Skip to content

Commit

Permalink
Merge pull request #1212 from nicholasyang2022/bsc_1213050_20220706
Browse files Browse the repository at this point in the history
Fix: upgradeutil: support the change of path of upgrade_seq in crmsh-4.5 (bsc#1213050)
  • Loading branch information
liangxin1300 authored Jul 6, 2023
2 parents 4649fa4 + 8085b5f commit 3503893
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crmsh/upgradeutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# pump this seq when upgrade check need to be run
CURRENT_UPGRADE_SEQ = (1, 0)
DATA_DIR = os.path.expanduser('~hacluster/crmsh')
DATA_DIR = '/var/lib/crmsh'
SEQ_FILE_PATH = DATA_DIR + '/upgrade_seq'
# touch this file to force a upgrade process
FORCE_UPGRADE_FILE_PATH = DATA_DIR + '/upgrade_forced'
Expand Down Expand Up @@ -72,8 +72,21 @@ def _is_upgrade_needed(nodes):
except FileNotFoundError:
pass
if not needed:
s = _get_file_content(SEQ_FILE_PATH, b'').strip()
if s == b'':
# try the old path
seq_file_path = os.path.expanduser('~hacluster/crmsh') + '/upgrade_seq'
s = _get_file_content(seq_file_path, b'').strip()
if s != b'':
try:
os.mkdir(DATA_DIR)
except FileExistsError:
pass
with open(SEQ_FILE_PATH, 'wb') as f:
f.write(s)
f.write(b'\n')
try:
local_seq = _parse_upgrade_seq(_get_file_content(SEQ_FILE_PATH, b'').strip())
local_seq = _parse_upgrade_seq(s)
except ValueError:
local_seq = (0, 0)
needed = CURRENT_UPGRADE_SEQ > local_seq
Expand Down
7 changes: 7 additions & 0 deletions test/features/healthcheck.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ Feature: healthcheck detect and fix problems in a crmsh deployment
And File "~hacluster/.ssh/id_rsa" exists on "hanode1"
And File "~hacluster/.ssh/id_rsa" exists on "hanode2"
And File "~hacluster/.ssh/id_rsa" exists on "hanode3"

@clean
Scenario: An upgrade_seq file in ~hacluster/crmsh/ will be migrated to /var/lib/crmsh (bsc#1213050)
When Run "mv /var/lib/crmsh ~hacluster/" on "hanode1"
Then File "~hacluster/crmsh/upgrade_seq" exists on "hanode1"
When Run "crm cluster status" on "hanode1"
Then File "/var/lib/crmsh/upgrade_seq" exists on "hanode1"

0 comments on commit 3503893

Please sign in to comment.