Don't reload existing config

This commit is contained in:
Zanis
2025-01-02 23:38:17 +00:00
parent f6887b4d8a
commit 6d1d017aa4

View File

@@ -479,6 +479,10 @@ func updatePodAnnotations(upgradeFuncs callbacks.RollingUpgradeFuncs, item runti
return constants.NotUpdated
}
if config.Type == constants.SecretProviderClassEnvVarPostfix && secretProviderClassAnnotationReloaded(pa, config) {
return constants.NotUpdated
}
for k, v := range annotations {
pa[k] = v
}
@@ -493,6 +497,11 @@ func getReloaderAnnotationKey() string {
)
}
func secretProviderClassAnnotationReloaded(oldAnnotations map[string]string, newConfig util.Config) bool {
annotaion := oldAnnotations[getReloaderAnnotationKey()]
return strings.Contains(annotaion, newConfig.ResourceName) && strings.Contains(annotaion, newConfig.SHAValue)
}
func createReloadedAnnotations(target *util.ReloadSource) (map[string]string, error) {
if target == nil {
return nil, errors.New("target is required")
@@ -527,6 +536,10 @@ func updateContainerEnvVars(upgradeFuncs callbacks.RollingUpgradeFuncs, item run
return constants.NoContainerFound
}
if config.Type == constants.SecretProviderClassEnvVarPostfix && secretProviderClassEnvReloaded(upgradeFuncs.ContainersFunc(item), envVar, config.SHAValue) {
return constants.NotUpdated
}
//update if env var exists
result = updateEnvVar(upgradeFuncs.ContainersFunc(item), envVar, config.SHAValue)
@@ -557,3 +570,15 @@ func updateEnvVar(containers []v1.Container, envVar string, shaData string) cons
}
return constants.NoEnvVarFound
}
func secretProviderClassEnvReloaded(containers []v1.Container, envVar string, shaData string) bool {
for i := range containers {
envs := containers[i].Env
for j := range envs {
if envs[j].Name == envVar {
return envs[j].Value == shaData
}
}
}
return false
}