
Since upgrade is responsibility of USM the upgrade scripts need to be moved to this repo. This commit adds the upgrade-scripts from config, note that the upgrade-scripts will still be located under /usr/local/share/upgrade.d folder. There's also a change in upgrade-scripts to use the log function from this repo instead of controllerconfig one. Also fix a log error in deploy scripts. Test Plan: PASS: Build-pkgs && build-image. PASS: Upgrade from 24.09 to 25.09 in sx. PASS: Install/bootstrap 25.09 in sx. PASS: Check if /usr/local/share/upgrade.d have the same scripts. PASS: Check scripts are logging accordingly. Story: 2011357 Task: 52196 Change-Id: Iab5e6d6f0348f996daf0adb2447d22c4216e537f Signed-off-by: Luis Eduardo Bonatti <luizeduardo.bonatti@windriver.com>
83 lines
2.5 KiB
Python
83 lines
2.5 KiB
Python
#!/usr/bin/python
|
|
# Copyright (c) 2022-2025 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# This script install fluxcd controllers in the fluxcd-helm namespace
|
|
# in kubernetes
|
|
#
|
|
# This script can be removed in the release that follows stx7
|
|
|
|
import logging
|
|
import subprocess
|
|
import sys
|
|
|
|
from sysinv.common import exception
|
|
from sysinv.common.retrying import retry
|
|
from sysinv.common.kubernetes import test_k8s_health
|
|
|
|
from software.utilities.utils import configure_logging
|
|
|
|
LOG = logging.getLogger('main_logger')
|
|
|
|
|
|
def main():
|
|
action = None
|
|
from_release = None
|
|
to_release = None
|
|
arg = 1
|
|
while arg < len(sys.argv):
|
|
if arg == 1:
|
|
from_release = sys.argv[arg]
|
|
elif arg == 2:
|
|
to_release = sys.argv[arg]
|
|
elif arg == 3:
|
|
action = sys.argv[arg]
|
|
elif arg == 4:
|
|
# postgres_port = sys.argv[arg]
|
|
pass
|
|
else:
|
|
print("Invalid option %s." % sys.argv[arg])
|
|
return 1
|
|
arg += 1
|
|
configure_logging()
|
|
|
|
if action == 'activate' and from_release >= '21.12':
|
|
LOG.info("%s invoked with from_release = %s to_release = %s "
|
|
"action = %s"
|
|
% (sys.argv[0], from_release, to_release, action))
|
|
enable_fluxcd_controllers(from_release)
|
|
|
|
|
|
@retry(retry_on_exception=lambda x: isinstance(x, exception.SysinvException),
|
|
stop_max_attempt_number=3)
|
|
@test_k8s_health
|
|
def enable_fluxcd_controllers(from_release):
|
|
"""Run fluxcd_controllers ansible playbook to enable fluxcd controllers
|
|
|
|
"""
|
|
|
|
playbooks_root = '/usr/share/ansible/stx-ansible/playbooks'
|
|
upgrade_script = 'upgrade-fluxcd-controllers.yml'
|
|
cmd = 'ansible-playbook {}/{} -e "upgrade_activate_from_release={}"'\
|
|
''.format(playbooks_root, upgrade_script, from_release)
|
|
|
|
try:
|
|
sub = subprocess.Popen(cmd, shell=True,
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
stdout, stderr = sub.communicate()
|
|
if sub.returncode != 0:
|
|
LOG.error('Command failed:\n %s\n. %s\n%s' % (
|
|
cmd, stdout.decode('utf-8'), stderr.decode('utf-8')))
|
|
raise Exception('Cannot install fluxcd controllers')
|
|
LOG.info('FluxCD controllers enabled. Output: %s' %
|
|
stdout.decode('utf-8'))
|
|
except Exception as e:
|
|
raise exception.SysinvException(
|
|
f"Error trying to enable fluxcd controllers via {cmd}, reason: {e}"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|