-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/gitlab: Fix state directory permissions, clean up initializers directory #68721
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested that this does not break an upgraded installation. If I link the two ymls to random files, they are replaced correctly. 👍
However, if the shell secret is owned by a different account than gitlab
, the start script still fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Please don't do this as this takes ages on larger gitlab installations (~15 mins for us).. |
If you restored the |
@globin Oh, for every config activation or just the first one? I guess it makes sense, since it has to stat all files recursively... :/ @aanderse That was my first thought, but it didn't work - systemd-tmpfiles emits the error message
which it apparently does when a file in a directory owned by an unprivileged user is owned by root... |
Okay, so I've gone with the earlier approach of running a privileged part and an unprivileged part of the |
Since the preStart script is no longer running in privileged mode, we reassign the files in the state directory and its config subdirectory to the user we're running as. This is done by splitting the preStart script into a privileged and an unprivileged part where the privileged part does the reassignment. Also, delete the database.yml symlink if it exists, since we want to create a real file in its place. Fixes NixOS#68696.
The initializers directory is populated with files from the gitlab distribution on start, but old files will be left in the state folder even if they're removed from the distribution, which can lead to startup failures. Fix this by always purging the directory on start before populating it.
I've pushed one additional commit that cleans up the @globin Do you have any issues with the current approach or could this be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested, nor ever used the gitlab
module on NixOS but I understand and approve of the basic idea behind this change. From my limited perspective the actual implementation looks fine as well. 👍
Motivation for this change
Since the preStart script is no longer running in privileged mode, recursively reassign all files in the state directory to the user we're running as. Also, delete the database.yml symlink if it exists,
since we want to create a real file in its place.
I've tested this by manually changing the owner of
gitlab_shell_secret
, and symlinkingdatabase.yml
andsecrets.yml
to an irrelevant file. Additional testing would be appreciated.The
config/initializers
directory is populated with files from the gitlab distribution on start, but old files will be left in the state folder even if they're removed from the distribution, which can lead tostartup failures. Fix this by always purging the directory on start before populating it.
Should hopefully fix #68696; if so, it needs to be pulled into 19.09 too.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @flokli @globin @aanderse @FRidh