967 Commits

Author SHA1 Message Date
Filipe Roque
c9973b4ba6 Fix recompile spelling 2024-04-30 09:26:00 +01:00
Kazunori Kimura
351711c4cc Simplify message on feature flag target specified as reviewed
like below:

````
Configuring gitlab::feature_flags...
- Launching rails runner to set feature flags. This will take some time....
- Specified feature flags  to be disabled:
--- "auto_devops_banner_disabled"
--- "invalid_flag_name"
- Specified feature flags  to be enabled
--- "git_push_create_all_pipelines"
--- "another_invalid_flag_name"
- Following flags are probably invalid and have been ignored
--- invalid_flag_name
--- another_invalid_flag_name
- Apply user defined feature flags:
--- auto_devops_banner_disabled : off
--- git_push_create_all_pipelines : on
````

- Do not `puts` parsed options (formatted by ruby's `.to_s`),
  `puts` each specified target with three hyphens instead
- `puts` each ignored target on each line with three hyphens instead of single line csv
2024-03-24 19:17:25 +09:00
Kazunori Kimura
05794a2b47 Allow setting feature flags via configuration parameter
- It requires database is set up because
  feature flags are stored to DB (table `application_settings`)
- Add configuration parameter GITLAB_FEATURE_FLAGS_ENABLE_TARGETS
  and GITLAB_FEATURE_FLAGS_DISABLE_TARGETS
- Add ruby script to configure feature flags from command line
  and invoke runtime (from configure_gitlab())
2024-03-24 18:43:51 +09:00
Kazunori Kimura
846a051bbe Allow additional configurations after DB migration
Such as feature flags (which is stored to database, application_settings table)

At this commit, it does nothing (no operation `:`)
2024-03-24 18:43:51 +09:00
Kazunori Kimura
9f5961939d Allow patching Ruby, add patch for lib/securernadom.rb
Backport: fix behavior of `SecureRandom.gen_random_openssl(n)`
commit:
64e503eb62

This has been merged into the Ruby 3.3 release, but Ruby (at least) 3.0 and later are affected by the issues fixed by this commit.
2024-02-13 04:27:50 +09:00
Kazunori Kimura
e636b969a9 Revise build patch structure
to allow patching each middleware or library

Just move patches to assets/build/patches/gitlabhq
Folder name are matched to assets/runtime/config
2024-02-13 04:27:50 +09:00
Steven Achilles
74f8514385
Merge pull request #2901 from danyill/issue-2790-secure-ci-folder
Create ci_secure_files directory if missing, closes #2790
2024-02-12 19:55:10 +01:00
Daniel Mulholland
3f2e8c2ce4
Create ci_secure_files directory if missing, closes #2790 2024-02-11 10:17:36 +13:00
Kazunori Kimura
1c286f72d1 Remove trailing whitespace in patch for assets:compile
to suppress warning on build like below:

    Applying patch /etc/docker-gitlab/build/patches/0004-fix-raketask-gitlab-assets-compile.patch for gitlab-foss...
    <stdin>:15: trailing whitespace.
           removal_targets += Dir.children(Tasks::Gitlab::Assets::PUBLIC_ASSETS_DIR).map {|child| File.join(Tasks::Gitlab::Assets::PUBLIC_ASSETS_DIR, child)}
    warning: 1 line adds whitespace errors.
2024-01-30 06:39:52 +00:00
Kazunori Kimura
9345235f27 Replace removed function in patch for assets::compile
`Dir.exists?(file_name) -> bool` have been deprecated since Ruby 2.1
and removed on Ruby 3.2.
See https://bugs.ruby-lang.org/issues/17391

Replacement is `Dir.exist?(file_name) -> bool`.
2024-01-30 06:39:52 +00:00
Steven Achilles
5b092729fa
Merge pull request #2884 from kkimurak/issue/2866-fix-assets_webpack_manifest.json-not-found
Add build patch to prevent rake task assets:compile to remove assets dir
2024-01-19 22:53:40 +01:00
Kazunori Kimura
3885a455d1 Add build patch to prevent rake task assets:compile to remove assets dir
GitLab does not launch after second run if relative url is used.
This is caused by following upstream change to remove assets directory on assets compile.
See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103715

This is introduced on v15.6.0
````sh
$ git -C ../gitlab.git/ tag --contains e46d92c0 | sort --version-sort | head -n 1
v15.6.0-ee
````

1. `sameersbn/gitlab` create symbolic link /home/git/gitlab/public/assets/
  to point /home/git/data/tmp/assets if relative url is used.
  This is to store assets in the docker volume to avoid unnecessary recompilations.
  These assets are removed and recompiled only when the gitlab version or relative url root is changed.
2. By the change provided by gitlab.com/gitlab-org/gitlab!103715,
  rake task `gitlab:assets:compile` became to remove assets directory directly (by `FileUtils.rm_rf()`).
  It does not remove compiled assets itself, but remove symlink /home/git/gitlab/public/assets .
  Then it compiles assets as usual, but they will be stored in newly-created normal directory /home/git/gitlab/public/assets/
3. On container down, whole container statement (except volumes) will be reset.
  These compiled assets will be removed as well because they are not in docker volume.
4. As we store version info and relative url root path to /home/git/data/tmp/,
  we cannot recognize we have to recompile assets (that have been removed by mistake)

To avoid the issue, this commit add a build time patch to change the behavior of rake task `gitlab:assets:compile`
to empty assets instead of removing assets directory itself.
2024-01-18 18:10:26 +09:00
Kazunori Kimura
d16119b54b Remove ajv as an explicit dependency
There was an issue that `ajv` is not installed by mistake.
This issue have been fixed on upstream, a few years ago.

Now, we can revert the change.
This commit partially reverts 985d57afb9673b2f5acb1f12cbc13f230f6ec074
See sameersbn/gitlab#1358

It seems that fix MR on upstream is https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14543
but we cannot check diff because source / target branch removed by mistake

Anyway, no need to add ajv as an explicit dependency with (at least) gitlab v11 or later
2024-01-18 15:42:17 +09:00
Steven Achilles
af17c908cf
Merge pull request #2847 from kkimurak/add-patch-for-preinstall.mjs-relative_url
Add build patch to avoid removing node_modules
2023-11-19 13:29:05 +01:00
massej
e574613c9e
Update assets/runtime/config/gitlabhq/gitlab.yml
Co-authored-by: Kazunori Kimura <33391846+kkimurak@users.noreply.github.com>
2023-10-24 08:23:11 -04:00
massej
0001125859
Update env-defaults 2023-10-24 08:22:08 -04:00
massej
d11ae7b617
Added missing configuration variable OAUTH_ALLOW_BYPASS_TWO_FACTOR. 2023-10-23 22:17:20 -04:00
Steven Achilles
daae8b70d3
Merge pull request #2841 from massej/patch-1
Added - OAuth2 Generic - missing label and scope variables
2023-10-23 22:45:00 +02:00
Kazunori Kimura
da0d78bf5b Add build patch to avoid removing node_modules
note: Only affected if using the relative_url feature

`gitlab/script/frontent/preinstall.mjs` is introduced since v16.4.0.
This script is executed on container startup, if using the relative url.
This script removes `NODE_MODULES` (/home/git/gitlab/node_modules) when
"the folder seems to end up being a corrupted somehow"
See more detail:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130938

On sameersbn/gitlab, the folder node_modules is declared as volume.
The volume is always busy so that cannot be removed in the container.
You can see following error reported on container startup
(sameersbn/gitlab:16.4.0 or later).

````
yarn install v1.22.19
$ node ./scripts/frontend/preinstall.mjs
[WARNING] package.json changed significantly. Removing node_modules to be sure there are no problems. node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

[Error: EBUSY: resource busy or locked, rmdir '/home/git/gitlab/node_modules'] {
  errno: -16,
  code: 'EBUSY',
  syscall: 'rmdir',
  path: '/home/git/gitlab/node_modules'
}

Node.js v18.17.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. -----
````

This PR add a build time patch to change the behavior of
script/frontend/preinstall.mjs to not to remove node_modules directly,
but empty it instead.
2023-10-21 01:24:39 +09:00
Kazunori Kimura
a2dd4e5ed8 Accept multiple hosts for RACK_ATTACK_WHITELIST
see sameersbn/docker-gitlab#2828

The current setup also accepts multiple hosts,
but the syntax is a bit strange.
The leading/trailing double quotes are embedded
in the configuration file itself,
so users should expect double quotes around the string they set.
In other words, when setting two hosts 0.0.0.0 and 1.1.1.1,
you will set the strings 0.0.0.0","1.1.1.1 in the
environment variables. This is not intuitive.

This commit removes double quote around corresponding config
and set backward compatibility fallback process
to surround whole with [], each host with double quote.
Also, validation script (written in ruby) will be executed during configuration.

Example docker-compose.yml
````yaml
services:
  gitlab:
    image: sameersbn/gitlab:latest
    environment:
    - RACK_ATTACK_WHITELIST='["127.0.0.1","0.0.0.0"]'
````

Co-authored-by: Mikhail Khadarenka <chodorenko@mail.ru>
2023-10-20 22:24:22 +09:00
massej
a903d98290
Update functions 2023-10-01 13:45:02 -04:00
massej
af693c5ecc
Update env-defaults 2023-10-01 13:44:28 -04:00
massej
c8bc43b914
Added missing label and scope variable field. 2023-10-01 13:40:45 -04:00
Steven Achilles
2fb3680976 Remove temporary patch for lfs object URL (see c51770292e) 2023-09-02 08:28:56 +02:00
Steven Achilles
c51770292e Add temporary patch for lfs object URL 2023-08-23 18:57:51 +02:00
Steven Achilles
fbb9a7422b Update puma.rb 2023-06-24 08:40:57 +02:00
Steven Achilles
a63405d433 Add pool option to database.yml 2023-06-18 09:42:35 +02:00
Kazunori Kimura
7140f0342b Fix unused client removal on restarted container
Handle the case where the target does not exist
in the process of deleting unused clients.
Such a situation will not occur in newly launched containers,
but will occur if they are restarted.

During container restarts, container status are preserved.
If the unused database client was deleted in the last run,
grep will not match anything.
It returns non-zero code and the container stops there
because entrypoint sets option `-e`
(exit immediately on non-zero exit code excluding some special cases)

This commit make the uninstall process to handle the case
UNUSED_DB_CLIENTS is empty.
2023-06-02 22:12:29 +09:00
Steven Achilles
230284ebcf Do not copy ruby by installing gitaly 2023-05-25 18:14:23 +02:00
Steven Achilles
5fc732eb3c Add new configuration options for database.yml 2023-05-25 06:44:20 +02:00
Kazunori Kimura
598a666693 Add -y option on uninstalling unused db client
Co-authored-by: Steven Achilles <steven.achilles@googlemail.com>
Co-authored-by: @f-io
2023-05-25 12:44:32 +09:00
Kazunori Kimura
24e2b581fb Use purge instead to uninstall unused db clients
Instead of `remove` that does not remove actual files.

Co-authored-by: @f-io
2023-05-24 20:26:15 +09:00
Kazunori Kimura
b3b700a701 Uninstall unused postgresql-client on startup
Unused clients are determinate by checking ~/.postgresqlrc
Uninstall logs like the following will appear in the docker log:

- Uninstalling unused version(s) of client: postgresql-client-12
2023-05-12 06:58:11 +09:00
Kazunori Kimura
260f548c5b Ship with multiple versions of postgresql-client
It is intended to work even in environments without an internet connection.

- Use latest version of pg_isready on checking database connection
- Switch postgresql-client version checking server on startup
- If the server versions do not match exactly, use the latest installed client
  and warn on docker log

From postgresql documentation:
https://www.postgresql.org/docs/15/app-pgdump.html#PG-DUMP-NOTES

> Also, it is not guaranteed that pg_dump's output can be loaded
> into a server of an older major version — not even if the dump
> was taken from a server of that version.

To switch client version, generate a file ~/.postgresqlrc with content like:

{server side major version} {server hostname}:{server port} {default database}

See detail on:
https://manpages.ubuntu.com/manpages/bionic/man5/postgresqlrc.5.html

Following messages appear on docker log:

- Detected server version: 140007
- Generating /home/git/.postgresqlrc
2023-05-12 06:58:11 +09:00
Kazunori Kimura
029186dc63 Avoid permission error on creating config file
`assets/build/config/database.yml.postgresql` is owned by root:root,
and permission is rwxrw----
so the user `git` (`${GILTAB_USER}`) doesn't have a permission to copy the file.
This raises an error while building.
2023-04-17 16:06:35 +09:00
Steven Achilles
5450187484
Merge pull request #2735 from zimmski/enable-git-protocol-2
Allow SSH clients to explicitly set the Git transfer protocol
2023-04-12 16:17:53 +02:00
Kazunori Kimura
95bc778ee0 Silence "CRIT unixServer" warning from supervisord
Silence the message like below:
  CRIT Server 'unix_http_server' running without any HTTP authentication checking

Reference:
  https://github.com/Supervisor/supervisor/issues/717#issuecomment-176860145
  https://github.com/sameersbn/docker-redmine/commit/0fb84b9
2023-03-31 03:01:19 +09:00
Markus Zimmermann
4bfc8974ba
Allow SSH clients to explicitly set the Git transfer protocol
This allows to the client to explicitly select protocol version 2, which is much more efficient. Without allowing that environment variable it seems that SSH connections are always stuck in version1.  See https://docs.gitlab.com/ee/administration/git_protocol.html on how to check if protocol 2 is used.
2023-03-24 11:55:42 +01:00
Steven Achilles
9e58a673c1
Merge pull request #2716 from kkimurak/increase-default-sidekiq-memory-killer-max-rss
Increase default value for SIDEKIQ_MEMORY_KILLER_MAX_RSS to 2GB
2023-03-13 00:29:03 +01:00
Kazunori Kimura
a1dcfe6eaf Update sidekiq supervisord config; sidekiq v6.0
Sidekiq is updated to v6.0 here (first contained tag: v14.4.0-ee)
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69655

In Sidekiq 6.0, these options have been marked as "deprecated":
-P (set pid file)
-L (set log file)
See https://github.com/sidekiq/sidekiq/commit/3f5b1c5

Now, we can see error message in {GITLAB_LOGS_DIR}/supervisor/sidekiq.log
like below:

----
ERROR: PID file creation was removed in Sidekiq 6.0, please use a proper process supervisor to start and manage your services
ERROR: Logfile redirection was removed in Sidekiq 6.0, Sidekiq will only log to STDOUT
----

Just stop using this option.
2023-02-22 20:42:51 +09:00
Kazunori Kimura
10a48c1541 Clarify user=root in supervisord.conf
to prevent "Supervisor running as root" warning
2023-02-22 20:42:51 +09:00
Kazunori Kimura
255ec9461a Increase default SIDEKIQ_MEMORY_KILLER_MAX_RSS to 2GB
There are many warnings like below
recorded in {GITLAB_LOG_DIR}/supervisord/sidekiq.log.
This can be avoided by simply increasing SIDEKIQ_MEMORY_KILLER_MAX_RSS.

----
{
  "severity": "WARN",
  "time": "[MASKED]",
  "class": "Gitlab::SidekiqDaemon::MemoryKiller",
  "pid": [MASKED],
  "message": "Sidekiq worker RSS out of range",
  "current_rss": 1009636,
  "soft_limit_rss": 1000000,
  "hard_limit_rss": [MASKED],
  "memory_total_kb": [MASKED],
  "reason": "current_rss(1009636) \u003e soft_limit_rss(1000000)",
  "running_jobs": [],
  "retry": 0
}
----

For sameersbn/gitlab, this parameter have been introduced with
following commit on May 21, 2015 and never updated until today:
e4008cc7ab9efd626511af4c43e52e2a9490d612

On upstream, the default setting documentation is updated here:
  https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/31682
but it is said "the documentation is outdated" at this time.
I could not find out when the value is increased.

At least, In omnibus-gitlab, this have been introduced in MR 2360
(release 11.10.0+ce.0 / 11.10.0+ee.0)
https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/2360
2023-02-22 04:00:45 +09:00
Antt1995
8db9ed8908
Upgrade Go & safe dir 2022-11-23 15:14:40 +00:00
kkkkkks0
f408585d8b
fixes sameersbn#2645 2022-10-20 18:58:03 +08:00
Ivan Baranov
8b9ca622f9 Tested support for azure_activedirectory_v2 2022-09-05 21:46:20 +09:00
Steven Achilles
5c9c5cad1b Temporary remove geo from config/database.yml 2022-07-02 15:49:54 +02:00
Steven Achilles
b34d48af65
Merge pull request #2594 from Syphon83/terraform_state_fix
refs https://github.com/sameersbn/docker-gitlab/issues/2593: fix env default variable for terraform state
2022-07-02 15:47:07 +02:00
Steven Achilles
eba7979564
Merge pull request #2579 from kkimurak/set-upload-object_store-enabled-even-if-disabled
Set `*:object_store:enabled` in gitlab.yml regardless the value
2022-07-02 15:46:54 +02:00
Poppo
7d0739218f fix env default variable 2022-06-24 20:12:32 +02:00
Kazunori Kimura
fbcdd290be fix condition to apply patch during build gitlab
rewrite patch applying with find | while read chain
`if [[ -f ]]` with globbing may not works
2022-06-21 08:46:32 +09:00