mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 05:19:17 -03:00
fix(stop-all): skip creating poolers when stop-all or hibernate is enabled (#642)
This commit is contained in:
@@ -60,7 +60,6 @@ tests:
|
||||
annotation3: annotation3
|
||||
g_annotation1: global_annotation1
|
||||
g_annotation2: global_annotation2
|
||||
cnpg.io/hibernation: "off"
|
||||
some-annotation: some-value
|
||||
- documentIndex: *poolerDoc
|
||||
matchRegex:
|
||||
|
||||
@@ -18,7 +18,10 @@ tests:
|
||||
instances: 2
|
||||
hibernate: true
|
||||
asserts:
|
||||
- documentIndex: &clusterDoc 1
|
||||
# Cluster and 2 Secrets
|
||||
- hasDocuments:
|
||||
count: &docCount 3
|
||||
- documentIndex: &clusterDoc 0
|
||||
isKind:
|
||||
of: Cluster
|
||||
- documentIndex: *clusterDoc
|
||||
@@ -29,17 +32,6 @@ tests:
|
||||
path: metadata.annotations
|
||||
content:
|
||||
cnpg.io/hibernation: "on"
|
||||
- documentIndex: &poolerDoc 0
|
||||
isKind:
|
||||
of: Pooler
|
||||
- documentIndex: *poolerDoc
|
||||
isAPIVersion:
|
||||
of: postgresql.cnpg.io/v1
|
||||
- documentIndex: *poolerDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
instances: 2
|
||||
|
||||
- it: should set hibernate and 0 instances on stopAll
|
||||
set:
|
||||
@@ -56,6 +48,8 @@ tests:
|
||||
hibernate: false
|
||||
instances: 2
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: *docCount
|
||||
- documentIndex: *clusterDoc
|
||||
isKind:
|
||||
of: Cluster
|
||||
@@ -67,17 +61,6 @@ tests:
|
||||
path: metadata.annotations
|
||||
content:
|
||||
cnpg.io/hibernation: "on"
|
||||
- documentIndex: *poolerDoc
|
||||
isKind:
|
||||
of: Pooler
|
||||
- documentIndex: *poolerDoc
|
||||
isAPIVersion:
|
||||
of: postgresql.cnpg.io/v1
|
||||
- documentIndex: *poolerDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
instances: 2
|
||||
|
||||
- it: should set hibernate and 0 instances on ixChartContext - isStopped
|
||||
set:
|
||||
@@ -97,6 +80,8 @@ tests:
|
||||
hibernate: false
|
||||
instances: 2
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: *docCount
|
||||
- documentIndex: *clusterDoc
|
||||
isKind:
|
||||
of: Cluster
|
||||
@@ -108,17 +93,6 @@ tests:
|
||||
path: metadata.annotations
|
||||
content:
|
||||
cnpg.io/hibernation: "on"
|
||||
- documentIndex: *poolerDoc
|
||||
isKind:
|
||||
of: Pooler
|
||||
- documentIndex: *poolerDoc
|
||||
isAPIVersion:
|
||||
of: postgresql.cnpg.io/v1
|
||||
- documentIndex: *poolerDoc
|
||||
isSubset:
|
||||
path: spec
|
||||
content:
|
||||
instances: 2
|
||||
|
||||
- it: should not set hibernate and 0 instances on ixChartContext - isStopped
|
||||
set:
|
||||
@@ -138,7 +112,10 @@ tests:
|
||||
hibernate: false
|
||||
instances: 2
|
||||
asserts:
|
||||
- documentIndex: *clusterDoc
|
||||
# Cluster, Pooler and 2 Secrets
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &clusterDoc 1
|
||||
isKind:
|
||||
of: Cluster
|
||||
- documentIndex: *clusterDoc
|
||||
@@ -149,7 +126,7 @@ tests:
|
||||
path: metadata.annotations
|
||||
content:
|
||||
cnpg.io/hibernation: "off"
|
||||
- documentIndex: *poolerDoc
|
||||
- documentIndex: &poolerDoc 0
|
||||
isKind:
|
||||
of: Pooler
|
||||
- documentIndex: *poolerDoc
|
||||
|
||||
@@ -15,4 +15,4 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 16.2.12
|
||||
version: 16.2.13
|
||||
|
||||
@@ -16,12 +16,7 @@
|
||||
{{- $poolerAnnotations := $objectData.pooler.annotations | default dict -}}
|
||||
{{- $poolerAnnotations = mustMerge $poolerAnnotations $objAnnotations -}}
|
||||
|
||||
{{/* Stop All */}}
|
||||
{{- $instances := $objectData.pooler.instances | default 2 -}}
|
||||
{{- $hibernation := "off" -}}
|
||||
{{- if or $objectData.hibernate (include "tc.v1.common.lib.util.stopAll" $rootCtx) -}}
|
||||
{{- $hibernation = "on" -}}
|
||||
{{- end }}
|
||||
{{- $instances := $objectData.pooler.instances | default 2 }}
|
||||
---
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Pooler
|
||||
@@ -36,7 +31,6 @@ metadata:
|
||||
{{- end }}
|
||||
annotations:
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
cnpg.io/hibernation: {{ $hibernation | quote }}
|
||||
{{- $annotations := (mustMerge $poolerAnnotations (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
{{- . | nindent 4 }}
|
||||
|
||||
@@ -16,26 +16,29 @@
|
||||
{{- $_ := set $objectData.pooler "type" "rw" -}}
|
||||
{{/* Validate Pooler */}}
|
||||
{{- include "tc.v1.common.lib.cnpg.pooler.validation" (dict "objectData" $objectData) -}}
|
||||
{{/* Create the RW Pooler object */}}
|
||||
{{- include "tc.v1.common.class.cnpg.pooler" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
|
||||
{{- if $monitoring -}} {{/* TODO: Unit tests for Pooler Metrics */}}
|
||||
{{- $poolerMetrics := include "tc.v1.common.lib.cnpg.metrics.pooler" (dict "poolerName" (printf "%s-rw" $objectData.name)) | fromYaml -}}
|
||||
{{- $_ := set $.Values.metrics (printf "cnpg-%s-rw" $objectData.shortName) $poolerMetrics -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $objectData.pooler.createRO -}}
|
||||
{{- $_ := set $objectData.pooler "type" "ro" -}}
|
||||
|
||||
{{/* Validate Pooler */}}
|
||||
{{- include "tc.v1.common.lib.cnpg.pooler.validation" (dict "objectData" $objectData) -}}
|
||||
{{/* Create the RO Pooler object */}}
|
||||
{{/* Stop All */}}
|
||||
{{- if not (or $objectData.hibernate (include "tc.v1.common.lib.util.stopAll" $rootCtx)) -}}
|
||||
{{/* Create the RW Pooler object */}}
|
||||
{{- include "tc.v1.common.class.cnpg.pooler" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
|
||||
{{- if $monitoring -}} {{/* TODO: Unit tests for Pooler Metrics */}}
|
||||
{{- $poolerMetrics := include "tc.v1.common.lib.cnpg.metrics.pooler" (dict "poolerName" (printf "%s-rw" $objectData.name)) | fromYaml -}}
|
||||
{{- $_ := set $.Values.metrics (printf "cnpg-%s-ro" $objectData.shortName) $poolerMetrics -}}
|
||||
{{- $_ := set $.Values.metrics (printf "cnpg-%s-rw" $objectData.shortName) $poolerMetrics -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $objectData.pooler.createRO -}}
|
||||
{{- $_ := set $objectData.pooler "type" "ro" -}}
|
||||
|
||||
{{/* Validate Pooler */}}
|
||||
{{- include "tc.v1.common.lib.cnpg.pooler.validation" (dict "objectData" $objectData) -}}
|
||||
{{/* Create the RO Pooler object */}}
|
||||
{{- include "tc.v1.common.class.cnpg.pooler" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
||||
|
||||
{{- if $monitoring -}} {{/* TODO: Unit tests for Pooler Metrics */}}
|
||||
{{- $poolerMetrics := include "tc.v1.common.lib.cnpg.metrics.pooler" (dict "poolerName" (printf "%s-rw" $objectData.name)) | fromYaml -}}
|
||||
{{- $_ := set $.Values.metrics (printf "cnpg-%s-ro" $objectData.shortName) $poolerMetrics -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user