@@ -307,16 +307,19 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
307307
308308 spec := openstackclient .ClientPodSpec (ctx , instance , helper , configVarsHash )
309309
310+ podSpecHash , err := util .ObjectHash (spec )
311+ if err != nil {
312+ return ctrl.Result {}, err
313+ }
314+
315+ podSpecHashName := "podSpec"
316+
310317 op , err := controllerutil .CreateOrPatch (ctx , r .Client , osclient , func () error {
311318 isPodUpdate := ! osclient .ObjectMeta .CreationTimestamp .IsZero ()
312- if ! isPodUpdate {
319+ currentPodSpecHash := instance .Status .Hash [podSpecHashName ]
320+ if ! isPodUpdate || currentPodSpecHash != podSpecHash {
313321 osclient .Spec = spec
314- } else {
315- osclient .Spec .Containers [0 ].Env = spec .Containers [0 ].Env
316- osclient .Spec .NodeSelector = spec .NodeSelector
317- osclient .Spec .Containers [0 ].Image = instance .Spec .ContainerImage
318322 }
319-
320323 osclient .Labels = util .MergeStringMaps (osclient .Labels , clientLabels )
321324
322325 err = controllerutil .SetControllerReference (instance , osclient , r .Scheme )
@@ -360,6 +363,8 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
360363 return ctrl.Result {}, err
361364 }
362365
366+ instance .Status .Hash , _ = util .SetHash (instance .Status .Hash , podSpecHashName , podSpecHash )
367+
363368 if op != controllerutil .OperationResultNone {
364369 util .LogForObject (
365370 helper ,
0 commit comments