Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kagenti-operator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ func main() {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("webhook", webhookServer.StartedChecker()); err != nil {
setupLog.Error(err, "unable to set up webhook ready check")
os.Exit(1)
}

setupLog.Info("starting manager")
if err := mgr.Start(ctx); err != nil {
Expand Down
35 changes: 35 additions & 0 deletions kagenti-operator/test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ var _ = Describe("AuthBridge Injection E2E", Ordered, func() {
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("creating auth bridge test namespace")
cmd := exec.Command("kubectl", "create", "ns", authBridgeTestNamespace)
_, err := utils.Run(cmd)
Expand Down Expand Up @@ -696,6 +701,11 @@ var _ = Describe("AgentCard E2E", Ordered, func() {
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("creating test namespace with labels")
cmd := exec.Command("kubectl", "create", "ns", testNamespace)
_, err := utils.Run(cmd)
Expand Down Expand Up @@ -1039,6 +1049,11 @@ rules:
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("creating test namespace")
cmd := exec.Command("kubectl", "create", "ns", agentRuntimeTestNamespace)
_, err := utils.Run(cmd)
Expand Down Expand Up @@ -1513,6 +1528,11 @@ rules:
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("setting KAGENTI_SPIRE_TRUST_DOMAIN env var")
envCmd := exec.Command("kubectl", "set", "env", "deployment/"+controllerDeployment,
"-n", controllerNamespace, "KAGENTI_SPIRE_TRUST_DOMAIN=example.org")
Expand Down Expand Up @@ -1974,6 +1994,11 @@ rules:
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("creating skill discovery test namespace")
cmd := exec.Command("kubectl", "create", "ns", skillDiscoveryTestNamespace)
_, err := utils.Run(cmd)
Expand Down Expand Up @@ -2134,6 +2159,11 @@ rules:
g.Expect(err).NotTo(HaveOccurred())
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready after restart")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())
})

It("should populate linkedSkills from annotation", func() {
Expand Down Expand Up @@ -2438,6 +2468,11 @@ var _ = Describe("Istio Mesh Enrollment E2E", Ordered, func() {
g.Expect(output).NotTo(BeEmpty(), "webhook endpoint not yet populated")
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("waiting for controller pod to be fully Ready")
Eventually(func() error {
return utils.ProbeWebhookReady(controllerNamespace)
}, 2*time.Minute, 2*time.Second).Should(Succeed())

By("creating test namespace")
cmd := exec.Command("kubectl", "create", "ns", istioMeshTestNamespace)
_, err := utils.Run(cmd)
Expand Down
16 changes: 16 additions & 0 deletions kagenti-operator/test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,3 +751,19 @@ func UncommentCode(filename, target, prefix string) error {
// nolint:gosec
return os.WriteFile(filename, out.Bytes(), 0644)
}

// ProbeWebhookReady checks that the controller pod is fully Ready.
// The readyz endpoint gates on webhookServer.StartedChecker(), so Ready
// means the webhook TLS server is accepting connections on :9443.
func ProbeWebhookReady(namespace string) error {
cmd := exec.Command("kubectl", "wait",
"--for=condition=Ready",
"pod", "-l", "control-plane=controller-manager",
"-n", namespace,
"--timeout=5s")
_, err := Run(cmd)
if err != nil {
return fmt.Errorf("controller pod not yet Ready: %w", err)
}
return nil
}
Loading