@@ -178,13 +178,16 @@ func setScopedHRQ(nm, nsnm string, resourceList corev1.ResourceList, scopeSelect
178
178
}
179
179
180
180
func setUpParentAndChild () (string , string , func ()) {
181
- parentNs := createNS ("hrq-test-parent-" )
182
- childNs := createSubNS (parentNs )
181
+ // There was the case where bug has occurred when there is a grandchildren namespace, so We'll make one.
182
+ rootNs := createNS ("root-" )
183
+ parentNs := createSubNS (rootNs , "parent-" )
184
+ childNs := createSubNS (parentNs , "child-" )
183
185
cleanup := func () {
186
+ MustRunWithTimeout (cleanupTimeout , "kubectl annotate ns" , rootNs , "hnc.x-k8s.io/subnamespace-of-" )
184
187
MustRunWithTimeout (cleanupTimeout , "kubectl annotate ns" , parentNs , "hnc.x-k8s.io/subnamespace-of-" )
185
188
MustRunWithTimeout (cleanupTimeout , "kubectl annotate ns" , childNs , "hnc.x-k8s.io/subnamespace-of-" )
186
189
var wg sync.WaitGroup
187
- for _ , ns := range []string {parentNs , childNs } {
190
+ for _ , ns := range []string {rootNs , parentNs , childNs } {
188
191
wg .Add (1 )
189
192
go func (ns string ) {
190
193
MustRun ("kubectl delete ns" , ns )
@@ -204,8 +207,8 @@ func createNS(prefix string) string {
204
207
return nsName
205
208
}
206
209
207
- func createSubNS (parent string ) string {
208
- nsName := "hrq-test-child-" + uuid .New ().String ()
210
+ func createSubNS (parent , prefix string ) string {
211
+ nsName := prefix + uuid .New ().String ()
209
212
MustRun ("kubectl hns create" , nsName , "-n" , parent )
210
213
return nsName
211
214
}
0 commit comments