Skip to content

Commit 202a630

Browse files
authored
Merge pull request #4882 from camilamacedo86/test-fix-2
🌱 (ci) fix: e2e tests by adding sleep before metrics access to handle K8s 1.33 cert delay
2 parents b9c3ab6 + 66e1ab1 commit 202a630

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

test/e2e/v4/plugin_cluster_test.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,19 @@ var _ = Describe("kubebuilder", func() {
9191
GenerateV4WithoutMetrics(kbc)
9292
Run(kbc, true, false, false, false, false)
9393
})
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+
})
10198
It("should generate a runnable project with webhooks and metrics protected by network policies", func() {
10299
GenerateV4WithNetworkPolicies(kbc)
103100
Run(kbc, true, false, false, true, true)
104101
})
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+
})
113107
})
114108
})
115109

@@ -518,6 +512,16 @@ func getMetricsOutput(kbc *utils.TestContext) string {
518512
Eventually(checkServiceEndpoint, 2*time.Minute, time.Second).Should(Succeed(),
519513
"Service endpoint should be ready")
520514

515+
// NOTE: On Kubernetes 1.33+, we've observed a delay before the metrics endpoint becomes available
516+
// when using controller-runtime's WithAuthenticationAndAuthorization() with self-signed certificates.
517+
// This delay appears to stem from Kubernetes itself, potentially due to changes in how it initializes
518+
// service account tokens or handles TLS/service readiness.
519+
//
520+
// Without this delay, tests that curl the /metrics endpoint using a token can fail from k8s 1.33+.
521+
// As a temporary workaround, we wait briefly before attempting to access metrics.
522+
By("waiting briefly to ensure that the certs are provisioned and metrics are available")
523+
time.Sleep(15 * time.Second)
524+
521525
By("creating a curl pod to access the metrics endpoint")
522526
cmdOpts := cmdOptsToCreateCurlPod(kbc, token)
523527
_, err = kbc.Kubectl.CommandInNamespace(cmdOpts...)

0 commit comments

Comments
 (0)