Skip to content

Commit

Permalink
feat(common): add a temporary failsafe to filter dragonfish and cobia…
Browse files Browse the repository at this point in the history
… SCALE users that forgot to follow instructions (#751)

**Description**
This is a **TEMPORARY** hotfix to ensure SCALE users that forgot setting
their `storageClass` to `SCALE-ZFS`, loose data on update to dragonfish.

This will be removed in the future, likely together with support for
SCALE storageClasses all-together.

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 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?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ 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 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._

---------

Co-authored-by: Stavros Kois <[email protected]>
Co-authored-by: Stavros kois <[email protected]>
  • Loading branch information
3 people authored Mar 16, 2024
1 parent a192b2a commit b090b8b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion library/common-test/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: ""
dependencies:
- name: common
repository: file://../common
version: ~20.1.0
version: ~20.2.0
deprecated: false
description: Helper chart to test different use cases of the common library
home: https://github.com/truecharts/apps/tree/master/charts/library/common-test
Expand Down
2 changes: 2 additions & 0 deletions library/common-test/tests/persistence/pvc_data_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ tests:
namespace: ix-namespace
ixChartContext:
storageClassName: ix-storage-class-releasename
ci:
storageClass: true
some_storage_class: "SCALE-ZFS"
persistence:
my-volume1:
Expand Down
16 changes: 2 additions & 14 deletions library/common-test/tests/persistence/validation_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,14 @@ tests:
- failedTemplate:
errorMessage: PVC - Expected [accessModes] entry to be one of [ReadWriteOnce, ReadOnlyMany, ReadWriteMany, ReadWriteOncePod], but got [not-an-access-mode]

- it: should fail without storageClassName in ixChartContext
set:
global:
namespace: ix-namespace
ixChartContext:
storageClassName: ""
persistence:
volume1:
enabled: true
type: pvc
asserts:
- failedTemplate:
errorMessage: PVC - Expected non-empty [global.ixChartContext.storageClassName]

- it: should fail without storageClassName in ixChartContext with SCALE-ZFS explicitly set
set:
global:
namespace: ix-namespace
ixChartContext:
storageClassName: ""
ci:
storageClass: true
persistence:
volume1:
enabled: true
Expand Down
22 changes: 2 additions & 20 deletions library/common-test/tests/volumeClaimTemplate/validation_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,14 @@ tests:
- failedTemplate:
errorMessage: Persistence - Expected [targetSelector] to be [dict], but got [string]

- it: should fail without storageClassName in ixChartContext
set:
global:
namespace: ix-namespace
ixChartContext:
storageClassName: ""
persistence:
volume1:
enabled: true
type: vct
workload:
main:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
asserts:
- failedTemplate:
errorMessage: PVC - Expected non-empty [global.ixChartContext.storageClassName]

- it: should fail without storageClassName in ixChartContext with SCALE-ZFS explicitly set
set:
global:
namespace: ix-namespace
ixChartContext:
storageClassName: ""
ci:
storageClass: true
persistence:
volume1:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ tests:
namespace: ix-namespace
ixChartContext:
storageClassName: ix-storage-class-releasename
ci:
storageClass: true
some_storage_class: "SCALE-ZFS"
persistence:
my-volume1:
Expand Down
2 changes: 1 addition & 1 deletion library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ maintainers:
name: common
sources: null
type: library
version: 20.1.5
version: 20.2.0
annotations:
artifacthub.io/category: "integration-delivery"
artifacthub.io/license: "BUSL-1.1"
Expand Down
18 changes: 14 additions & 4 deletions library/common/templates/lib/storage/_storageClassName.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@ objectData: The object data of the pvc
{{- $className = tpl $storageClass $rootCtx -}}
{{- end -}}

{{- else if $rootCtx.Values.global.ixChartContext -}}
{{- if not $rootCtx.Values.global.ixChartContext.storageClassName -}}
{{- fail (printf "%s - Expected non-empty [global.ixChartContext.storageClassName]" $caller) -}}
{{/* On Cobia -> Dragonfish update the ixChartContext should still be there, for existing apps so we can reference it */}}
{{- else if and $rootCtx.Values.global.ixChartContext $rootCtx.Values.global.ixChartContext.storageClassName -}}
{{- $scaleClassFound := false -}}
{{- with (lookup "v1" "StorageClass" "" $rootCtx.Values.global.ixChartContext.storageClassName) -}}
{{/* Check if there is an actually valid storageClass found */}}
{{- if .provisioner -}}
{{- $scaleClassFound = true -}}
{{- end -}}
{{- end -}}

{{- if or $scaleClassFound (and $rootCtx.Values.global.ixChartContext.ci $rootCtx.Values.global.ixChartContext.ci.storageClass) -}}
{{- $className = tpl $rootCtx.Values.global.ixChartContext.storageClassName $rootCtx -}}
{{- else if $rootCtx.Values.global.fallbackDefaults.storageClass -}}
{{- $className = tpl $rootCtx.Values.global.fallbackDefaults.storageClass $rootCtx -}}
{{- end -}}
{{- $className = tpl $rootCtx.Values.global.ixChartContext.storageClassName $rootCtx -}}

{{- else if $rootCtx.Values.global.fallbackDefaults.storageClass -}}

Expand Down

0 comments on commit b090b8b

Please sign in to comment.