Allow FluxCD to be upgraded from N to N+1

With the introduction of [1] FluxCD needs to be updated.
Enhancing upgrade-fluxcd-controllers.yml to allow FluxCD
upgrades is done part of [2].

When upgrading from 22.06 we need the flux manifest to be reapplied
(and pods will be restarted part of the new deployment).
This is designed future proof, upgrading from generic N to N+1 would
work.

Tests on AIO-SX:
Using the load for [2], emulated upgrades call.
PASS: Observed no pod restart when emulating upgrade from 21.12 as there
should be no pod in the first place when coming from 21.12
/etc/upgrade.d/62-enable-fluxcd-controllers.py 21.12 22.12 activate
PASS: Observed pods restart picking the new manifests whe emulating
upgrade from 22.06
/etc/upgrade.d/62-enable-fluxcd-controllers.py 22.06 22.12 activate

[1]: https://review.opendev.org/c/starlingx/ansible-playbooks/+/866820
[2]: https://review.opendev.org/c/starlingx/ansible-playbooks/+/867032
Depends-On: https://review.opendev.org/c/starlingx/ansible-playbooks/+/867032
Partial-Bug: 1999032
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Change-Id: I14c7802ef405a2ea4665b2a2b64e5daaf0eef009
This commit is contained in:
Dan Voiculeasa 2022-12-08 18:56:40 +02:00
parent d7dede71ce
commit 55b21d7438
1 changed files with 5 additions and 4 deletions

View File

@ -31,21 +31,22 @@ def main():
arg += 1
log.configure()
if action == 'activate' and from_release == '21.12':
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()
enable_fluxcd_controllers(from_release)
def enable_fluxcd_controllers():
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 {}/{}'.format(playbooks_root, upgrade_script)
cmd = 'ansible-playbook {}/{} -e "upgrade_activate_from_release={}"'\
''.format(playbooks_root, upgrade_script, from_release)
sub = subprocess.Popen(cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = sub.communicate()