Skip to content

systemd: Fix -Dpid arg passing to systemd usage service#3210

Merged
GabrielBrascher merged 3 commits into
apache:4.11from
shapeblue:usage-systemd-fix
Mar 14, 2019
Merged

systemd: Fix -Dpid arg passing to systemd usage service#3210
GabrielBrascher merged 3 commits into
apache:4.11from
shapeblue:usage-systemd-fix

Conversation

@yadvr
Copy link
Copy Markdown
Member

@yadvr yadvr commented Mar 12, 2019

This fixes regression introduced by refactoring PR #3163 where -Dpid
was incorrectly passed string $$ instead of parent PID integer.

Fixes #3203

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

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>
@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 12, 2019

cc @andrijapanic @PaulAngus @ustcweizhou

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 12, 2019

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2627

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 12, 2019

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

Copy link
Copy Markdown
Member

@GabrielBrascher GabrielBrascher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Type=simple
EnvironmentFile=/etc/default/cloudstack-usage
ExecStart=/usr/bin/java $JAVA_OPTS -cp $CLASSPATH $JAVA_CLASS
Environment=JAVA_PID=$$
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 12, 2019

@GabrielBrascher fixed the issue, it was systemd variable referencing/syntax issue which per following docs should be ${VAR} instead of $VAR:
https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines

After my last commit, it's working again.

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 12, 2019

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2628

@andrijapanicsb
Copy link
Copy Markdown
Contributor

LGTM

Tested and the job does kick in as expected.

@GabrielBrascher
Copy link
Copy Markdown
Member

@rhtyd @andrijapanic are you testing it with CentOS? On Ubuntu I still get error. Now the exception is: java.lang.NumberFormatException: For input string: "$$"

@andrijapanicsb
Copy link
Copy Markdown
Contributor

yes, Centos7
let me build Ubuntu lab - 18.04 sounds fine ?

@GabrielBrascher
Copy link
Copy Markdown
Member

@rhtyd @andrijapanic nevermind, my mistake when updating the script at this time. Due to the /bin/sh -ec '' it works now. Thanks!

@andrijapanicsb
Copy link
Copy Markdown
Contributor

Cool - let's LGTM this one and close if you are OK with it @GabrielBrascher ?

@GabrielBrascher
Copy link
Copy Markdown
Member

GabrielBrascher commented Mar 12, 2019

@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.

} catch (Exception e) {
    e.printStackTrace();
}

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-3418)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 22699 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3210-t3418-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
Smoke tests completed. 68 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 12, 2019

@GabrielBrascher okay I'll move that to logging tomorrow.
@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-3419)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 23399 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3210-t3419-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_outofbandmanagement.py
Intermittent failure detected: /marvin/tests/smoke/test_host_maintenance.py
Smoke tests completed. 68 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@ustcweizhou
Copy link
Copy Markdown
Contributor

tested ok in 4.11.2
LGTM

@GabrielBrascher
Copy link
Copy Markdown
Member

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!

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 13, 2019

@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.

@GabrielBrascher
Copy link
Copy Markdown
Member

No problem @rhtyd, thanks!

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 14, 2019

@GabrielBrascher done

@GabrielBrascher GabrielBrascher merged commit f7327c7 into apache:4.11 Mar 14, 2019
@GabrielBrascher
Copy link
Copy Markdown
Member

Thanks, @rhtyd! I am merging this PR.

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Mar 14, 2019

@GabrielBrascher, I've forward merged it to master now, in case you want to cut the RC or address another issue. Thanks.

@GabrielBrascher
Copy link
Copy Markdown
Member

Time to spin out RC5 then, thanks!

pbankonier pushed a commit to pbankonier/cloudstack that referenced this pull request Apr 24, 2019
* 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>
nvazquez pushed a commit to shapeblue/cloudstack that referenced this pull request Jul 24, 2019
* 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>
ustcweizhou pushed a commit to ustcweizhou/cloudstack that referenced this pull request Feb 14, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants