add jaeger check: to confirm whether the jaeger injector pod is in running state or not (#5528)

Currently, the linkerd jaeger check runs multiple checks but it doesn't have a check to confirm the state of the jaeger injector to be running.

This commit adds that required check to confirm the running state of the jaeger injector pod.

Fixes #5495

Signed-off-by: Yashvardhan Kukreja <yash.kukreja.98@gmail.com>
This commit is contained in:
Yashvardhan Kukreja 2021-01-19 08:35:16 +05:30 committed by GitHub
parent c416e78261
commit b67bbe157b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

View File

@ -65,7 +65,7 @@ func jaegerCategory(hc *healthcheck.HealthChecker) (*healthcheck.Category, error
checkers = append(checkers,
*healthcheck.NewChecker("collector pod is running").
WithHintAnchor("l5d-jaeger-collector-running").
Warning().
Fatal().
WithRetryDeadline(hc.RetryDeadline).
SurfaceErrorOnRetry().
WithCheck(func(ctx context.Context) error {
@ -74,13 +74,13 @@ func jaegerCategory(hc *healthcheck.HealthChecker) (*healthcheck.Category, error
if err != nil {
return err
}
return healthcheck.CheckPodsRunning(podList.Items)
return healthcheck.CheckPodsRunning(podList.Items, fmt.Sprintf("No collector pods found in the %s namespace", namespace))
}))
checkers = append(checkers,
*healthcheck.NewChecker("jaeger pod is running").
WithHintAnchor("l5d-jaeger-jaeger-running").
Warning().
Fatal().
WithRetryDeadline(hc.RetryDeadline).
SurfaceErrorOnRetry().
WithCheck(func(ctx context.Context) error {
@ -89,7 +89,22 @@ func jaegerCategory(hc *healthcheck.HealthChecker) (*healthcheck.Category, error
if err != nil {
return err
}
return healthcheck.CheckPodsRunning(podList.Items)
return healthcheck.CheckPodsRunning(podList.Items, fmt.Sprintf("No jaeger pods found in the %s namespace", namespace))
}))
checkers = append(checkers,
*healthcheck.NewChecker("jaeger injector pod is running").
WithHintAnchor("l5d-jaeger-jaeger-running").
Fatal().
WithRetryDeadline(hc.RetryDeadline).
SurfaceErrorOnRetry().
WithCheck(func(ctx context.Context) error {
// Check for Jaeger Injector pod
podList, err := kubeAPI.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{LabelSelector: "component=jaeger-injector"})
if err != nil {
return err
}
return healthcheck.CheckPodsRunning(podList.Items, fmt.Sprintf("No jaeger injector pods found in the %s namespace", namespace))
}))
checkers = append(checkers,
@ -97,7 +112,7 @@ func jaegerCategory(hc *healthcheck.HealthChecker) (*healthcheck.Category, error
WithHintAnchor("l5d-jaeger-pods-injection").
Warning().
WithCheck(func(ctx context.Context) error {
// Check for Jaeger pod
// Check if Jaeger Extension pods have been injected
pods, err := kubeAPI.GetPodsByNamespace(ctx, jaegerNamespace)
if err != nil {
return err

View File

@ -2595,7 +2595,10 @@ func CheckForPods(pods []corev1.Pod, deployNames []string) error {
}
// CheckPodsRunning checks if the given pods are in running state
func CheckPodsRunning(pods []corev1.Pod) error {
func CheckPodsRunning(pods []corev1.Pod, podsNotFoundMsg string) error {
if len(pods) == 0 && podsNotFoundMsg != "" {
return fmt.Errorf(podsNotFoundMsg)
}
for _, pod := range pods {
if pod.Status.Phase != "Running" {
return fmt.Errorf("%s status is %s", pod.Name, pod.Status.Phase)

View File

@ -146,7 +146,7 @@ func vizCategory(hc *healthcheck.HealthChecker) *healthcheck.Category {
return err
}
return healthcheck.CheckPodsRunning(pods)
return healthcheck.CheckPodsRunning(pods, "")
}))
checkers = append(checkers,