Skip to content

Commit f130aac

Browse files
committed
[e2e] Fixing flakes in multigroup serve metrics
Fix flakes - 2 Run make generate RUn make generate Minor fix Minor fix Fix-2 Fix-3
1 parent dcb76da commit f130aac

File tree

7 files changed

+245
-0
lines changed

7 files changed

+245
-0
lines changed

docs/book/src/cronjob-tutorial/testdata/project/test/e2e/e2e_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,41 @@ var _ = Describe("Manager", Ordered, func() {
216216
}
217217
Eventually(verifyMetricsServerStarted).Should(Succeed())
218218

219+
By("waiting for webhook service to be ready if webhooks are configured")
220+
verifyWebhookServiceReady := func(g Gomega) {
221+
// Check if webhook service exists first
222+
cmd := exec.Command("kubectl", "get", "service", "project-webhook-service", "-n", namespace)
223+
_, err := utils.Run(cmd)
224+
if err != nil {
225+
// No webhook service found, skip webhook checks
226+
return
227+
}
228+
229+
// Check if webhook server is ready by verifying pod readiness
230+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
231+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
232+
output, err := utils.Run(cmd)
233+
g.Expect(err).NotTo(HaveOccurred())
234+
g.Expect(output).To(Equal("True"),
235+
"Controller manager pod not ready (webhook server may not be accepting connections)")
236+
237+
// Check if webhook service endpoints are available
238+
cmd = exec.Command("kubectl", "get", "endpoints", "project-webhook-service",
239+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
240+
output, err = utils.Run(cmd)
241+
g.Expect(err).NotTo(HaveOccurred())
242+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
243+
244+
// Test webhook connectivity by checking if webhook server port is responding
245+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
246+
"--image=curlimages/curl:latest", "--",
247+
"curl", "-k", "--connect-timeout", "5",
248+
"https://project-webhook-service."+namespace+".svc:443/readyz")
249+
_, err = utils.Run(cmd)
250+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
251+
}
252+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
253+
219254
By("creating the curl-metrics pod to access the metrics endpoint")
220255
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
221256
"--namespace", namespace,

docs/book/src/getting-started/testdata/project/test/e2e/e2e_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,41 @@ var _ = Describe("Manager", Ordered, func() {
211211
}
212212
Eventually(verifyMetricsServerStarted).Should(Succeed())
213213

214+
By("waiting for webhook service to be ready if webhooks are configured")
215+
verifyWebhookServiceReady := func(g Gomega) {
216+
// Check if webhook service exists first
217+
cmd := exec.Command("kubectl", "get", "service", "project-webhook-service", "-n", namespace)
218+
_, err := utils.Run(cmd)
219+
if err != nil {
220+
// No webhook service found, skip webhook checks
221+
return
222+
}
223+
224+
// Check if webhook server is ready by verifying pod readiness
225+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
226+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
227+
output, err := utils.Run(cmd)
228+
g.Expect(err).NotTo(HaveOccurred())
229+
g.Expect(output).To(Equal("True"),
230+
"Controller manager pod not ready (webhook server may not be accepting connections)")
231+
232+
// Check if webhook service endpoints are available
233+
cmd = exec.Command("kubectl", "get", "endpoints", "project-webhook-service",
234+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
235+
output, err = utils.Run(cmd)
236+
g.Expect(err).NotTo(HaveOccurred())
237+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
238+
239+
// Test webhook connectivity by checking if webhook server port is responding
240+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
241+
"--image=curlimages/curl:latest", "--",
242+
"curl", "-k", "--connect-timeout", "5",
243+
"https://project-webhook-service."+namespace+".svc:443/readyz")
244+
_, err = utils.Run(cmd)
245+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
246+
}
247+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
248+
214249
By("creating the curl-metrics pod to access the metrics endpoint")
215250
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
216251
"--namespace", namespace,

docs/book/src/multiversion-tutorial/testdata/project/test/e2e/e2e_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,41 @@ var _ = Describe("Manager", Ordered, func() {
216216
}
217217
Eventually(verifyMetricsServerStarted).Should(Succeed())
218218

219+
By("waiting for webhook service to be ready if webhooks are configured")
220+
verifyWebhookServiceReady := func(g Gomega) {
221+
// Check if webhook service exists first
222+
cmd := exec.Command("kubectl", "get", "service", "project-webhook-service", "-n", namespace)
223+
_, err := utils.Run(cmd)
224+
if err != nil {
225+
// No webhook service found, skip webhook checks
226+
return
227+
}
228+
229+
// Check if webhook server is ready by verifying pod readiness
230+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
231+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
232+
output, err := utils.Run(cmd)
233+
g.Expect(err).NotTo(HaveOccurred())
234+
g.Expect(output).To(Equal("True"),
235+
"Controller manager pod not ready (webhook server may not be accepting connections)")
236+
237+
// Check if webhook service endpoints are available
238+
cmd = exec.Command("kubectl", "get", "endpoints", "project-webhook-service",
239+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
240+
output, err = utils.Run(cmd)
241+
g.Expect(err).NotTo(HaveOccurred())
242+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
243+
244+
// Test webhook connectivity by checking if webhook server port is responding
245+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
246+
"--image=curlimages/curl:latest", "--",
247+
"curl", "-k", "--connect-timeout", "5",
248+
"https://project-webhook-service."+namespace+".svc:443/readyz")
249+
_, err = utils.Run(cmd)
250+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
251+
}
252+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
253+
219254
By("creating the curl-metrics pod to access the metrics endpoint")
220255
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
221256
"--namespace", namespace,

pkg/plugins/golang/v4/scaffolds/internal/templates/test/e2e/test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,41 @@ var _ = Describe("Manager", Ordered, func() {
394394
}
395395
Eventually(verifyMetricsServerStarted).Should(Succeed())
396396
397+
By("waiting for webhook service to be ready if webhooks are configured")
398+
verifyWebhookServiceReady := func(g Gomega) {
399+
// Check if webhook service exists first
400+
cmd := exec.Command("kubectl", "get", "service", "{{ .ProjectName }}-webhook-service", "-n", namespace)
401+
_, err := utils.Run(cmd)
402+
if err != nil {
403+
// No webhook service found, skip webhook checks
404+
return
405+
}
406+
407+
// Check if webhook server is ready by verifying pod readiness
408+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
409+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
410+
output, err := utils.Run(cmd)
411+
g.Expect(err).NotTo(HaveOccurred())
412+
g.Expect(output).To(Equal("True"),
413+
"Controller manager pod not ready (webhook server may not be accepting connections)")
414+
415+
// Check if webhook service endpoints are available
416+
cmd = exec.Command("kubectl", "get", "endpoints", "{{ .ProjectName }}-webhook-service",
417+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
418+
output, err = utils.Run(cmd)
419+
g.Expect(err).NotTo(HaveOccurred())
420+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
421+
422+
// Test webhook connectivity by checking if webhook server port is responding
423+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
424+
"--image=curlimages/curl:latest", "--",
425+
"curl", "-k", "--connect-timeout", "5",
426+
"https://{{ .ProjectName }}-webhook-service."+namespace+".svc:443/readyz")
427+
_, err = utils.Run(cmd)
428+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
429+
}
430+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
431+
397432
By("creating the curl-metrics pod to access the metrics endpoint")
398433
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
399434
"--namespace", namespace,

testdata/project-v4-multigroup/test/e2e/e2e_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,41 @@ var _ = Describe("Manager", Ordered, func() {
211211
}
212212
Eventually(verifyMetricsServerStarted).Should(Succeed())
213213

214+
By("waiting for webhook service to be ready if webhooks are configured")
215+
verifyWebhookServiceReady := func(g Gomega) {
216+
// Check if webhook service exists first
217+
cmd := exec.Command("kubectl", "get", "service", "project-v4-multigroup-webhook-service", "-n", namespace)
218+
_, err := utils.Run(cmd)
219+
if err != nil {
220+
// No webhook service found, skip webhook checks
221+
return
222+
}
223+
224+
// Check if webhook server is ready by verifying pod readiness
225+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
226+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
227+
output, err := utils.Run(cmd)
228+
g.Expect(err).NotTo(HaveOccurred())
229+
g.Expect(output).To(Equal("True"),
230+
"Controller manager pod not ready (webhook server may not be accepting connections)")
231+
232+
// Check if webhook service endpoints are available
233+
cmd = exec.Command("kubectl", "get", "endpoints", "project-v4-multigroup-webhook-service",
234+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
235+
output, err = utils.Run(cmd)
236+
g.Expect(err).NotTo(HaveOccurred())
237+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
238+
239+
// Test webhook connectivity by checking if webhook server port is responding
240+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
241+
"--image=curlimages/curl:latest", "--",
242+
"curl", "-k", "--connect-timeout", "5",
243+
"https://project-v4-multigroup-webhook-service."+namespace+".svc:443/readyz")
244+
_, err = utils.Run(cmd)
245+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
246+
}
247+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
248+
214249
By("creating the curl-metrics pod to access the metrics endpoint")
215250
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
216251
"--namespace", namespace,

testdata/project-v4-with-plugins/test/e2e/e2e_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,41 @@ var _ = Describe("Manager", Ordered, func() {
211211
}
212212
Eventually(verifyMetricsServerStarted).Should(Succeed())
213213

214+
By("waiting for webhook service to be ready if webhooks are configured")
215+
verifyWebhookServiceReady := func(g Gomega) {
216+
// Check if webhook service exists first
217+
cmd := exec.Command("kubectl", "get", "service", "project-v4-with-plugins-webhook-service", "-n", namespace)
218+
_, err := utils.Run(cmd)
219+
if err != nil {
220+
// No webhook service found, skip webhook checks
221+
return
222+
}
223+
224+
// Check if webhook server is ready by verifying pod readiness
225+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
226+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
227+
output, err := utils.Run(cmd)
228+
g.Expect(err).NotTo(HaveOccurred())
229+
g.Expect(output).To(Equal("True"),
230+
"Controller manager pod not ready (webhook server may not be accepting connections)")
231+
232+
// Check if webhook service endpoints are available
233+
cmd = exec.Command("kubectl", "get", "endpoints", "project-v4-with-plugins-webhook-service",
234+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
235+
output, err = utils.Run(cmd)
236+
g.Expect(err).NotTo(HaveOccurred())
237+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
238+
239+
// Test webhook connectivity by checking if webhook server port is responding
240+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
241+
"--image=curlimages/curl:latest", "--",
242+
"curl", "-k", "--connect-timeout", "5",
243+
"https://project-v4-with-plugins-webhook-service."+namespace+".svc:443/readyz")
244+
_, err = utils.Run(cmd)
245+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
246+
}
247+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
248+
214249
By("creating the curl-metrics pod to access the metrics endpoint")
215250
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
216251
"--namespace", namespace,

testdata/project-v4/test/e2e/e2e_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,41 @@ var _ = Describe("Manager", Ordered, func() {
211211
}
212212
Eventually(verifyMetricsServerStarted).Should(Succeed())
213213

214+
By("waiting for webhook service to be ready if webhooks are configured")
215+
verifyWebhookServiceReady := func(g Gomega) {
216+
// Check if webhook service exists first
217+
cmd := exec.Command("kubectl", "get", "service", "project-v4-webhook-service", "-n", namespace)
218+
_, err := utils.Run(cmd)
219+
if err != nil {
220+
// No webhook service found, skip webhook checks
221+
return
222+
}
223+
224+
// Check if webhook server is ready by verifying pod readiness
225+
cmd = exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager",
226+
"-n", namespace, "-o", "jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}")
227+
output, err := utils.Run(cmd)
228+
g.Expect(err).NotTo(HaveOccurred())
229+
g.Expect(output).To(Equal("True"),
230+
"Controller manager pod not ready (webhook server may not be accepting connections)")
231+
232+
// Check if webhook service endpoints are available
233+
cmd = exec.Command("kubectl", "get", "endpoints", "project-v4-webhook-service",
234+
"-n", namespace, "-o", "jsonpath={.subsets[*].addresses[*].ip}")
235+
output, err = utils.Run(cmd)
236+
g.Expect(err).NotTo(HaveOccurred())
237+
g.Expect(output).NotTo(BeEmpty(), "Webhook service endpoints are not ready")
238+
239+
// Test webhook connectivity by checking if webhook server port is responding
240+
cmd = exec.Command("kubectl", "run", "webhook-test", "--rm", "-i", "--restart=Never",
241+
"--image=curlimages/curl:latest", "--",
242+
"curl", "-k", "--connect-timeout", "5",
243+
"https://project-v4-webhook-service."+namespace+".svc:443/readyz")
244+
_, err = utils.Run(cmd)
245+
g.Expect(err).NotTo(HaveOccurred(), "Webhook server not responding on port 443")
246+
}
247+
Eventually(verifyWebhookServiceReady, 2*time.Minute).Should(Succeed())
248+
214249
By("creating the curl-metrics pod to access the metrics endpoint")
215250
cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never",
216251
"--namespace", namespace,

0 commit comments

Comments
 (0)