@@ -100,22 +100,13 @@ func (r *FunctionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
100100 }
101101
102102 isNewGeneration := r .checkIfFunctionGenerationsIsIncreased (function )
103+ pauseRollout := shouldPauseNonGenerationRollout (function , isNewGeneration )
104+ function .Status .PendingChange = ""
103105
104106 err = r .ObserveFunctionStatefulSet (ctx , function )
105107 if err != nil {
106108 return reconcile.Result {}, err
107109 }
108- // skip reconcile if pauseRollout is set to true and the generation is not increased
109- if spec .IsPauseRollout (function ) && ! isNewGeneration {
110- err = r .Status ().Update (ctx , function )
111- if err != nil {
112- r .Log .Error (err , "failed to update function status after observing statefulset" )
113- return ctrl.Result {}, err
114- }
115- return ctrl.Result {}, nil
116- } else {
117- function .Status .PendingChange = ""
118- }
119110
120111 err = r .ObserveFunctionService (ctx , function )
121112 if err != nil {
@@ -144,6 +135,45 @@ func (r *FunctionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
144135 return ctrl.Result {}, err
145136 }
146137
138+ if pauseRollout {
139+ if shouldApplyPausedResourceAction (function .Status .Conditions [v1alpha1 .StatefulSet ].Action ) {
140+ err = r .ApplyFunctionStatefulSet (ctx , function , isNewGeneration )
141+ if err != nil {
142+ return reconcile.Result {}, err
143+ }
144+ }
145+ if shouldApplyPausedResourceAction (function .Status .Conditions [v1alpha1 .Service ].Action ) {
146+ err = r .ApplyFunctionService (ctx , function , isNewGeneration )
147+ if err != nil {
148+ return reconcile.Result {}, err
149+ }
150+ }
151+ if condition , ok := function .Status .Conditions [v1alpha1 .HPA ]; ok && shouldApplyPausedResourceAction (condition .Action ) {
152+ if r .GroupVersionFlags != nil && r .GroupVersionFlags .APIAutoscalingGroupVersion == utils .GroupVersionV2Beta2 {
153+ err = r .ApplyFunctionHPAV2Beta2 (ctx , function , isNewGeneration )
154+ if err != nil {
155+ return reconcile.Result {}, err
156+ }
157+ } else if r .GroupVersionFlags != nil && r .GroupVersionFlags .APIAutoscalingGroupVersion == utils .GroupVersionV2 {
158+ err = r .ApplyFunctionHPA (ctx , function , isNewGeneration )
159+ if err != nil {
160+ return reconcile.Result {}, err
161+ }
162+ }
163+ }
164+ if condition , ok := function .Status .Conditions [v1alpha1 .VPA ]; ok && shouldApplyPausedResourceAction (condition .Action ) {
165+ err = r .ApplyFunctionVPA (ctx , function )
166+ if err != nil {
167+ return reconcile.Result {}, err
168+ }
169+ }
170+ err = r .ApplyFunctionCleanUpJob (ctx , function )
171+ if err != nil {
172+ return reconcile.Result {}, err
173+ }
174+ return ctrl.Result {}, nil
175+ }
176+
147177 err = r .ApplyFunctionStatefulSet (ctx , function , isNewGeneration )
148178 if err != nil {
149179 return reconcile.Result {}, err
0 commit comments