From 2577929729ce3c5ae879c9da587029eae761404e Mon Sep 17 00:00:00 2001 From: Tuomas Katila Date: Thu, 20 Aug 2026 13:04:29 +0300 Subject: [PATCH] controller: set status n/a if no DSs are created Signed-off-by: Tuomas Katila --- internal/controller/deviceplugin_controller.go | 7 +++++++ internal/controller/dra_controller.go | 6 ++++++ internal/controller/xpumanager_controller.go | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/internal/controller/deviceplugin_controller.go b/internal/controller/deviceplugin_controller.go index 7f850e9..4ba8c2c 100644 --- a/internal/controller/deviceplugin_controller.go +++ b/internal/controller/deviceplugin_controller.go @@ -26,6 +26,7 @@ import ( core "k8s.io/api/core/v1" "k8s.io/klog/v2" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -261,6 +262,12 @@ func (r *DevicePluginReconciler) updateStatus(ctx context.Context, cp *v1alpha.C ds := &apps.DaemonSet{} if err := r.Get(ctx, client.ObjectKey{Name: r.buildDaemonSetName(cp.Name), Namespace: r.Opts.Namespace}, ds); err != nil { + if errors.IsNotFound(err) { + cp.Status.DevicePluginStatus = notAvailableStatus + + return nil + } + klog.Error(err, "unable to get DP DaemonSet to update status") return err diff --git a/internal/controller/dra_controller.go b/internal/controller/dra_controller.go index 310b564..c0c74ca 100644 --- a/internal/controller/dra_controller.go +++ b/internal/controller/dra_controller.go @@ -409,6 +409,12 @@ func (r *DRAReconciler) buildDraDaemonset(spec *v1alpha.ClusterPolicy) *apps.Dae func (r *DRAReconciler) updateStatus(ctx context.Context, cp *v1alpha.ClusterPolicy) error { ds := &apps.DaemonSet{} if err := r.Get(ctx, client.ObjectKey{Name: r.buildDaemonSetName(cp.Name), Namespace: r.Opts.Namespace}, ds); err != nil { + if errors.IsNotFound(err) { + cp.Status.DRAStatus = notAvailableStatus + + return nil + } + klog.Error(err, "unable to get DRA DaemonSet to update status") return err diff --git a/internal/controller/xpumanager_controller.go b/internal/controller/xpumanager_controller.go index 5f6506d..370d339 100644 --- a/internal/controller/xpumanager_controller.go +++ b/internal/controller/xpumanager_controller.go @@ -507,6 +507,12 @@ func (r *XpuManagerReconciler) removeDeploymentIfExists(ctx context.Context, cp func (r *XpuManagerReconciler) updateStatus(ctx context.Context, cp *v1alpha.ClusterPolicy) error { ds := &apps.DaemonSet{} if err := r.Get(ctx, client.ObjectKey{Name: r.buildDaemonSetName(cp.Name), Namespace: r.Opts.Namespace}, ds); err != nil { + if errors.IsNotFound(err) { + cp.Status.XPUManagerStatus = notAvailableStatus + + return nil + } + klog.Error(err, "unable to get XPU Manager DaemonSet to update status") return err