Skip to content

Commit 00daba2

Browse files
committed
HPCC-33922 Extend excludeKeys mechanism to support regex
Change and extend excludeKeys to support regex patterns. e.g. "~.*::replicas". A "~" prefix denoes component is a regex. Also: 1) remove superfluous from eclagent.yaml 2) fix globalExcludeSectionRegexList to correctly exclude *-job.yaml sections. 3) Exclude all replicas via globalExcludeList with "~.*::replicas" Signed-off-by: Jake Smith <[email protected]>
1 parent a25c976 commit 00daba2

File tree

4 files changed

+53
-29
lines changed

4 files changed

+53
-29
lines changed

helm/hpcc/templates/_helpers.tpl

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,9 @@ This means pods only auto-restart if the non-excluded parts change.
25302530
25312531
Pass in root, me, configMapHelper, component, excludeSectionRegexList and excludeKeyList
25322532
excludeSectionRegexList is a list of regexp's that filter out top-level sections, e.g. [".*spec.yaml$" ]
2533-
excludeKeyList is a list of key values to exclude from each section, e.g. [ "global", "esp.services" "esp.queues"]
2533+
excludeKeyList is a list of key values with optional regex support (denoted by leading '~') to exclude from
2534+
each section, each component of the key must be seperated by "::" due to the regex support.
2535+
e.g. [ "global", "esp::services" "esp::queues", "~.*::loggging"]
25342536
25352537
The configMap data section is reconstructed based on filtering out matches.
25362538
@@ -2543,32 +2545,53 @@ e.g. a cache of secrets, with an auto reload/refresh mechanism, or 'replicas'.
25432545
{{- $excludeSectionRegexList := .excludeSectionRegexList -}}
25442546
{{- $excludeKeyList := .excludeKeyList -}}
25452547
{{- range $configElementName, $configElementDict := $config.data -}}
2546-
{{- $_ := set $configCtx "excludeSection" false -}}
2547-
{{- range $regex := $excludeSectionRegexList -}}
2548-
{{- if (regexMatch $regex $configElementName) -}}
2549-
{{- $_ := set $configCtx "excludeSection" true -}}
2550-
{{- end -}}
2548+
{{- $_ := set $configCtx "excludeSection" false -}}
2549+
{{- range $regex := $excludeSectionRegexList -}}
2550+
{{- if (regexMatch $regex $configElementName) -}}
2551+
{{- $_ := set $configCtx "excludeSection" true -}}
25512552
{{- end -}}
2552-
{{- if not $configCtx.excludeSection -}}
2553-
{{- $configDictCtx := dict -}}
2554-
{{- range $key := $excludeKeyList -}}
2555-
{{- $_ := set $configDictCtx "keyDictStr" (regexReplaceAll "(.*)\\..*$" $key "${1}") -}}
2556-
{{- if eq $configDictCtx.keyDictStr $key -}}{{/* single component key, e.g. "global"*/}}
2557-
{{- $configElementDict := (unset $configElementDict $key) -}}
2558-
{{- else -}}{{/* scopes component key, e.g. "eclccserver.queue"*/}}
2559-
{{- $_ := set $configDictCtx "keyKeyStr" (regexReplaceAll ".*\\.(.*)$" $key "${1}") -}}
2560-
{{- $subDict := get $configElementDict $configDictCtx.keyDictStr -}}
2561-
{{- if $subDict -}}
2562-
{{- $_ := set $configElementDict $configDictCtx.keyDictStr (unset $subDict $configDictCtx.keyKeyStr) -}}
2553+
{{- end -}}
2554+
{{- if not $configCtx.excludeSection -}}
2555+
{{- $configDictCtx := dict -}}
2556+
{{- range $key := $excludeKeyList -}}
2557+
{{- $keyParts := splitList "::" $key -}}
2558+
{{- $outerRaw := index $keyParts 0 -}}
2559+
{{- $outerIsWild := hasPrefix "~" $outerRaw -}}
2560+
{{- $outerKey := trimPrefix "~" $outerRaw -}}
2561+
{{- $hasSubKey := eq (len $keyParts) 2 -}}
2562+
{{- $innerKey := "" -}}
2563+
{{- $innerIsWild := false -}}
2564+
{{- if $hasSubKey -}}
2565+
{{- $innerRaw := index $keyParts 1 -}}
2566+
{{- $innerIsWild = hasPrefix "~" $innerRaw -}}
2567+
{{- $innerKey = trimPrefix "~" $innerRaw -}}
2568+
{{- end -}}
2569+
{{- range $topKey, $topVal := $configElementDict -}}
2570+
{{- if or (and (not $outerIsWild) (eq $outerKey $topKey)) (and $outerIsWild (regexMatch $outerKey $topKey)) -}}
2571+
{{- if not $hasSubKey -}}
2572+
{{- $configElementDict = unset $configElementDict $topKey -}}
2573+
{{- else -}}
2574+
{{- $innerDict := get $configElementDict $topKey | default dict -}}
2575+
{{- if (kindIs "map" $innerDict) -}}
2576+
{{- if $innerIsWild -}}
2577+
{{- range $k, $_ := $innerDict -}}
2578+
{{- if regexMatch $innerKey $k -}}
2579+
{{- $innerDict = unset $innerDict $k -}}
2580+
{{- end -}}
25632581
{{- end -}}
2582+
{{- else -}}
2583+
{{- $innerDict = unset $innerDict $innerKey -}}
2584+
{{- end -}}
25642585
{{- end -}}
2565-
{{- end -}}{{/*range $key*/}}
2566-
{{- $configYaml := toYaml $configElementDict -}}
2567-
{{- $_ := set $config.data $configElementName $configYaml -}}
2568-
{{- else -}}
2569-
{{- $configData := (unset $config.data $configElementName) -}}
2570-
{{- $_ := set $config "data" $configData -}}
2586+
{{- $_ := set $configElementDict $topKey $innerDict -}}
2587+
{{- end -}}
2588+
{{- end -}}
2589+
{{- end -}}
25712590
{{- end -}}
2591+
{{- else -}}
2592+
{{- $configData := (unset $config.data $configElementName) -}}
2593+
{{- $_ := set $config "data" $configData -}}
2594+
{{- end -}}
25722595
{{- end -}}{{/*range $configElementName*/}}
25732596
{{ toYaml $config }}
25742597
{{- end -}}
@@ -2598,9 +2621,10 @@ globalExcludeList below is a hard-coded list of global keys to exclude.
25982621
25992622
*/}}
26002623
{{- define "hpcc.getConfigSHA" }}
2601-
{{- $globalExcludeList := list (printf "%s.replicas" .component) -}}
2602-
{{- $globalExcludeSectionRegexList := list ".*spec.yaml$" -}}
2603-
{{- $combinedExcludeKeyList := concat (splitList "," (.excludeKeys | default "")) $globalExcludeList -}}
2624+
{{- $globalExcludeList := list "~.*::replicas" -}}
2625+
{{- $globalExcludeSectionRegexList := list ".*-job.yaml$" -}}
2626+
{{- $componentExcludeList := ternary (splitList "," (.excludeKeys | default "")) list (hasKey . "excludeKeys") -}}
2627+
{{- $combinedExcludeKeyList := concat $globalExcludeList $componentExcludeList -}}
26042628
{{- $ctx := merge (omit . "excludeKeys") (dict "excludeSectionRegexList" $globalExcludeSectionRegexList "excludeKeyList" $combinedExcludeKeyList) -}}
26052629
{{- include "hpcc.filterConfig" $ctx | sha256sum }}
26062630
{{- end -}}

helm/hpcc/templates/eclagent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ data:
124124
{{- $enginePlaneDetails := dict -}}
125125
{{- $_ := include "hpcc.getEnginePlanes" (dict "root" $ "me" . "result" $enginePlaneDetails) -}}
126126
{{- $commonCtx := dict "root" $ "me" . "secretsCategories" $secretsCategories "includeCategories" $enginePlaneDetails.planeCategories "includeNames" $enginePlaneDetails.namedPlanes "env" $env }}
127-
{{- $configSHA := include "hpcc.getConfigSHA" ($commonCtx | merge (dict "configMapHelper" "hpcc.agentConfigMap" "component" "eclagent" "excludeKeys" (print "global," $apptype ".replicas") "lifeCycleCtx" (dict "containers" list))) }}
127+
{{- $configSHA := include "hpcc.getConfigSHA" ($commonCtx | merge (dict "configMapHelper" "hpcc.agentConfigMap" "component" "eclagent" "excludeKeys" "global" "lifeCycleCtx" (dict "containers" list))) }}
128128
{{- $_ := set $commonCtx "lifeCycleCtx" (dict "containers" list) -}}
129129
{{- include "hpcc.checkDefaultStoragePlane" $commonCtx }}
130130
apiVersion: apps/v1

helm/hpcc/templates/eclccserver.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ data:
132132
{{- $env := concat ($.Values.global.env | default list) (.env | default list) $gitenv -}}
133133
{{- $secretsCategories := list "system" "codeVerify" "git" "storage" "jfrog" }}
134134
{{- $commonCtx := dict "root" $ "me" . "includeCategories" (list "dll" "git" "debug") "secretsCategories" $secretsCategories "env" $env }}
135-
{{- $configSHA := include "hpcc.getConfigSHA" ($commonCtx | merge (dict "configMapHelper" "hpcc.eclccServerConfigMap" "component" "eclccserver" "excludeKeys" "global,eclccserver.queues" "lifeCycleCtx" (dict "containers" list))) }}
135+
{{- $configSHA := include "hpcc.getConfigSHA" ($commonCtx | merge (dict "configMapHelper" "hpcc.eclccServerConfigMap" "component" "eclccserver" "excludeKeys" "global,eclccserver::queues" "lifeCycleCtx" (dict "containers" list))) }}
136136
{{- $_ := set $commonCtx "lifeCycleCtx" (dict "containers" list) -}}
137137
apiVersion: apps/v1
138138
kind: Deployment

helm/hpcc/templates/esp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ data:
9797
{{- $includeStorageCategories := ternary (list "lz" "data" "dll" "debug") (list "data" "dll" "debug") (eq $application "eclwatch") -}}
9898
{{- $commonCtx := dict "root" $ "me" . "secretsCategories" $secretsCategories "includeCategories" $includeStorageCategories "env" $env -}}
9999
{{- $_ := set $commonCtx "lifeCycleCtx" (dict "containers" list) -}}
100-
{{- $configSHA := include "hpcc.getConfigSHA" ($commonCtx | merge (dict "configMapHelper" "hpcc.espConfigMap" "component" "esp" "excludeKeys" "global,esp.queues")) -}}
100+
{{- $configSHA := include "hpcc.getConfigSHA" ($commonCtx | merge (dict "configMapHelper" "hpcc.espConfigMap" "component" "esp" "excludeKeys" "global,esp::queues")) -}}
101101
{{- if (ne (include "hpcc.isVisibilityPublic" (dict "root" $ "visibility" .service.visibility)) "") }}
102102
{{- /* If esp is using a public cert, this flag is used later to add the local MTLS mount and cert */ -}}
103103
{{- $_ := set $commonCtx "externalCert" true -}}

0 commit comments

Comments
 (0)