Skip to content

Commit

Permalink
Dev: utils: Change get_dc function as the behavior of crmadmin -D
Browse files Browse the repository at this point in the history
… changed (#1632)

The behavior of `crmadmin -D` changed when no DC elected
original:
```
# crmadmin -D -t 1
error: Timed out after 1000ms waiting for reply from controller API on DC
error: Command failed: Resource temporarily unavailable
```
now:
```
# crmadmin -D -t 1
Designated Controller is: not yet elected
```
  • Loading branch information
liangxin1300 authored Dec 17, 2024
2 parents 2731077 + 231425e commit 562ce84
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,7 @@ def append_file(dest, src):
def get_dc(peer=None):
cmd = "crmadmin -D -t 1"
_, out, _ = sh.cluster_shell().get_rc_stdout_stderr_without_input(peer, cmd)
if not out:
return None
if not out.startswith("Designated"):
if not out or not out.startswith("Designated") or "not yet elected" in out:
return None
return out.split()[-1]

Expand Down

0 comments on commit 562ce84

Please sign in to comment.