@@ -29,8 +29,6 @@ import (
2929
3030 api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3131 "github.com/arangodb/kube-arangodb/pkg/deployment/features"
32- "github.com/arangodb/kube-arangodb/pkg/deployment/resources"
33- "github.com/arangodb/kube-arangodb/pkg/deployment/topology"
3432 "github.com/arangodb/kube-arangodb/pkg/util"
3533 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3634)
@@ -62,30 +60,14 @@ func containersCompare(ds api.DeploymentSpec, g api.ServerGroup, spec, status *c
6260
6361 g := podContainerFuncGenerator (ds , g , ac , bc )
6462
65- if m , p , err := comparePodContainer (builder , g (compareServerContainerVolumeMounts ), g (compareServerContainerProbes )); err != nil {
63+ if m , p , err := comparePodContainer (builder , g (compareServerContainerVolumeMounts ), g (compareServerContainerProbes ), g ( compareServerContainerEnvs ) ); err != nil {
6664 log .Err (err ).Msg ("Error while getting pod diff" )
6765 return SkippedRotation , nil , err
6866 } else {
6967 mode = mode .And (m )
7068 plan = append (plan , p ... )
7169 }
7270
73- if ! equality .Semantic .DeepEqual (ac .Env , bc .Env ) {
74- filter := func (a , b map [string ]core.EnvVar ) (map [string ]core.EnvVar , map [string ]core.EnvVar ) {
75- for _ , excludedEnv := range getExcludedEnv () {
76- delete (a , excludedEnv )
77- delete (b , excludedEnv )
78- }
79-
80- return a , b
81- }
82- if areEnvsEqual (ac .Env , bc .Env , filter ) {
83- // Envs are the same after filtering, but it were different before filtering, so it can be replaced.
84- bc .Env = ac .Env
85- mode = mode .And (SilentRotation )
86- }
87- }
88-
8971 if ! equality .Semantic .DeepEqual (ac .EnvFrom , bc .EnvFrom ) {
9072 // Check EnvFromSource differences.
9173 filter := func (a , b map [string ]core.EnvFromSource ) (map [string ]core.EnvFromSource , map [string ]core.EnvFromSource ) {
@@ -113,6 +95,16 @@ func containersCompare(ds api.DeploymentSpec, g api.ServerGroup, spec, status *c
11395 bc .Image = ac .Image
11496 mode = mode .And (InPlaceRotation )
11597 }
98+
99+ g := podContainerFuncGenerator (ds , g , ac , bc )
100+
101+ if m , p , err := comparePodContainer (builder , g (compareAnyContainerVolumeMounts ), g (compareAnyContainerEnvs )); err != nil {
102+ log .Err (err ).Msg ("Error while getting pod diff" )
103+ return SkippedRotation , nil , err
104+ } else {
105+ mode = mode .And (m )
106+ plan = append (plan , p ... )
107+ }
116108 }
117109
118110 if api .IsReservedServerGroupContainerName (ac .Name ) {
@@ -217,27 +209,6 @@ func internalContainerLifecycleCompare(spec, status *core.Container) Mode {
217209 return SkippedRotation
218210}
219211
220- func areEnvsEqual (a , b []core.EnvVar , rules ... func (a , b map [string ]core.EnvVar ) (map [string ]core.EnvVar , map [string ]core.EnvVar )) bool {
221- am := getEnvs (a )
222- bm := getEnvs (b )
223-
224- for _ , r := range rules {
225- am , bm = r (am , bm )
226- }
227-
228- return equality .Semantic .DeepEqual (am , bm )
229- }
230-
231- func getEnvs (e []core.EnvVar ) map [string ]core.EnvVar {
232- m := map [string ]core.EnvVar {}
233-
234- for _ , q := range e {
235- m [q .Name ] = q
236- }
237-
238- return m
239- }
240-
241212func areProbesEqual (a , b * core.Probe ) bool {
242213 if a == nil && b == nil {
243214 return true
@@ -286,10 +257,3 @@ func createEnvsFromMap(e []core.EnvFromSource) map[string]core.EnvFromSource {
286257
287258 return m
288259}
289-
290- // getExcludedEnv returns environment variables which should not be compared when pod's rotation is considered.
291- func getExcludedEnv () []string {
292- return []string {topology .ArangoDBZone , resources .ArangoDBOverrideServerGroupEnv ,
293- resources .ArangoDBOverrideDeploymentModeEnv , resources .ArangoDBOverrideVersionEnv ,
294- resources .ArangoDBOverrideEnterpriseEnv }
295- }
0 commit comments