mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 03:49:15 -03:00
fix: correct cnpg naming behavior and seperate default vctAccessmodes from accessmodes (#726)
**Description** Current recovery behavior doesn't target the correct backup serverName if the serverName isn't explicitly set. Even when set it still sometimes misbehaves so we're going to also set the externCluster-name accordingly as a fail-safe **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [x] ⚠️ 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:** Technically breaking, as we're changing the default behavior of VCT. However, we don't use VCT's a lot **✔️ 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._
This commit is contained in:
@@ -3,7 +3,7 @@ appVersion: ""
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../common
|
||||
version: ~18.2.0
|
||||
version: ~19.0.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
|
||||
|
||||
@@ -54,18 +54,7 @@ tests:
|
||||
path: spec
|
||||
content:
|
||||
backup:
|
||||
target: primary
|
||||
retentionPolicy: 10d
|
||||
barmanObjectStore:
|
||||
wal:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
data:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
jobs: 2
|
||||
endpointURL: null
|
||||
destinationPath: some-path
|
||||
azureCredentials:
|
||||
connectionString:
|
||||
key: CONNECTION_STRING
|
||||
@@ -79,6 +68,18 @@ tests:
|
||||
storageSasToken:
|
||||
key: STORAGE_SAS_TOKEN
|
||||
name: test-release-name-common-test-cnpg-my-pg-provider-backup-azure-creds
|
||||
data:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
jobs: 2
|
||||
destinationPath: some-path
|
||||
endpointURL: null
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
wal:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
retentionPolicy: 10d
|
||||
target: primary
|
||||
|
||||
- it: should generate correct spec with backups (google)
|
||||
set:
|
||||
@@ -126,23 +127,24 @@ tests:
|
||||
path: spec
|
||||
content:
|
||||
backup:
|
||||
target: primary
|
||||
retentionPolicy: 10d
|
||||
barmanObjectStore:
|
||||
wal:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
data:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
jobs: 2
|
||||
endpointURL: null
|
||||
destinationPath: some-path
|
||||
endpointURL: null
|
||||
googleCredentials:
|
||||
gkeEnvironment: false
|
||||
applicationCredentials:
|
||||
key: APPLICATION_CREDENTIALS
|
||||
name: test-release-name-common-test-cnpg-my-pg-provider-backup-google-creds
|
||||
gkeEnvironment: false
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
wal:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
retentionPolicy: 10d
|
||||
target: primary
|
||||
|
||||
- it: should generate correct spec with backups (s3)
|
||||
set:
|
||||
@@ -193,18 +195,13 @@ tests:
|
||||
path: spec
|
||||
content:
|
||||
backup:
|
||||
target: primary
|
||||
retentionPolicy: 10d
|
||||
barmanObjectStore:
|
||||
wal:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
data:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
jobs: 2
|
||||
endpointURL: some-url
|
||||
destinationPath: some-path
|
||||
endpointURL: some-url
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
key: ACCESS_KEY_ID
|
||||
@@ -212,6 +209,12 @@ tests:
|
||||
secretAccessKey:
|
||||
key: ACCESS_SECRET_KEY
|
||||
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
wal:
|
||||
compression: gzip
|
||||
encryption: AES256
|
||||
retentionPolicy: 10d
|
||||
target: primary
|
||||
|
||||
- it: should generate correct spec with empty target
|
||||
set:
|
||||
|
||||
@@ -122,7 +122,7 @@ tests:
|
||||
name: test-release-name-common-test-cnpg-my-pg-user
|
||||
owner: test-user
|
||||
database: test-db
|
||||
source: objectStoreRecoveryCluster
|
||||
source: test-release-name-common-test-cnpg-my-pg
|
||||
recoveryTarget:
|
||||
targetTime: "2021-01-01T00:00:00Z"
|
||||
- documentIndex: *clusterDoc
|
||||
@@ -130,8 +130,9 @@ tests:
|
||||
path: spec
|
||||
content:
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
- name: test-release-name-common-test-cnpg-my-pg
|
||||
barmanObjectStore:
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
destinationPath: gs://some-bucket/some-path
|
||||
endpointURL: null
|
||||
googleCredentials:
|
||||
@@ -192,7 +193,7 @@ tests:
|
||||
name: test-release-name-common-test-cnpg-my-pg-user
|
||||
owner: test-user
|
||||
database: test-db
|
||||
source: objectStoreRecoveryCluster
|
||||
source: test-release-name-common-test-cnpg-my-pg
|
||||
recoveryTarget:
|
||||
targetTime: "2021-01-01T00:00:00Z"
|
||||
- documentIndex: *clusterDoc
|
||||
@@ -200,8 +201,9 @@ tests:
|
||||
path: spec
|
||||
content:
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
- name: test-release-name-common-test-cnpg-my-pg
|
||||
barmanObjectStore:
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
destinationPath: gs://some-bucket
|
||||
endpointURL: null
|
||||
googleCredentials:
|
||||
@@ -264,14 +266,15 @@ tests:
|
||||
name: test-release-name-common-test-cnpg-my-pg-user
|
||||
owner: test-user
|
||||
database: test-db
|
||||
source: objectStoreRecoveryCluster
|
||||
source: test-release-name-common-test-cnpg-my-pg
|
||||
- documentIndex: *clusterDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
- name: test-release-name-common-test-cnpg-my-pg
|
||||
barmanObjectStore:
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
destinationPath: s3://some-bucket/some-path
|
||||
endpointURL: https://s3.some-region.amazonaws.com
|
||||
s3Credentials:
|
||||
@@ -335,14 +338,15 @@ tests:
|
||||
name: test-release-name-common-test-cnpg-my-pg-user
|
||||
owner: test-user
|
||||
database: test-db
|
||||
source: objectStoreRecoveryCluster
|
||||
source: test-release-name-common-test-cnpg-my-pg
|
||||
- documentIndex: *clusterDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
- name: test-release-name-common-test-cnpg-my-pg
|
||||
barmanObjectStore:
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
destinationPath: s3://some-bucket
|
||||
endpointURL: some-endpoint-url
|
||||
s3Credentials:
|
||||
@@ -409,14 +413,15 @@ tests:
|
||||
name: test-release-name-common-test-cnpg-my-pg-user
|
||||
owner: test-user
|
||||
database: test-db
|
||||
source: objectStoreRecoveryCluster
|
||||
source: test-release-name-common-test-cnpg-my-pg
|
||||
- documentIndex: *clusterDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
- name: test-release-name-common-test-cnpg-my-pg
|
||||
barmanObjectStore:
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
destinationPath: https://some-storage-account.some-service-name.core.windows.net/some-container-name/some-path
|
||||
endpointURL: null
|
||||
azureCredentials:
|
||||
@@ -486,14 +491,15 @@ tests:
|
||||
name: test-release-name-common-test-cnpg-my-pg-user
|
||||
owner: test-user
|
||||
database: test-db
|
||||
source: objectStoreRecoveryCluster
|
||||
source: test-release-name-common-test-cnpg-my-pg
|
||||
- documentIndex: *clusterDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
- name: test-release-name-common-test-cnpg-my-pg
|
||||
barmanObjectStore:
|
||||
serverName: test-release-name-common-test-cnpg-my-pg
|
||||
destinationPath: https://some-storage-account.some-service-name.core.windows.net/some-container-name
|
||||
endpointURL: null
|
||||
azureCredentials:
|
||||
|
||||
@@ -15,7 +15,7 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 18.2.1
|
||||
version: 19.0.0
|
||||
annotations:
|
||||
artifacthub.io/category: "integration-delivery"
|
||||
artifacthub.io/license: "BUSL-1.1"
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
{{- $primaryUpdateStrategy := "unsupervised" -}}
|
||||
{{- $primaryUpdateMethod := "switchover" -}}
|
||||
{{- $logLevel := "info" -}}
|
||||
{{- $accessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
|
||||
{{- $walAccessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
|
||||
|
||||
{{/* Make sure keys exist before try to access any sub keys */}}
|
||||
{{- if not (hasKey $objectData "cluster") -}}
|
||||
@@ -122,6 +124,14 @@
|
||||
{{- $walSize = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $objectData.cluster.storage.accessModes -}}
|
||||
{{- $accessModes = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $objectData.cluster.walStorage.accessModes -}}
|
||||
{{- $walAccessModes = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.util.verifycrd" (dict "rootCtx" $rootCtx "crd" "clusters.postgresql.cnpg.io" "missing" "CloudNative-PG") }}
|
||||
|
||||
---
|
||||
@@ -174,10 +184,14 @@ spec:
|
||||
storage:
|
||||
pvcTemplate:
|
||||
{{- $_ := set $objectData.cluster.storage "size" $size -}}
|
||||
{{- $_ := set $objectData.cluster.storage "accessModes" $accessModes -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.storage.pvc.spec" (dict "rootCtx" $rootCtx "objectData" $objectData.cluster.storage) | trim | nindent 6 }}
|
||||
walStorage:
|
||||
pvcTemplate:
|
||||
{{- $_ := set $objectData.cluster.walStorage "size" $walSize -}}
|
||||
{{- $_ := set $objectData.cluster.storage "accessModes" $walAccessModes -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.storage.pvc.spec" (dict "rootCtx" $rootCtx "objectData" $objectData.cluster.walStorage) | trim | nindent 6 }}
|
||||
{{- if $enableMonitoring }}
|
||||
monitoring:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{{- $serverName = $objectData.recovery.serverName -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.recovery.revision -}}
|
||||
{{- $serverName = printf "%s-%s" $serverName $objectData.recovery.revision -}}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.recovery.revision -}}
|
||||
{{- end -}}
|
||||
{{- else if eq $type "backup" -}}
|
||||
{{- $endpointURL = $objectData.backups.endpointURL -}}
|
||||
@@ -29,7 +29,7 @@
|
||||
{{- $serverName = $objectData.backups.serverName -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.backups.revision -}}
|
||||
{{- $serverName = printf "%s-%s" $serverName $objectData.backups.revision -}}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.backups.revision -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if not $destinationPath -}}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
{{- $serverName = $objectData.recovery.serverName -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.recovery.revision -}}
|
||||
{{- $serverName = printf "%s-%s" $serverName $objectData.recovery.revision -}}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.recovery.revision -}}
|
||||
{{- end -}}
|
||||
{{- else if eq $type "backup" -}}
|
||||
{{- $endpointURL = $objectData.backups.endpointURL -}}
|
||||
@@ -34,7 +34,7 @@
|
||||
{{- $serverName = $objectData.backups.serverName -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.backups.revision -}}
|
||||
{{- $serverName = printf "%s-%s" $serverName $objectData.backups.revision -}}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.backups.revision -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if not $destinationPath -}}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{{- $serverName = $objectData.recovery.serverName -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.recovery.revision -}}
|
||||
{{- $serverName = printf "%s-%s" $serverName $objectData.recovery.revision -}}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.recovery.revision -}}
|
||||
{{- end -}}
|
||||
{{- else if eq $type "backup" -}}
|
||||
{{- $endpointURL = $objectData.backups.endpointURL -}}
|
||||
@@ -29,7 +29,7 @@
|
||||
{{- $serverName = $objectData.backups.serverName -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.backups.revision -}}
|
||||
{{- $serverName = printf "%s-%s" $serverName $objectData.backups.revision -}}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.backups.revision -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if not $destinationPath -}}
|
||||
|
||||
@@ -10,7 +10,11 @@ recovery:
|
||||
backup:
|
||||
name: {{ $objectData.recovery.backupName }}
|
||||
{{- else if eq $objectData.recovery.method "object_store" }}
|
||||
source: objectStoreRecoveryCluster
|
||||
{{- $serverName := $objectData.recovery.serverName | default $objectData.clusterName }}
|
||||
{{- if $objectData.recovery.revision }}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.recovery.revision }}
|
||||
{{- end }}
|
||||
source: {{ $serverName }}
|
||||
{{- end -}}
|
||||
{{- if $objectData.recovery.pitrTarget -}}
|
||||
{{- with $objectData.recovery.pitrTarget.time }}
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
|
||||
{{- if eq $objectData.recovery.method "object_store" }}
|
||||
externalClusters:
|
||||
- name: objectStoreRecoveryCluster
|
||||
{{- $serverName := $objectData.recovery.serverName | default $objectData.clusterName }}
|
||||
{{- if $objectData.recovery.revision }}
|
||||
{{- $serverName = printf "%s-r%s" $serverName $objectData.recovery.revision }}
|
||||
{{- end }}
|
||||
- name: {{ $serverName }}
|
||||
barmanObjectStore:
|
||||
|
||||
{{- $provider := $objectData.recovery.provider -}}
|
||||
|
||||
@@ -102,7 +102,26 @@
|
||||
{{- if not (mustRegexMatch $regexPolicy $objectData.backups.retentionPolicy) -}}
|
||||
{{- fail (printf "CNPG Backup - Expected [backups.retentionPolicy] to match regex [%s], got [%s]" $regexPolicy $objectData.backups.retentionPolicy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq $objectData.mode "recovery" -}}
|
||||
{{- $serverNameBackup := $objectData.backups.serverName | default $objectData.clusterName -}}
|
||||
{{- $serverNameRecovery := $objectData.recovery.serverName | default $objectData.clusterName -}}
|
||||
{{- if $objectData.backups.revision -}}
|
||||
{{- $serverNameBackup = printf "%s-r%s" $serverNameBackup $objectData.backups.revision -}}
|
||||
{{- end -}}
|
||||
{{- if $objectData.recovery.revision -}}
|
||||
{{- $serverNameRecovery = printf "%s-r%s" $serverNameRecovery $objectData.recovery.revision -}}
|
||||
{{- end -}}
|
||||
{{- if eq $serverNameBackup $serverNameRecovery -}}
|
||||
{{- if $objectData.backups.serverName -}}
|
||||
{{- fail (printf "CNPG Backup/Recovery - [backups.serverName] and [backups.revision] cannot match [recovery.serverName] and [recovery.revision] when in recovery mode and backup is enabled, for cnpg cluster [%s]" $objectData.clusterName) -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "CNPG Backup/Recovery - [backups.revision] cannot match [recovery.revision] when in recovery mode and backup is enabled, for cnpg cluster [%s]" $objectData.clusterName) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -43,8 +43,15 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- with $vct.size -}}
|
||||
{{- $vctSize = tpl . $rootCtx -}}
|
||||
{{- end }}
|
||||
{{- $_ := set $vct "size" $vctSize }}
|
||||
|
||||
{{- $vctAccessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
|
||||
{{- with $vct.accessModes -}}
|
||||
{{- $vctAccessModes = $vct.accessModes -}}
|
||||
{{- end }}
|
||||
{{- $_ := set $vct "accessModes" $vctAccessModes }}
|
||||
- metadata:
|
||||
name: {{ include "tc.v1.common.lib.storage.pvc.name" (dict "rootCtx" $rootCtx "objectName" $vct.shortName "objectData" $vctValues) }}
|
||||
name: {{ include "tc.v1.common.lib.storage.pvc.name" (dict "rootCtx" $rootCtx "objectName" $vct.shortName "objectData" $vct) }}
|
||||
{{- $labels := $vct.labels | default dict -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
@@ -56,7 +63,7 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- . | nindent 6 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "tc.v1.common.lib.storage.pvc.spec" (dict "rootCtx" $rootCtx "objectData" $vctValues) | trim | nindent 4 }}
|
||||
{{- include "tc.v1.common.lib.storage.pvc.spec" (dict "rootCtx" $rootCtx "objectData" $vct) | trim | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -53,9 +53,12 @@ fallbackDefaults:
|
||||
pvcSize: 100Gi
|
||||
# -- Default VCT Size
|
||||
vctSize: 100Gi
|
||||
# -- Default PVC/VCT Access Modes
|
||||
# -- Default PVC Access Modes
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
# -- Default VCT Access Modes
|
||||
vctAccessModes:
|
||||
- ReadWriteOnce
|
||||
# -- Default probe timeouts
|
||||
probeTimeouts:
|
||||
liveness:
|
||||
|
||||
Reference in New Issue
Block a user