Skip to content

Commit

Permalink
salt: exclude PrometheusRule cleanup under certain conditions
Browse files Browse the repository at this point in the history
The Metalk8s python-kubernetes module list_objects method
is bugged for already released versions.

The module has been patched in this PR: #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
  • Loading branch information
Ebaneck committed Jun 8, 2020
1 parent d836f44 commit 2e8ca7b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
23 changes: 23 additions & 0 deletions salt/metalk8s/addons/prometheus-operator/post-downgrade.sls
Original file line number Diff line number Diff line change
@@ -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 %}
4 changes: 4 additions & 0 deletions salt/metalk8s/addons/prometheus-operator/post-upgrade.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Include here all states that should be called after upgrading

include:
- .post-cleanup
2 changes: 1 addition & 1 deletion salt/metalk8s/orchestrate/downgrade/post.sls
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion salt/metalk8s/orchestrate/upgrade/post.sls
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2e8ca7b

Please sign in to comment.