@@ -34,6 +34,7 @@ import (
3434 "sigs.k8s.io/controller-runtime/pkg/reconcile"
3535 "sigs.k8s.io/controller-runtime/pkg/source"
3636
37+ gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1"
3738 nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1"
3839 "github.com/NVIDIA/gpu-operator/controllers/clusterinfo"
3940 "github.com/NVIDIA/gpu-operator/internal/conditions"
@@ -59,6 +60,7 @@ type GPUClusterConfigReconciler struct {
5960//+kubebuilder:rbac:groups=nvidia.com,resources=gpuclusterconfigs,verbs=get;list;watch;create;update;patch;delete
6061//+kubebuilder:rbac:groups=nvidia.com,resources=gpuclusterconfigs/status,verbs=get;update;patch
6162//+kubebuilder:rbac:groups=nvidia.com,resources=gpuclusterconfigs/finalizers,verbs=update
63+ //+kubebuilder:rbac:groups=nvidia.com,resources=clusterpolicies,verbs=get;list;watch
6264
6365func (r * GPUClusterConfigReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
6466 logger := log .FromContext (ctx )
@@ -79,6 +81,24 @@ func (r *GPUClusterConfigReconciler) Reconcile(ctx context.Context, req ctrl.Req
7981 return ctrl.Result {}, wrappedErr
8082 }
8183
84+ // GPUClusterConfig (DRA path) is mutually exclusive with ClusterPolicy: if one
85+ // exists, yield to it rather than deploying the DRA stack alongside it.
86+ clusterPolicies := & gpuv1.ClusterPolicyList {}
87+ if err := r .List (ctx , clusterPolicies ); err != nil {
88+ return ctrl.Result {}, fmt .Errorf ("error listing ClusterPolicies: %w" , err )
89+ }
90+ if len (clusterPolicies .Items ) > 0 {
91+ logger .V (consts .LogLevelWarning ).Info ("ClusterPolicy present, skipping mutually exclusive GPUClusterConfig" )
92+ if err := r .updateCrStatus (ctx , instance , nvidiav1alpha1 .Disabled ); err != nil {
93+ return ctrl.Result {}, err
94+ }
95+ msg := "GPUClusterConfig is mutually exclusive with ClusterPolicy; remove the ClusterPolicy or disable GPUClusterConfig"
96+ if condErr := r .conditionUpdater .SetConditionsError (ctx , instance , conditions .ReconcileFailed , msg ); condErr != nil {
97+ logger .Error (condErr , "failed to set condition" )
98+ }
99+ return ctrl.Result {}, nil
100+ }
101+
82102 // Singleton, first-wins (mirroring ClusterPolicy): the first instance to reconcile
83103 // claims ownership; any other instance is marked Ignored and skipped. The owner is
84104 // held in memory, so the choice resets on operator restart.
0 commit comments