@@ -33,7 +33,7 @@ import (
33
33
34
34
var _ = Describe ("RayCluster controller" , func () {
35
35
Context ("RayCluster controller test" , func () {
36
- var rayClusterName = "test-raycluster"
36
+ rayClusterName : = "test-raycluster"
37
37
var namespaceName string
38
38
BeforeEach (func (ctx SpecContext ) {
39
39
By ("Creating a namespace for running the tests." )
@@ -145,6 +145,53 @@ var _ = Describe("RayCluster controller", func() {
145
145
}).WithTimeout (time .Second * 10 ).Should (WithTransform (OwnerReferenceName , Equal (foundRayCluster .Name )))
146
146
})
147
147
148
+ It ("should delete the head pod if missing image pull secrets" , func (ctx SpecContext ) {
149
+ foundRayCluster , err := rayClient .RayV1 ().RayClusters (namespaceName ).Get (ctx , rayClusterName , metav1.GetOptions {})
150
+ Expect (err ).To (Not (HaveOccurred ()))
151
+
152
+ Eventually (func () (* corev1.ServiceAccount , error ) {
153
+ return k8sClient .CoreV1 ().ServiceAccounts (namespaceName ).Get (ctx , oauthServiceAccountNameFromCluster (foundRayCluster ), metav1.GetOptions {})
154
+ }).WithTimeout (time .Second * 10 ).Should (WithTransform (OwnerReferenceKind , Equal ("RayCluster" )))
155
+
156
+ headPodName := "head-pod"
157
+ headPod := & corev1.Pod {
158
+ ObjectMeta : metav1.ObjectMeta {
159
+ Name : headPodName ,
160
+ Namespace : namespaceName ,
161
+ Labels : map [string ]string {
162
+ "ray.io/node-type" : "head" ,
163
+ "ray.io/cluster" : foundRayCluster .Name ,
164
+ },
165
+ },
166
+ Spec : corev1.PodSpec {
167
+ Containers : []corev1.Container {
168
+ {
169
+ Name : "head-container" ,
170
+ Image : "busybox" ,
171
+ },
172
+ },
173
+ },
174
+ }
175
+ _ , err = k8sClient .CoreV1 ().Pods (namespaceName ).Create (ctx , headPod , metav1.CreateOptions {})
176
+ Expect (err ).To (Not (HaveOccurred ()))
177
+
178
+ Eventually (func () (* corev1.Pod , error ) {
179
+ return k8sClient .CoreV1 ().Pods (namespaceName ).Get (ctx , headPodName , metav1.GetOptions {})
180
+ }).WithTimeout (time .Second * 10 ).ShouldNot (BeNil ())
181
+
182
+ sa , err := k8sClient .CoreV1 ().ServiceAccounts (namespaceName ).Get (ctx , oauthServiceAccountNameFromCluster (foundRayCluster ), metav1.GetOptions {})
183
+ Expect (err ).To (Not (HaveOccurred ()))
184
+
185
+ sa .ImagePullSecrets = append (sa .ImagePullSecrets , corev1.LocalObjectReference {Name : "test-image-pull-secret" })
186
+ _ , err = k8sClient .CoreV1 ().ServiceAccounts (namespaceName ).Update (ctx , sa , metav1.UpdateOptions {})
187
+ Expect (err ).To (Not (HaveOccurred ()))
188
+
189
+ Eventually (func () error {
190
+ _ , err := k8sClient .CoreV1 ().Pods (namespaceName ).Get (ctx , headPodName , metav1.GetOptions {})
191
+ return err
192
+ }).WithTimeout (time .Second * 10 ).Should (Satisfy (errors .IsNotFound ))
193
+ })
194
+
148
195
It ("should remove CRB when the RayCluster is deleted" , func (ctx SpecContext ) {
149
196
foundRayCluster , err := rayClient .RayV1 ().RayClusters (namespaceName ).Get (ctx , rayClusterName , metav1.GetOptions {})
150
197
Expect (err ).To (Not (HaveOccurred ()))
@@ -157,7 +204,6 @@ var _ = Describe("RayCluster controller", func() {
157
204
return err
158
205
}).WithTimeout (time .Second * 10 ).Should (Satisfy (errors .IsNotFound ))
159
206
})
160
-
161
207
})
162
208
})
163
209
0 commit comments