Drop helmv2 database after Armada removal
This change adds a function to the Armada removal script that runs during platform upgrades giving it the ability to remove the helmv2 database if no Armada apps are present. Helm v2 is not supported anymore so its database should be dropped alongside the removal of Armada as no other platform components will make use of it. Test Plan: PASS: build-pkgs && build-image PASS: SX upgrade from stx-8 to master Check if helmv2 database was removed Story: 48480 Task: 2010560 Change-Id: I3c6489643bcf608893b8715f4d3c4a45c72e03ec Signed-off-by: Igor Soares <Igor.PiresSoares@windriver.com>
This commit is contained in:
parent
e0679eb6c0
commit
7f0341759a
|
@ -336,6 +336,39 @@ def remove_docker_images():
|
|||
return True
|
||||
|
||||
|
||||
def drop_helm_v2_database():
|
||||
"""
|
||||
Drop Helm v2 PostgreSQL database since it is not needed
|
||||
after Armada removal.
|
||||
"""
|
||||
|
||||
env = os.environ.copy()
|
||||
drop_database = subprocess.Popen(
|
||||
['sudo', '-u', 'postgres',
|
||||
'psql', '-c',
|
||||
'DROP DATABASE IF EXISTS helmv2'],
|
||||
env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
timer = threading.Timer(20, kill_process_and_descendants, [drop_database])
|
||||
|
||||
try:
|
||||
timer.start()
|
||||
_, err = drop_database.communicate()
|
||||
if drop_database.returncode != 0 and err:
|
||||
LOG.exception(err)
|
||||
return False
|
||||
elif drop_database.returncode != 0:
|
||||
LOG.error("Unknown error while dropping helmv2 database")
|
||||
return False
|
||||
except Exception as e:
|
||||
LOG.exception("Failed to drop helmv2 database: %s" % e)
|
||||
return False
|
||||
finally:
|
||||
timer.cancel()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
|
@ -367,6 +400,9 @@ def main():
|
|||
if not remove_docker_images():
|
||||
return 1
|
||||
|
||||
if not drop_helm_v2_database():
|
||||
return 1
|
||||
|
||||
LOG.info("Armada removed.")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
|
Loading…
Reference in New Issue