-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
MDEV-19210: use environment file in systemd units for _WSREP_* #1143
Conversation
I have filled out the contribution agreement and sent it. |
4dabf8c
to
4ec2c15
Compare
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 think this is a great improvement in deducing the need for PermissionStartOnly=true
.
Final question for clarity, is what is the cleaning policy on support-files/tmpfiles.conf.in that contain d @MYSQL_UNIX_DIR@
?
support-files/mariadb.service.in
Outdated
@@ -84,7 +83,7 @@ ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITI | |||
@SYSTEMD_EXECSTARTPOST@ | |||
|
|||
# Unset _WSREP_START_POSITION environment variable. | |||
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" | |||
ExecStartPost=@bindir@/rm @MYSQL_UNIX_DIR@/wsrep-start-position |
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.
@bindir@
is referring to the mariadb location, so I think an absolute /bin/rm
is safe here, especially as systemd is linux only.
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 was not certain about what path to choose. Can we be sure /bin/rm
will not break?
(For Arch it is fine.)
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.
Just a few tests:
# docker run ubuntu:18.04 ls -la /bin/rm /usr/bin/rm ls: cannot access '/usr/bin/rm': No such file or directory -rwxr-xr-x. 1 root root 63704 Jan 18 2018 /bin/rm # docker run ubuntu:16.04 ls -la /bin/rm /usr/bin/rm ls: cannot access '/usr/bin/rm': No such file or directory -rwxr-xr-x. 1 root root 60272 Mar 2 2017 /bin/rm # docker run ubuntu:14.04 ls -la /bin/rm /usr/bin/rm ls: cannot access /usr/bin/rm: No such file or directory -rwxr-xr-x. 1 root root 60160 Mar 10 2016 /bin/rm # docker run alpine ls -la /bin/rm /usr/bin/rm ls: /usr/bin/rm: No such file or directory lrwxrwxrwx 1 root root 12 Jan 9 2018 /bin/rm -> /bin/busybox # docker run debian:stable ls -la /bin/rm /usr/bin/rm ls: cannot access '/usr/bin/rm': No such file or directory -rwxr-xr-x. 1 root root 64424 Feb 22 2017 /bin/rm # docker run debian:oldstable ls -la /bin/rm /usr/bin/rm ls: cannot access /usr/bin/rm: No such file or directory -rwxr-xr-x. 1 root root 60072 Mar 14 2015 /bin/rm # docker run centos:6 ls -la /bin/rm /usr/bin/rm ls: cannot access /usr/bin/rm: No such file or directory -rwxr-xr-x. 1 root root 53592 Mar 22 2017 /bin/rm # docker run centos:7 ls -la /bin/rm /usr/bin/rm -rwxr-xr-x. 1 root root 62864 Nov 5 2016 /bin/rm -rwxr-xr-x. 1 root root 62864 Nov 5 2016 /usr/bin/rm # docker run fedora:29 ls -la /bin/rm /usr/bin/rm -rwxr-xr-x. 1 root root 86432 Nov 7 15:14 /bin/rm -rwxr-xr-x. 1 root root 86432 Nov 7 15:14 /usr/bin/rm
4ec2c15
to
3fbae48
Compare
A non-capital |
Just added another commit to update |
3fbae48
to
fa34e83
Compare
fa34e83
to
9995053
Compare
Hey @fauust, looks like you are doing some systemd work. Is this something for you? |
@eworm-de, I do Debian packaging and debug for MariaDB foundation and systemd too, so yes I will look at this too. |
Note this accidentally(?) reverts and removes the a+x permissions on scripts/galera_new_cluster.sh within git so maybe the added chmod isn't needed. galera_new_cluster needs a multi-instance argument ( |
We have the literal
Right, that's not yet implemented. However #510 removes wsrep support from multi-instance unit. Any decision on whether or not that goes in? |
9995053
to
745502d
Compare
No idea what excuse is being applied for not merging #510. In MDEV-18863 Geoff is advocating there are users of galera systemd multiinstance so hence me re-looking at this one to re-add galera support while keeping |
About to update the script for multi-instance support then. |
745502d
to
d77e660
Compare
Updated... I hope this covers all cases now. |
@@ -21,11 +21,11 @@ EOF | |||
exit 0 | |||
fi | |||
|
|||
systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' && \ | |||
echo _WSREP_NEW_CLUSTER='--wsrep-new-cluster' > @mysqlunixdir@/"wsrep-new-cluster-${1:-mariadb}" && \ |
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.
-
before $
breaks it for mariadb@service
Maybe something like:
SERVICE=${1:-mariadb@service} FILE=@mysqlunixdir@/wsrep-new-cluster-${SERVICE} echo _WSREP_NEW_CLUSTER='--wsrep-new-cluster' > "${FILE}" ... .. systemctl start "$SERVICE" rm -f "$FILE"
And then have both mariadb.service.in and mariadb@service.in the same with:
EnvironmentFile=-@mysqlunixdir@/wsrep-new-cluster-%n EnvironmentFile=-@mysqlunixdir@/wsrep-start-position-%n
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.
Let's have a look at what my code does. ${1:-mariadb}
evaluates to:
mariadb
when argument is omitted -> the main unitmariadb
formariadb
-> the main unitmariadb@foo
formariadb@foo
- > instantiated unit
Within the unit files I use %N
, which is the full unit name with type suffix removed.
I still think this works as-is. Or did I get anything wrong?
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.
Ah, missed default expansion and a more specific indicator that the filename was incorrect. So mariadb.service.in needs @mysqlunixdir@/wsrep-start-position-mariadb
rather than @mysqlunixdir@/wsrep-start-position
.
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.
No, that's not true. The file @mysqlunixdir@/wsrep-start-position
is generated in main unit in StartExecPre=
without -mariadb
suffix.
(In contrast to file @mysqlunixdir@/wsrep-new-cluster-%N
, which has the suffix as it is generated in script galera_new_cluster
.)
mariadb.service
:
@mysqlunixdir@/wsrep-start-position
@mysqlunixdir@/wsrep-new-cluster-%N
mariadb@.service
:
@mysqlunixdir@/wsrep-start-position-%N
@mysqlunixdir@/wsrep-new-cluster-%N
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.
oh, so sorry. Going to sleep now.
d77e660
to
b939738
Compare
🐌 |
No idea why the CLA stuff popped up lately... Just (re-)signed. |
b939738
to
ed5c5c3
Compare
Just rebased... |
ed5c5c3
to
61ad108
Compare
61ad108
to
456fb66
Compare
Hi @eworm-de, I'm trying to get older pull requests to some kind of resolution. As a result, I want to get this one into a place where it can be reviewed properly. I've tried rebasing it against 10.4, and I am having problems with Could you please rebase against 10.4 for us? We can review it for you as a matter of priority. |
456fb66
to
bb09521
Compare
Rebased for current |
Support for Galera in multi-instance service has been dropped in 91f1694. So we can just drop that part. |
bb09521
to
a3bf388
Compare
Rebased for current |
We used to run `systemctl set-environment` to pass _WSREP_START_POSITION. This is bad because: * it clutter systemd's environment (yes, pid 1) * it requires root privileges * options (like LimitNOFILE=) are not applied Let's just create an environment file in ExecStartPre=, that is read before ExecStart= kicks in. We have _WSREP_START_POSITION around for the main process without any downsides.
Now that the systemd unit files use an environment file to pass _WSREP_START_POSITION we have to update galera_new_cluster as well.
a3bf388
to
fd256d2
Compare
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.
Nice work, many thanks!
@eworm-de unfortunately I had to revert this because it was breaking the build on some of the Debian builders. For example: https://buildbot.mariadb.net/buildbot/builders/kvm-deb-buster-aarch64/builds/3742 |
Looks like this is the message from command that fails:
But there is nothing in Please note that |
Yes, added here... Lines 48 to 49 in 161ce04
Broken just for Debian. 😜 |
I guess for Debian we should not remove this:
Is there an easy way to verify? |
I think something like #2724 should resolve this properly. |
How to proceed here? Do I have to open a new pull request? |
Just opened #2726... Let's continue there. |
We used to run
systemctl set-environment
to pass_WSREP_START_POSITION. This is bad because:
Let's just create an environment file in ExecStartPre=, that is read
before ExecStart= kicks in. We have _WSREP_START_POSITION around for the
main process without any downsides.