@@ -91,6 +91,59 @@ func TestDRADriverSCCAllowsMPSHostPID(t *testing.T) {
9191 require .True (t , allowHostPID , "MPS control daemon pods require hostPID" )
9292}
9393
94+ func TestComputeDomainDaemonAnyUIDBinding (t * testing.T ) {
95+ for _ , tc := range []struct {
96+ name string
97+ openshift bool
98+ computeDomains bool
99+ }{
100+ {name : "openshift-enabled" , openshift : true , computeDomains : true },
101+ {name : "openshift-disabled" , openshift : true },
102+ {name : "kubernetes-enabled" , computeDomains : true },
103+ {name : "kubernetes-disabled" },
104+ } {
105+ t .Run (tc .name , func (t * testing.T ) {
106+ s := newTestDRAState (t )
107+ cr := sampleGPUCluster ()
108+ cr .Spec .DRADriver .ComputeDomains .Enabled = new (tc.computeDomains )
109+ catalog := draSupportedCatalog ()
110+ if tc .openshift {
111+ catalog = draSupportedOpenshiftCatalog ()
112+ }
113+ objs , err := s .getManifestObjects (context .Background (), cr , catalog )
114+ require .NoError (t , err )
115+ var binding * unstructured.Unstructured
116+ for _ , obj := range objs {
117+ if obj .GetKind () == "ClusterRoleBinding" && obj .GetName () == "compute-domain-daemon-openshift-anyuid-role-binding" {
118+ binding = obj
119+ }
120+ }
121+ if tc .openshift && tc .computeDomains {
122+ require .NotNil (t , binding )
123+ require .Equal (t , map [string ]any {
124+ "apiGroup" : "rbac.authorization.k8s.io" ,
125+ "kind" : "ClusterRole" ,
126+ "name" : "system:openshift:scc:anyuid" ,
127+ }, binding .Object ["roleRef" ])
128+ require .Equal (t , []any {map [string ]any {
129+ "kind" : "ServiceAccount" ,
130+ "name" : "compute-domain-daemon-service-account" ,
131+ "namespace" : "test-operator" ,
132+ }}, binding .Object ["subjects" ])
133+ } else {
134+ require .Nil (t , binding )
135+ }
136+ if tc .openshift {
137+ scc := findSCC (t , objs , "nvidia-dra-driver" )
138+ require .NotNil (t , scc )
139+ require .Contains (t , sccUsers (t , scc ), "system:serviceaccount:test-operator:compute-domain-daemon-service-account" )
140+ require .Contains (t , scc .Object , "priority" )
141+ require .Nil (t , scc .Object ["priority" ])
142+ }
143+ })
144+ }
145+ }
146+
94147func TestGPUClusterOperandSCCs (t * testing.T ) {
95148 testCases := []struct {
96149 name string
0 commit comments