systemd: Fix -Dpid arg passing to systemd usage service#3210
Conversation
This fixes regression introduced by refactoring PR apache#3163 where `-Dpid` was incorrectly passed string `$$` instead of parent PID integer. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
cc @andrijapanic @PaulAngus @ustcweizhou |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2627 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
GabrielBrascher
left a comment
There was a problem hiding this comment.
@rhtyd when debugging it I get the PID as a string "$JAVA_PID". With the silenced exception java.lang.NumberFormatException: For input string: "$JAVA_PID"
The solution on PR #3207 is not pretty, I agree with you. However, the systemd unit process the Environment as a string, not a script. Thus, had to execute a script with the ExecStartPost to provide a workaround on the PID.
…ntax https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
| Type=simple | ||
| EnvironmentFile=/etc/default/cloudstack-usage | ||
| ExecStart=/usr/bin/java $JAVA_OPTS -cp $CLASSPATH $JAVA_CLASS | ||
| Environment=JAVA_PID=$$ |
There was a problem hiding this comment.
@GabrielBrascher @andrijapanic moved the JAVA_PID here so users can't change/mess it around. The systemd variable referencing is limiting, the fix was to use the ${VAR} syntax and not $VAR syntax. Can you believe it! https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines
|
@GabrielBrascher fixed the issue, it was systemd variable referencing/syntax issue which per following docs should be After my last commit, it's working again. |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2628 |
|
LGTM Tested and the job does kick in as expected. |
|
@rhtyd @andrijapanic are you testing it with CentOS? On Ubuntu I still get error. Now the exception is: |
|
yes, Centos7 |
|
@rhtyd @andrijapanic nevermind, my mistake when updating the script at this time. Due to the /bin/sh -ec '' it works now. Thanks! |
|
Cool - let's LGTM this one and close if you are OK with it @GabrielBrascher ? |
|
@rhtyd it looks good. Thanks! Can you please also remove the lines that are silencing the exception? I don't see any reason for print on the stack trace (console) the exceptions. |
|
Trillian test result (tid-3418)
|
|
@GabrielBrascher okay I'll move that to logging tomorrow. |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3419)
|
|
tested ok in 4.11.2 |
|
All checks have passed (Travis, Jenkins, Trillian) passed and we have 3 LGTMs. I also tested and it worked. @rhtyd this PR is looking good. @rhtyd just to keep track on the exception silenced; will you be able to add a commit addressing that exception silenced? Adding the JAVA_DEBUG is great, fixing that exception is also a great plus to help users on debugging. Thanks for the work! |
|
@GabrielBrascher sorry forgot about that amidst dayjob work. I can do that tomorrow, or if you'd prefer you nay push your changes to this PR's branch. |
|
No problem @rhtyd, thanks! |
…cloudstack/pull/3207/files#diff-062fcf5ae32de59dfd6cd4f780e1d7cd Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
@GabrielBrascher done |
|
Thanks, @rhtyd! I am merging this PR. |
|
@GabrielBrascher, I've forward merged it to master now, in case you want to cut the RC or address another issue. Thanks. |
|
Time to spin out RC5 then, thanks! |
* systemd: Fix -Dpid arg passing to systemd usage service This fixes regression introduced by refactoring PR apache#3163 where `-Dpid` was incorrectly passed string `$$` instead of parent PID integer. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * fix systemd limitation, exec using /bin/sh instead and wrap in ${} syntax https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * usage: don't hide exception from Gabriel's https://github.com/apache/cloudstack/pull/3207/files#diff-062fcf5ae32de59dfd6cd4f780e1d7cd Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
* systemd: Fix -Dpid arg passing to systemd usage service This fixes regression introduced by refactoring PR apache#3163 where `-Dpid` was incorrectly passed string `$$` instead of parent PID integer. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * fix systemd limitation, exec using /bin/sh instead and wrap in ${} syntax https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * usage: don't hide exception from Gabriel's https://github.com/apache/cloudstack/pull/3207/files#diff-062fcf5ae32de59dfd6cd4f780e1d7cd Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit f7327c7) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
* systemd: Fix -Dpid arg passing to systemd usage service This fixes regression introduced by refactoring PR apache#3163 where `-Dpid` was incorrectly passed string `$$` instead of parent PID integer. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * fix systemd limitation, exec using /bin/sh instead and wrap in ${} syntax https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * usage: don't hide exception from Gabriel's https://github.com/apache/cloudstack/pull/3207/files#diff-062fcf5ae32de59dfd6cd4f780e1d7cd Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This fixes regression introduced by refactoring PR #3163 where
-Dpidwas incorrectly passed string
$$instead of parent PID integer.Fixes #3203
Types of changes