@@ -167,6 +167,7 @@ func (r *FunctionReconciler) ApplyFunctionService(ctx context.Context, function
167167func (r * FunctionReconciler ) ObserveFunctionHPA (ctx context.Context , function * v1alpha1.Function ) error {
168168 if function .Spec .MaxReplicas == nil {
169169 // HPA not enabled, skip further action
170+ delete (function .Status .Conditions , v1alpha1 .HPA )
170171 return nil
171172 }
172173
@@ -212,7 +213,12 @@ func (r *FunctionReconciler) ObserveFunctionHPA(ctx context.Context, function *v
212213func (r * FunctionReconciler ) ApplyFunctionHPA (ctx context.Context , function * v1alpha1.Function ,
213214 newGeneration bool ) error {
214215 if function .Spec .MaxReplicas == nil {
215- // HPA not enabled, skip further action
216+ // HPA not enabled, delete HPA if it exists
217+ err := deleteHPA (ctx , r .Client , types.NamespacedName {Namespace : function .Namespace , Name : function .Name })
218+ if err != nil {
219+ r .Log .Error (err , "failed to delete HPA for function" , "namespace" , function .Namespace , "name" , function .Name )
220+ return err
221+ }
216222 return nil
217223 }
218224 condition := function .Status .Conditions [v1alpha1 .HPA ]
@@ -237,6 +243,7 @@ func (r *FunctionReconciler) ApplyFunctionHPA(ctx context.Context, function *v1a
237243func (r * FunctionReconciler ) ObserveFunctionHPAV2Beta2 (ctx context.Context , function * v1alpha1.Function ) error {
238244 if function .Spec .MaxReplicas == nil {
239245 // HPA not enabled, skip further action
246+ delete (function .Status .Conditions , v1alpha1 .HPA )
240247 return nil
241248 }
242249
@@ -282,7 +289,12 @@ func (r *FunctionReconciler) ObserveFunctionHPAV2Beta2(ctx context.Context, func
282289func (r * FunctionReconciler ) ApplyFunctionHPAV2Beta2 (ctx context.Context , function * v1alpha1.Function ,
283290 newGeneration bool ) error {
284291 if function .Spec .MaxReplicas == nil {
285- // HPA not enabled, skip further action
292+ // HPA not enabled, delete HPA if it exists
293+ err := deleteHPAV2Beta2 (ctx , r .Client , types.NamespacedName {Namespace : function .Namespace , Name : function .Name })
294+ if err != nil {
295+ r .Log .Error (err , "failed to delete HPA for function" , "namespace" , function .Namespace , "name" , function .Name )
296+ return err
297+ }
286298 return nil
287299 }
288300 condition := function .Status .Conditions [v1alpha1 .HPA ]
0 commit comments