@@ -43,12 +43,44 @@ func newRuntimeContainerImageUpdateAction(action api.Action, actionCtx ActionCon
4343}
4444
4545var _ ActionPost = & actionRuntimeContainerImageUpdate {}
46+ var _ ActionPre = & actionRuntimeContainerImageUpdate {}
4647
4748type actionRuntimeContainerImageUpdate struct {
4849 // actionImpl implement timeout and member id functions
4950 actionImpl
5051}
5152
53+ func (a actionRuntimeContainerImageUpdate ) Pre (ctx context.Context ) error {
54+ a .log .Info ("Updating member condition" )
55+ m , ok := a .actionCtx .GetMemberStatusByID (a .action .MemberID )
56+ if ! ok {
57+ a .log .Info ("member is gone already" )
58+ return nil
59+ }
60+
61+ cname , _ , ok := a .getContainerDetails ()
62+ if ! ok {
63+ a .log .Info ("Unable to find container details" )
64+ return nil
65+ }
66+
67+ if c , ok := m .Conditions .Get (api .ConditionTypeUpdating ); ok {
68+ if c .Params == nil {
69+ c .Params = api.ConditionParams {}
70+ }
71+
72+ if c .Params [api .ConditionParamContainerUpdatingName ] != cname {
73+ c .Params [api .ConditionParamContainerUpdatingName ] = cname
74+
75+ if err := a .actionCtx .UpdateMember (ctx , m ); err != nil {
76+ return err
77+ }
78+ }
79+ }
80+
81+ return nil
82+ }
83+
5284func (a actionRuntimeContainerImageUpdate ) Post (ctx context.Context ) error {
5385 a .log .Info ("Updating container image" )
5486 m , ok := a .actionCtx .GetMemberStatusByID (a .action .MemberID )
@@ -57,6 +89,22 @@ func (a actionRuntimeContainerImageUpdate) Post(ctx context.Context) error {
5789 return nil
5890 }
5991
92+ if c , ok := m .Conditions .Get (api .ConditionTypeUpdating ); ok {
93+ if c .Params != nil {
94+ if _ , ok := c .Params [api .ConditionParamContainerUpdatingName ]; ok {
95+ delete (c .Params , api .ConditionParamContainerUpdatingName )
96+
97+ if len (c .Params ) == 0 {
98+ c .Params = nil
99+ }
100+
101+ if err := a .actionCtx .UpdateMember (ctx , m ); err != nil {
102+ return err
103+ }
104+ }
105+ }
106+ }
107+
60108 cname , image , ok := a .getContainerDetails ()
61109 if ! ok {
62110 a .log .Info ("Unable to find container details" )
0 commit comments