From ed4a40bb34b0b2440b75f99e280bb79116c5f992 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sat, 27 May 2023 15:00:19 +0200 Subject: [PATCH] fix(common): reenable manifest manager and add deletion logic (#437) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** This PR reenables manifest manager by default and creates additional toggles for both install and checks. It also, more importantly, adds an option to delete resources created using manifestmanager, a prerequisite for moving to building our own operator helm-charts **โš™๏ธ Type of change** - [x] โš™๏ธ Feature/App addition - [x] ๐Ÿช› Bugfix - [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] ๐Ÿ”ƒ Refactor of current code **๐Ÿงช How Has This Been Tested?** **๐Ÿ“ƒ Notes:** **โœ”๏ธ Checklist:** - [ ] โš–๏ธ My code follows the style guidelines of this project - [ ] ๐Ÿ‘€ I have performed a self-review of my own code - [ ] #๏ธโƒฃ I have commented my code, particularly in hard-to-understand areas - [ ] ๐Ÿ“„ I have made corresponding changes to the documentation - [ ] โš ๏ธ My changes generate no new warnings - [ ] ๐Ÿงช I have added tests to this description that prove my fix is effective or that my feature works - [ ] โฌ†๏ธ I increased versions for any altered app according to semantic versioning **โž• App addition** If this PR is an app addition please make sure you have done the following. - [ ] ๐Ÿชž I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] ๐Ÿ–ผ๏ธ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- .../common-test/ci/register-operator-values.yaml | 7 +++++++ library/common/Chart.yaml | 2 +- .../common/templates/lib/util/_manifest_manager.tpl | 13 +++++++++++++ library/common/values.yaml | 5 ++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/library/common-test/ci/register-operator-values.yaml b/library/common-test/ci/register-operator-values.yaml index 035f0bb8..c2723315 100644 --- a/library/common-test/ci/register-operator-values.yaml +++ b/library/common-test/ci/register-operator-values.yaml @@ -42,3 +42,10 @@ args: operator: register: true + +manifestManager: + enabled: false + staging: false + install: false + check: false + delete: false diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 16b37168..70226774 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.10.2 +version: 12.10.3 diff --git a/library/common/templates/lib/util/_manifest_manager.tpl b/library/common/templates/lib/util/_manifest_manager.tpl index 08df1ae9..eb6522d7 100644 --- a/library/common/templates/lib/util/_manifest_manager.tpl +++ b/library/common/templates/lib/util/_manifest_manager.tpl @@ -83,11 +83,14 @@ spec: {{- $handleErr = "&& echo 'Job failed...'" -}} {{- end }} + {{- if .Values.manifestManager.install }} kubectl apply --server-side --force-conflicts --grace-period 30 --v=4 -k https://github.com/truecharts/manifests/{{ $branch }} || \ kubectl apply --server-side --force-conflicts --grace-period 30 -k https://github.com/truecharts/manifests/{{ $branch }} {{ $handleErr }} echo "Install finished..." + {{- end }} + {{- if .Values.manifestManager.check }} echo "Starting waits and checks..." kubectl delete pod --field-selector=status.phase==Succeeded -n cnpg-system || echo "Delete of Completed Pods failed..." kubectl delete pod --field-selector=status.phase==Failed -n cnpg-system || echo "Delete of Failed Pods failed..." @@ -102,6 +105,16 @@ spec: kubectl wait --namespace cert-manager --for=condition=ready pod --selector=app.kubernetes.io/instance=cert-manager --timeout=60s || echo "cert-manager wait failed..." cmctl check api --wait=1m || echo "cmctl wait failed..." + + echo "Checks finished..." + {{- end }} + + {{- if .Values.manifestManager.delete -}} + echo "Deleting manifests..." + kubectl delete --grace-period 30 --v=4 -k https://github.com/truecharts/manifests/delete && kubectl delete --grace-period 30 --v=4 -k https://github.com/truecharts/manifests/delete || \ + kubectl delete --force --grace-period 30 -k https://github.com/truecharts/manifests/delete {{ $handleErr }} + echo "Deletion finished..." + {{- end }} EOF volumeMounts: - name: {{ $fullName }}-manifests-temp diff --git a/library/common/values.yaml b/library/common/values.yaml index b266f8c4..1daf16ac 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -312,8 +312,11 @@ APPURL: "" # -- Used to inject our own operator manifests into SCALE manifestManager: - enabled: false + enabled: true staging: false + install: true + check: true + delete: false gluetunImage: repository: tccr.io/truecharts/gluetun