mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
fix(monitoring): fail the render on a malformed platform spread policy
A globalAppTopologySpreadConstraints value that did not parse, or that held no topologySpreadConstraints list, gave every tier the chart default without any sign, so the platform's policy was silently not applied. The render now fails and names the parse error, as the chart already does for an empty logsStorages. The tests also pin that a selector the policy sets itself is kept as written. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
This commit is contained in:
1 parent
a4cb00e6dd
commit
0dbbb3b157
3 files changed
+91
-1
No files matched your search
@@ -4,7 +4,11 @@
|
|||||||
{{- $global := list -}}
|
{{- $global := list -}}
|
||||||
{{- with ($root.Values._cluster | default dict).scheduling -}}
|
{{- with ($root.Values._cluster | default dict).scheduling -}}
|
||||||
{{- with get . "globalAppTopologySpreadConstraints" -}}
|
{{- with get . "globalAppTopologySpreadConstraints" -}}
|
||||||
{{- $global = dig "topologySpreadConstraints" (list) (fromYaml .) -}}
|
{{- $parsed := fromYaml . -}}
|
||||||
|
{{- $global = dig "topologySpreadConstraints" (list) $parsed -}}
|
||||||
|
{{- if or (not (kindIs "slice" $global)) (not $global) -}}
|
||||||
|
{{- fail (trim (printf "monitoring: _cluster.scheduling.globalAppTopologySpreadConstraints must be YAML with a non-empty topologySpreadConstraints list. %s" (get $parsed "Error"))) -}}
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $constraints := list -}}
|
{{- $constraints := list -}}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
suite: monitoring refuses a malformed platform spread policy
|
||||||
|
templates:
|
||||||
|
- templates/vm/vmcluster.yaml
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: monitoring-system
|
||||||
|
namespace: tenant-root
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: fails on a platform policy that does not parse
|
||||||
|
template: templates/vm/vmcluster.yaml
|
||||||
|
set:
|
||||||
|
_cluster:
|
||||||
|
scheduling:
|
||||||
|
globalAppTopologySpreadConstraints: |
|
||||||
|
topologySpreadConstraints:
|
||||||
|
- maxSkew: 1
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorPattern: "globalAppTopologySpreadConstraints must be YAML with a non-empty topologySpreadConstraints list\\. error converting YAML to JSON"
|
||||||
|
|
||||||
|
- it: fails on a platform policy without a topologySpreadConstraints list
|
||||||
|
template: templates/vm/vmcluster.yaml
|
||||||
|
set:
|
||||||
|
_cluster:
|
||||||
|
scheduling:
|
||||||
|
globalAppTopologySpreadConstraints: |
|
||||||
|
- maxSkew: 1
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
whenUnsatisfiable: ScheduleAnyway
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorPattern: "globalAppTopologySpreadConstraints must be YAML with a non-empty topologySpreadConstraints list"
|
||||||
|
|
||||||
|
- it: fails on a platform policy with an empty topologySpreadConstraints list
|
||||||
|
template: templates/vm/vmcluster.yaml
|
||||||
|
set:
|
||||||
|
_cluster:
|
||||||
|
scheduling:
|
||||||
|
globalAppTopologySpreadConstraints: |
|
||||||
|
topologySpreadConstraints: []
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorMessage: "monitoring: _cluster.scheduling.globalAppTopologySpreadConstraints must be YAML with a non-empty topologySpreadConstraints list."
|
||||||
|
|
||||||
|
- it: fails on a platform policy whose topologySpreadConstraints is not a list
|
||||||
|
template: templates/vm/vmcluster.yaml
|
||||||
|
set:
|
||||||
|
_cluster:
|
||||||
|
scheduling:
|
||||||
|
globalAppTopologySpreadConstraints: |
|
||||||
|
topologySpreadConstraints:
|
||||||
|
maxSkew: 1
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
whenUnsatisfiable: ScheduleAnyway
|
||||||
|
asserts:
|
||||||
|
- failedTemplate:
|
||||||
|
errorMessage: "monitoring: _cluster.scheduling.globalAppTopologySpreadConstraints must be YAML with a non-empty topologySpreadConstraints list."
|
||||||
@@ -348,3 +348,30 @@ tests:
|
|||||||
matchLabels:
|
matchLabels:
|
||||||
app.kubernetes.io/name: vmstorage
|
app.kubernetes.io/name: vmstorage
|
||||||
app.kubernetes.io/instance: shortterm
|
app.kubernetes.io/instance: shortterm
|
||||||
|
|
||||||
|
- it: keeps a selector the platform policy sets itself
|
||||||
|
template: templates/vm/vmcluster.yaml
|
||||||
|
set:
|
||||||
|
_cluster:
|
||||||
|
scheduling:
|
||||||
|
globalAppTopologySpreadConstraints: |
|
||||||
|
topologySpreadConstraints:
|
||||||
|
- maxSkew: 1
|
||||||
|
topologyKey: topology.kubernetes.io/zone
|
||||||
|
whenUnsatisfiable: ScheduleAnyway
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
example.org/spread: all
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: shortterm
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.vmstorage.topologySpreadConstraints
|
||||||
|
value:
|
||||||
|
- maxSkew: 1
|
||||||
|
topologyKey: topology.kubernetes.io/zone
|
||||||
|
whenUnsatisfiable: ScheduleAnyway
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
example.org/spread: all
|
||||||
Reference in new issue
Block a user