From 9794b19a201465f887d6421cbd8a5ee4da4dc462 Mon Sep 17 00:00:00 2001 From: Claude Ebaneck Date: Sun, 7 Jun 2020 23:27:52 +0200 Subject: [PATCH] salt: exclude PrometheusRule cleanup under certain conditions The Metalk8s python-kubernetes module list_objects method is bugged for already released versions as reported here:https://github.com/scality/metalk8s/issues/2592. The module has been patched in this PR: https://github.com/scality/metalk8s/issues/2592 but since we require the list_objects methods to cleanup old PrometheusRule, we need to find a way to skip cleanup for already released versions. Closes: #2606 --- buildchain/buildchain/salt_tree.py | 2 ++ .../prometheus-operator/post-downgrade.sls | 23 +++++++++++++++++++ .../prometheus-operator/post-upgrade.sls | 4 ++++ salt/metalk8s/orchestrate/downgrade/post.sls | 2 +- salt/metalk8s/orchestrate/upgrade/post.sls | 2 +- 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 salt/metalk8s/addons/prometheus-operator/post-downgrade.sls create mode 100644 salt/metalk8s/addons/prometheus-operator/post-upgrade.sls diff --git a/buildchain/buildchain/salt_tree.py b/buildchain/buildchain/salt_tree.py index 2716a2ec73..5f3f31336d 100644 --- a/buildchain/buildchain/salt_tree.py +++ b/buildchain/buildchain/salt_tree.py @@ -220,6 +220,8 @@ def _get_parts(self) -> Iterator[str]: Path('salt/metalk8s/addons/prometheus-adapter/deployed/init.sls'), Path('salt/metalk8s/addons/prometheus-operator/post-cleanup.sls'), + Path('salt/metalk8s/addons/prometheus-operator/post-downgrade.sls'), + Path('salt/metalk8s/addons/prometheus-operator/post-upgrade.sls'), Path('salt/metalk8s/addons/prometheus-operator/deployed/chart.sls'), Path('salt/metalk8s/addons/prometheus-operator/deployed/cleanup.sls'), Path('salt/metalk8s/addons/prometheus-operator/deployed/dashboards.sls'), diff --git a/salt/metalk8s/addons/prometheus-operator/post-downgrade.sls b/salt/metalk8s/addons/prometheus-operator/post-downgrade.sls new file mode 100644 index 0000000000..d0e735a60f --- /dev/null +++ b/salt/metalk8s/addons/prometheus-operator/post-downgrade.sls @@ -0,0 +1,23 @@ +# Include here all states that should be called after downgrading + +{%- set version = pillar.metalk8s.cluster_version %} + +{#- The Metalk8s python-kubernetes module for listing objects is bugged for + already released versions, The following release versions are affected: + 2.4.0, 2.4.1, 2.4.2, 2.4.3 and 2.5.0 + This issue as reported here: + https://github.com/scality/metalk8s/issues/2592 has been fixed. We need to + skip the PrometheusRule cleanup state for the versions mentioned above. #} + +{%- set affected_versions = ['2.4.0', '2.4.1', '2.4.2', '2.4.3', '2.5.0'] %} + +{%- if version not in affected_versions %} +include: + - .post-cleanup + +{%- else %} + +Skipping PrometheusRule cleanup for affected version {{ version }}: + test.succeed_without_changes: [] + +{%- endif %} diff --git a/salt/metalk8s/addons/prometheus-operator/post-upgrade.sls b/salt/metalk8s/addons/prometheus-operator/post-upgrade.sls new file mode 100644 index 0000000000..49af7d52ae --- /dev/null +++ b/salt/metalk8s/addons/prometheus-operator/post-upgrade.sls @@ -0,0 +1,4 @@ +# Include here all states that should be called after upgrading + +include: + - .post-cleanup diff --git a/salt/metalk8s/orchestrate/downgrade/post.sls b/salt/metalk8s/orchestrate/downgrade/post.sls index 42a7917319..8bb69ef3a6 100644 --- a/salt/metalk8s/orchestrate/downgrade/post.sls +++ b/salt/metalk8s/orchestrate/downgrade/post.sls @@ -1,4 +1,4 @@ # Include here all states that should be called after downgrading include: - - metalk8s.addons.prometheus-operator.post-cleanup + - metalk8s.addons.prometheus-operator.post-downgrade diff --git a/salt/metalk8s/orchestrate/upgrade/post.sls b/salt/metalk8s/orchestrate/upgrade/post.sls index 84e238acbf..f6c8b8d350 100644 --- a/salt/metalk8s/orchestrate/upgrade/post.sls +++ b/salt/metalk8s/orchestrate/upgrade/post.sls @@ -1,4 +1,4 @@ # Include here all states that should be called after upgrading include: - - metalk8s.addons.prometheus-operator.post-cleanup + - metalk8s.addons.prometheus-operator.post-upgrade