pingcap / tiup

A component manager for TiDB
https://tiup.io
Apache License 2.0
425 stars 312 forks source link

Optimized the active judgment command #2378

Open hackersean opened 9 months ago

hackersean commented 9 months ago

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 'tidb@172.17.0.17: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

Code changes

Side effects

Related changes

Release notes:

NONE
CLAassistant commented 9 months ago

CLA assistant check
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.

ti-chi-bot[bot] commented 9 months ago

Welcome @hackersean! It looks like this is your first PR to pingcap/tiup 🎉

codecov-commenter commented 9 months ago

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 ```diff @@ 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](https://app.codecov.io/gh/pingcap/tiup/pull/2378/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [cluster](https://app.codecov.io/gh/pingcap/tiup/pull/2378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `45.09% <100.00%> (-0.15%)` | :arrow_down: | | [dm](https://app.codecov.io/gh/pingcap/tiup/pull/2378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `25.51% <100.00%> (-<0.01%)` | :arrow_down: | | [playground](https://app.codecov.io/gh/pingcap/tiup/pull/2378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `15.16% <0.00%> (-1.37%)` | :arrow_down: | | [tiup](https://app.codecov.io/gh/pingcap/tiup/pull/2378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `33.60% <ø> (-0.04%)` | :arrow_down: | | [unittest](https://app.codecov.io/gh/pingcap/tiup/pull/2378/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `22.23% <ø> (+0.08%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

AstroProfundis commented 8 months ago

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?

ti-chi-bot[bot] commented 7 months ago

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

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/pingcap/tiup/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment