@@ -31,6 +31,7 @@ import (
3131 "github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
3232 "github.com/arangodb/kube-arangodb/pkg/util/errors"
3333 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
34+ "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
3435)
3536
3637func newRuntimeContainerImageUpdateAction (action api.Action , actionCtx ActionContext ) Action {
@@ -56,51 +57,54 @@ func (a actionRuntimeContainerImageUpdate) Post(ctx context.Context) error {
5657 return nil
5758 }
5859
59- name , image , ok := a .getContainerDetails ()
60+ cname , image , ok := a .getContainerDetails ()
6061 if ! ok {
6162 a .log .Info ("Unable to find container details" )
6263 return nil
6364 }
6465
65- member , ok := a .actionCtx .ACS ().CurrentClusterCache ().ArangoMember ().V1 ().GetSimple (m .ArangoMemberName (a .actionCtx .GetName (), a .action .Group ))
66+ cache := a .actionCtx .ACS ().CurrentClusterCache ()
67+ name := m .ArangoMemberName (a .actionCtx .GetName (), a .action .Group )
68+
69+ _ , ok = cache .ArangoMember ().V1 ().GetSimple (name )
6670 if ! ok {
6771 err := errors .Newf ("ArangoMember not found" )
6872 a .log .Err (err ).Error ("ArangoMember not found" )
6973 return err
7074 }
7175
72- return a . actionCtx . WithCurrentArangoMember ( member . GetName ()). UpdateStatus ( ctx , func ( obj * api. ArangoMember , s * api.ArangoMemberStatus ) bool {
73- if obj .Spec .Template == nil || s .Template == nil ||
74- obj .Spec .Template .PodSpec == nil || s .Template .PodSpec == nil {
76+ return inspector . WithArangoMemberUpdate ( ctx , cache , name , func ( in * api.ArangoMember ) ( bool , error ) {
77+ if in .Spec .Template == nil || in . Status .Template == nil ||
78+ in .Spec .Template .PodSpec == nil || in . Status .Template .PodSpec == nil {
7579 a .log .Info ("Nil Member definition" )
76- return false
80+ return false , nil
7781 }
7882
79- if len (obj .Spec .Template .PodSpec .Spec .Containers ) != len (s .Template .PodSpec .Spec .Containers ) {
83+ if len (in .Spec .Template .PodSpec .Spec .Containers ) != len (in . Status .Template .PodSpec .Spec .Containers ) {
8084 a .log .Info ("Invalid size of containers" )
81- return false
85+ return false , nil
8286 }
8387
84- for id := range obj .Spec .Template .PodSpec .Spec .Containers {
85- if obj .Spec .Template .PodSpec .Spec .Containers [id ].Name == name {
86- if s . Template .PodSpec .Spec .Containers [id ].Name != name {
88+ for id := range in .Spec .Template .PodSpec .Spec .Containers {
89+ if in .Spec .Template .PodSpec .Spec .Containers [id ].Name == cname {
90+ if in . Status . Template .PodSpec .Spec .Containers [id ].Name != cname {
8791 a .log .Info ("Invalid order of containers" )
88- return false
92+ return false , nil
8993 }
9094
91- if obj .Spec .Template .PodSpec .Spec .Containers [id ].Image != image {
92- a .log .Str ("got" , obj .Spec .Template .PodSpec .Spec .Containers [id ].Image ).Str ("expected" , image ).Info ("Invalid spec image of container" )
93- return false
95+ if in .Spec .Template .PodSpec .Spec .Containers [id ].Image != image {
96+ a .log .Str ("got" , in .Spec .Template .PodSpec .Spec .Containers [id ].Image ).Str ("expected" , image ).Info ("Invalid spec image of container" )
97+ return false , nil
9498 }
9599
96- if s .Template .PodSpec .Spec .Containers [id ].Image != image {
97- s .Template .PodSpec .Spec .Containers [id ].Image = image
98- return true
100+ if in . Status .Template .PodSpec .Spec .Containers [id ].Image != image {
101+ in . Status .Template .PodSpec .Spec .Containers [id ].Image = image
102+ return true , nil
99103 }
100- return false
104+ return false , nil
101105 }
102106 }
103- return false
107+ return false , nil
104108 })
105109}
106110
0 commit comments