Limit etcd migration to swact actions

Currently the etcd migration will take place whenever
upgrade_swact_migration.py is called. Typically this is called during a
swact as part of etcd start. However the script can also be called
during etcd restart, which occurs as part of activating secured etcd.

The solution is to limit the etcd migration to controller-0. This will
ensure the action will only be taken during the swact to controller-0.

Closes-Bug: 1927508
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
Change-Id: I893eeaa7ddb0b600baa051498a30ed737c688151
This commit is contained in:
David Sullivan 2021-05-06 10:02:50 -05:00
parent 1399a4bc54
commit 37d348ae6d
1 changed files with 5 additions and 0 deletions

View File

@ -10,6 +10,7 @@
import os import os
import shutil import shutil
import socket
import subprocess import subprocess
import sys import sys
import yaml import yaml
@ -73,6 +74,10 @@ def migrate_etcd_on_swact():
UPGRADE_ETCD_FILE) UPGRADE_ETCD_FILE)
return return
if socket.gethostname() != 'controller-0':
LOG.info("Skipping etcd migration, not running on controller-0")
return
with open(UPGRADE_ETCD_FILE, 'r') as f: with open(UPGRADE_ETCD_FILE, 'r') as f:
document = yaml.safe_load(f) document = yaml.safe_load(f)