Skip to content

Commit 90ddf82

Browse files
authored
fix(operator): tolerate missing KEDA when cleaning up ScaledObject (#985)
The VLLMRuntime controller reconciled a stale ScaledObject delete in the autoscaling-disabled branch, guarding only errors.IsNotFound. On a cluster without KEDA the keda.sh/v1alpha1 API group is not registered, so the delete returns a NoKindMatchError rather than NotFound, and every reconcile failed -- making the operator unusable on clusters that never requested autoscaling. Also tolerate meta.IsNoMatchError on the cleanup path: there is nothing to delete when the CRD is absent, so the reconcile should succeed. Fixes #981 Signed-off-by: Tai An <antai12232931@outlook.com>
1 parent 1e973a3 commit 90ddf82

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

operator/internal/controller/vllmruntime_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
appsv1 "k8s.io/api/apps/v1"
2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/apimachinery/pkg/api/errors"
29+
"k8s.io/apimachinery/pkg/api/meta"
2930
"k8s.io/apimachinery/pkg/api/resource"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -363,7 +364,13 @@ func (r *VLLMRuntimeReconciler) Reconcile(
363364
scaledObject.SetKind("ScaledObject")
364365
scaledObject.SetName(vllmRuntime.Name + "-scaledobject")
365366
scaledObject.SetNamespace(vllmRuntime.Namespace)
366-
if err := r.Delete(ctx, scaledObject); err != nil && !errors.IsNotFound(err) {
367+
// Best-effort cleanup of a stale ScaledObject when autoscaling is
368+
// disabled. Tolerate IsNoMatchError so the reconcile still succeeds on
369+
// clusters where KEDA is not installed (the keda.sh API group is not
370+
// registered): there is nothing to delete, and requiring KEDA here
371+
// would make the operator unusable on non-autoscaling clusters.
372+
if err := r.Delete(ctx, scaledObject); err != nil &&
373+
!errors.IsNotFound(err) && !meta.IsNoMatchError(err) {
367374
log.Error(err, "Failed to delete ScaledObject")
368375
return ctrl.Result{}, err
369376
}

0 commit comments

Comments
 (0)