Optimized the active judgment command
What problem does this PR solve?
when use GNU bash, version 5.2.21(1)-release (x86_64-redhat-linux-gnu) scale-out will be failed
- Reload prometheus -> 172.17.0.17:9090 ... Error
- Reload grafana -> 172.17.0.17:3000 ... Done
Error: stdout: , stderr:Failed to connect to bus: No such file or directory
bash: -c: line 1: conditional binary operator expected
bash: -c: line 1: syntax error near `active'
bash: -c: line 1: `systemctl daemon-reload && if [[ == active ]]; then systemctl reload prometheus-9090.service; fi'
: executor.ssh.execute_failed: Failed to execute command over SSH for '[email protected]:22' {ssh_stderr: Failed to connect to bus: No such file or directory
bash: -c: line 1: conditional binary operator expected
bash: -c: line 1: syntax error near `active'
bash: -c: line 1: `systemctl daemon-reload && if [[ == active ]]; then systemctl reload prometheus-9090.service; fi'
, ssh_stdout: , ssh_command: export LANG=C; PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin /usr/bin/sudo -H bash -c "systemctl daemon-reload && if [[ $(systemctl is-active prometheus-9090.service) == "active" ]]; then systemctl reload prometheus-9090.service; fi"}, cause: Process exited with status 2
Manual execution also generates an error
[tidb@d86d4890486f ~]$ sudo -H bash -c "systemctl daemon-reload && if [[ $(systemctl is-active prometheus-9090.service) == "active" ]]; then systemctl reload prometheus-9090.service; fi"
Failed to connect to bus: No such file or directory
bash: -c: line 1: conditional binary operator expected
bash: -c: line 1: syntax error near `active'
bash: -c: line 1: `systemctl daemon-reload && if [[ == active ]]; then systemctl reload prometheus-9090.service; fi'
What is changed and how it works?
Optimized shell statement
Check List
Tests
- Unit test
- Integration test
- Manual test (add detailed scripts or steps below)
- No code
Code changes
- Has exported function/method change
- Has exported variable/fields change
- Has interface methods change
- Has persistent data change
Side effects
- Possible performance regression
- Increased code complexity
- Breaking backward compatibility
Related changes
- Need to cherry-pick to the release branch
- Need to update the documentation
Release notes:
NONE
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Welcome @hackersean! It looks like this is your first PR to pingcap/tiup 🎉
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 55.60%. Comparing base (
6f01692) to head (26915c6). Report is 5 commits behind head on master.
:exclamation: Current head 26915c6 differs from pull request most recent head 01de734. Consider uploading reports for the commit 01de734 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #2378 +/- ##
==========================================
- Coverage 55.96% 55.60% -0.36%
==========================================
Files 329 329
Lines 35221 35025 -196
==========================================
- Hits 19709 19474 -235
- Misses 13141 13215 +74
+ Partials 2371 2336 -35
| Flag | Coverage Δ | |
|---|---|---|
| cluster | 45.09% <100.00%> (-0.15%) |
:arrow_down: |
| dm | 25.51% <100.00%> (-<0.01%) |
:arrow_down: |
| playground | 15.16% <0.00%> (-1.37%) |
:arrow_down: |
| tiup | 33.60% <ø> (-0.04%) |
:arrow_down: |
| unittest | 22.23% <ø> (+0.08%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This looks like an issue of systemd on the target server, maybe your systemd service is not in a normal state or maybe you are using a --user scope?
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign kaaaaaaang for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment