@@ -2329,63 +2329,71 @@ func createResourceQuota(client clientset.Interface, namespace string, size stri
2329
2329
ctx , cancel := context .WithCancel (context .Background ())
2330
2330
defer cancel ()
2331
2331
2332
- var storagePolicyNameForSharedDatastores string
2333
2332
var storagePolicyNameForSvc1 string
2334
2333
var storagePolicyNameForSvc2 string
2335
2334
2336
- waitTime := 15
2337
- var executeCreateResourceQuota bool
2338
- executeCreateResourceQuota = true
2339
- if ! multipleSvc {
2340
- // reading export variable from a single supervisor cluster
2341
- storagePolicyNameForSharedDatastores = GetAndExpectStringEnvVar (envStoragePolicyNameForSharedDatastores )
2342
- } else {
2335
+ // waitTime := 15
2336
+ // var executeCreateResourceQuota bool
2337
+ // executeCreateResourceQuota = true
2338
+ if multipleSvc {
2343
2339
// reading multiple export variables from a multi svc setup
2344
2340
storagePolicyNameForSvc1 = GetAndExpectStringEnvVar (envStoragePolicyNameForSharedDsSvc1 )
2345
2341
storagePolicyNameForSvc2 = GetAndExpectStringEnvVar (envStoragePolicyNameForSharedDsSvc2 )
2346
2342
}
2347
2343
2344
+ // if supervisorCluster {
2345
+ // _, err := client.CoreV1().ResourceQuotas(namespace).Get(ctx, namespace+"-storagequota", metav1.GetOptions{})
2346
+ // if !multipleSvc {
2347
+ // if err != nil || !(scName == storagePolicyNameForSharedDatastores) {
2348
+ // executeCreateResourceQuota = true
2349
+ // } else {
2350
+ // executeCreateResourceQuota = false
2351
+ // }
2352
+ // } else {
2353
+ // if err != nil || !(scName == storagePolicyNameForSvc1) || !(scName == storagePolicyNameForSvc2) {
2354
+ // executeCreateResourceQuota = true
2355
+ // } else {
2356
+ // executeCreateResourceQuota = false
2357
+ // }
2358
+ // }
2359
+ // }
2360
+
2348
2361
if supervisorCluster {
2349
- _ , err := client .CoreV1 ().ResourceQuotas (namespace ).Get (ctx , namespace + "-storagequota" , metav1.GetOptions {})
2350
- if ! multipleSvc {
2351
- if err != nil || ! (scName == storagePolicyNameForSharedDatastores ) {
2352
- executeCreateResourceQuota = true
2353
- } else {
2354
- executeCreateResourceQuota = false
2355
- }
2356
- } else {
2357
- if err != nil || ! (scName == storagePolicyNameForSvc1 ) || ! (scName == storagePolicyNameForSvc2 ) {
2358
- executeCreateResourceQuota = true
2359
- } else {
2360
- executeCreateResourceQuota = false
2361
- }
2362
- }
2362
+ setStoragePolicyQuota (ctx , restConfig , scName , namespace , rqLimit )
2363
2363
}
2364
2364
2365
- if executeCreateResourceQuota {
2366
- // deleteResourceQuota if already present.
2367
- deleteResourceQuota (client , namespace )
2368
-
2369
- resourceQuota := newTestResourceQuota (quotaName , size , scName )
2370
- resourceQuota , err := client .CoreV1 ().ResourceQuotas (namespace ).Create (ctx , resourceQuota , metav1.CreateOptions {})
2371
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
2372
- ginkgo .By (fmt .Sprintf ("Create Resource quota: %+v" , resourceQuota ))
2373
- ginkgo .By (fmt .Sprintf ("Waiting for %v seconds to allow resourceQuota to be claimed" , waitTime ))
2374
- time .Sleep (time .Duration (waitTime ) * time .Second )
2365
+ if multipleSvc {
2366
+ setStoragePolicyQuota (ctx , restConfig , storagePolicyNameForSvc1 , namespace , rqLimit )
2367
+ setStoragePolicyQuota (ctx , restConfig , storagePolicyNameForSvc2 , namespace , rqLimit )
2375
2368
}
2369
+
2370
+ // if executeCreateResourceQuota {
2371
+ // // deleteResourceQuota if already present.
2372
+ // deleteResourceQuota(client, namespace)
2373
+
2374
+ // resourceQuota := newTestResourceQuota(quotaName, size, scName)
2375
+ // resourceQuota, err := client.CoreV1().ResourceQuotas(namespace).Create(ctx, resourceQuota, metav1.CreateOptions{})
2376
+ // gomega.Expect(err).NotTo(gomega.HaveOccurred())
2377
+ // ginkgo.By(fmt.Sprintf("Create Resource quota: %+v", resourceQuota))
2378
+ // ginkgo.By(fmt.Sprintf("Waiting for %v seconds to allow resourceQuota to be claimed", waitTime))
2379
+ // time.Sleep(time.Duration(waitTime) * time.Second)
2380
+ // }
2376
2381
}
2377
2382
2378
2383
// deleteResourceQuota deletes resource quota for the specified namespace,
2379
2384
// if it exists.
2380
2385
func deleteResourceQuota (client clientset.Interface , namespace string ) {
2381
- ctx , cancel := context .WithCancel (context .Background ())
2382
- defer cancel ()
2383
- _ , err := client .CoreV1 ().ResourceQuotas (namespace ).Get (ctx , quotaName , metav1.GetOptions {})
2384
- if err == nil {
2385
- err = client .CoreV1 ().ResourceQuotas (namespace ).Delete (ctx , quotaName , * metav1 .NewDeleteOptions (0 ))
2386
- gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
2387
- ginkgo .By (fmt .Sprintf ("Deleted Resource quota: %+v" , quotaName ))
2386
+ if ! supervisorCluster {
2387
+ ctx , cancel := context .WithCancel (context .Background ())
2388
+ defer cancel ()
2389
+ _ , err := client .CoreV1 ().ResourceQuotas (namespace ).Get (ctx , quotaName , metav1.GetOptions {})
2390
+ if err == nil {
2391
+ err = client .CoreV1 ().ResourceQuotas (namespace ).Delete (ctx , quotaName , * metav1 .NewDeleteOptions (0 ))
2392
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
2393
+ ginkgo .By (fmt .Sprintf ("Deleted Resource quota: %+v" , quotaName ))
2394
+ }
2388
2395
}
2396
+
2389
2397
}
2390
2398
2391
2399
// checks if resource quota gets updated or not
@@ -2415,8 +2423,11 @@ func checkResourceQuota(client clientset.Interface, namespace string, name strin
2415
2423
func setResourceQuota (client clientset.Interface , namespace string , size string ) {
2416
2424
ctx , cancel := context .WithCancel (context .Background ())
2417
2425
defer cancel ()
2418
- // deleteResourceQuota if already present.
2419
- deleteResourceQuota (client , namespace )
2426
+ if ! supervisorCluster {
2427
+ // deleteResourceQuota if already present.
2428
+ deleteResourceQuota (client , namespace )
2429
+ }
2430
+
2420
2431
existingResourceQuota , err := client .CoreV1 ().ResourceQuotas (namespace ).Get (ctx , namespace , metav1.GetOptions {})
2421
2432
if ! apierrors .IsNotFound (err ) {
2422
2433
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
@@ -2433,15 +2444,15 @@ func setResourceQuota(client clientset.Interface, namespace string, size string)
2433
2444
2434
2445
// newTestResourceQuota returns a quota that enforces default constraints for
2435
2446
// testing.
2436
- func newTestResourceQuota (name string , size string , scName string ) * v1.ResourceQuota {
2437
- hard := v1.ResourceList {}
2438
- // Test quota on discovered resource type.
2439
- hard [v1 .ResourceName (scName + rqStorageType )] = resource .MustParse (size )
2440
- return & v1.ResourceQuota {
2441
- ObjectMeta : metav1.ObjectMeta {Name : name },
2442
- Spec : v1.ResourceQuotaSpec {Hard : hard },
2443
- }
2444
- }
2447
+ // func newTestResourceQuota(name string, size string, scName string) *v1.ResourceQuota {
2448
+ // hard := v1.ResourceList{}
2449
+ // // Test quota on discovered resource type.
2450
+ // hard[v1.ResourceName(scName+rqStorageType)] = resource.MustParse(size)
2451
+ // return &v1.ResourceQuota{
2452
+ // ObjectMeta: metav1.ObjectMeta{Name: name},
2453
+ // Spec: v1.ResourceQuotaSpec{Hard: hard},
2454
+ // }
2455
+ // }
2445
2456
2446
2457
// updatedSpec4ExistingResourceQuota returns a quota that enforces default
2447
2458
// constraints for testing.
0 commit comments