@@ -91,25 +91,19 @@ var _ = Describe("kubebuilder", func() {
91
91
GenerateV4WithoutMetrics (kbc )
92
92
Run (kbc , true , false , false , false , false )
93
93
})
94
- // FIXME: This test is currently disabled because it requires to be fixed:
95
- // https://github.com/kubernetes-sigs/kubebuilder/issues/4853
96
- // It is not working for k8s 1.33
97
- // It("should generate a runnable project with metrics protected by network policies", func() {
98
- // GenerateV4WithNetworkPoliciesWithoutWebhooks(kbc)
99
- // Run(kbc, false, false, false, true, true)
100
- // })
94
+ It ("should generate a runnable project with metrics protected by network policies" , func () {
95
+ GenerateV4WithNetworkPoliciesWithoutWebhooks (kbc )
96
+ Run (kbc , false , false , false , true , true )
97
+ })
101
98
It ("should generate a runnable project with webhooks and metrics protected by network policies" , func () {
102
99
GenerateV4WithNetworkPolicies (kbc )
103
100
Run (kbc , true , false , false , true , true )
104
101
})
105
- // FIXME: This test is currently disabled because it requires to be fixed:
106
- // https://github.com/kubernetes-sigs/kubebuilder/issues/4853
107
- // It is not working for k8s 1.33
108
- // It("should generate a runnable project with the manager running "+
109
- // "as restricted and without webhooks", func() {
110
- // GenerateV4WithoutWebhooks(kbc)
111
- // Run(kbc, false, false, false, true, false)
112
- // })
102
+ It ("should generate a runnable project with the manager running " +
103
+ "as restricted and without webhooks" , func () {
104
+ GenerateV4WithoutWebhooks (kbc )
105
+ Run (kbc , false , false , false , true , false )
106
+ })
113
107
})
114
108
})
115
109
@@ -525,24 +519,57 @@ func getMetricsOutput(kbc *utils.TestContext) string {
525
519
526
520
By ("validating that the curl pod is running as expected" )
527
521
verifyCurlUp := func (g Gomega ) {
528
- var status string
529
- status , err = kbc .Kubectl .Get (
530
- true ,
531
- "pods" , "curl" , "-o" , "jsonpath={.status.phase}" )
522
+ maxRetries := 3
523
+ var status , logs string
524
+
525
+ for i := 0 ; i < maxRetries ; i ++ {
526
+ status , err = kbc .Kubectl .Get (
527
+ true ,
528
+ "pods" , "curl" , "-o" , "jsonpath={.status.phase}" )
529
+ g .Expect (err ).NotTo (HaveOccurred ())
530
+
531
+ if status == "Succeeded" {
532
+ return
533
+ }
534
+
535
+ logs , _ = kbc .Kubectl .Logs ("curl" )
536
+
537
+ if status == "Failed" ||
538
+ strings .Contains (logs , "Failed to connect" ) ||
539
+ strings .Contains (logs , "Connection refused" ) {
540
+ By ("Outputting curl pod logs for debugging" )
541
+ _ , _ = fmt .Fprintln (GinkgoWriter , logs )
542
+
543
+ By ("Outputting manager pod logs for debugging" )
544
+ controllerPodName := getControllerName (kbc )
545
+ managerLogs , _ := kbc .Kubectl .Logs (controllerPodName )
546
+ _ , _ = fmt .Fprintln (GinkgoWriter , managerLogs )
547
+
548
+ By ("Describing all resources for debugging" )
549
+ out , errDescribe := kbc .Kubectl .CommandInNamespace ("describe" , "all" )
550
+ Expect (errDescribe ).NotTo (HaveOccurred ())
551
+ _ , _ = fmt .Fprintln (GinkgoWriter , out )
552
+
553
+ By (fmt .Sprintf ("curl pod failed with status %s. Retrying (%d/%d)..." , status , i + 1 , maxRetries ))
554
+ _ , _ = kbc .Kubectl .Delete (true , "pod" , "curl" , "--ignore-not-found" ,
555
+ "--grace-period=0" , "--force" )
556
+ time .Sleep (3 * time .Second )
557
+
558
+ cmdOpts = cmdOptsToCreateCurlPod (kbc , token )
559
+ _ , err = kbc .Kubectl .CommandInNamespace (cmdOpts ... )
560
+ g .Expect (err ).NotTo (HaveOccurred ())
561
+
562
+ time .Sleep (5 * time .Second )
563
+ } else {
564
+ By (fmt .Sprintf ("curl pod in %s state without known failure, waiting..." , status ))
565
+ time .Sleep (5 * time .Second )
566
+ }
567
+ }
568
+ status , err = kbc .Kubectl .Get (true , "pods" , "curl" , "-o" , "jsonpath={.status.phase}" )
532
569
g .Expect (err ).NotTo (HaveOccurred ())
533
- g .Expect (status ).To (Equal ("Succeeded" ), fmt .Sprintf ("curl pod in %s status " , status ))
570
+ g .Expect (status ).To (Equal ("Succeeded" ), fmt .Sprintf ("curl pod in %s state after all retries " , status ))
534
571
}
535
- Eventually (verifyCurlUp , 240 * time .Second , time .Second ).Should (Succeed ())
536
-
537
- By ("validating that the correct ServiceAccount is being used" )
538
- saName := kbc .Kubectl .ServiceAccount
539
- currentSAOutput , err := kbc .Kubectl .Get (
540
- true ,
541
- "serviceaccount" , saName ,
542
- "-o" , "jsonpath={.metadata.name}" ,
543
- )
544
- Expect (err ).NotTo (HaveOccurred (), "Failed to fetch the service account" )
545
- Expect (currentSAOutput ).To (Equal (saName ), "The ServiceAccount in use does not match the expected one" )
572
+ Eventually (verifyCurlUp , 2 * time .Minute , time .Second ).Should (Succeed ())
546
573
547
574
By ("validating that the metrics endpoint is serving as expected" )
548
575
getCurlLogs := func (g Gomega ) {
0 commit comments