Skip to content

Commit

Permalink
add calico-apiserver and tigera-operator to pod check
Browse files Browse the repository at this point in the history
  • Loading branch information
k8s-bot committed Jun 5, 2024
1 parent 1249628 commit 5b08693
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/k8s/pkg/k8sd/features/calico/status.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build moonray

package calico

import (
Expand All @@ -20,12 +18,24 @@ func CheckNetwork(ctx context.Context, snap snap.Snap) (bool, error) {
return false, fmt.Errorf("failed to create kubernetes client: %w", err)
}

operatorReady, err := client.IsPodReady(ctx, "kube-system", "tigera-operator", metav1.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to get calico pods: %w", err)
}
if !operatorReady {
return false, nil
}

calicoPods, err := client.ListPods(ctx, "calico-system", metav1.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to get calico pods: %w", err)
}
calicoApiserverPods, err := client.ListPods(ctx, "calico-apiserver", metav1.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to get calico-apiserver pods: %w", err)
}

for _, pod := range calicoPods {
for _, pod := range append(calicoPods, calicoApiserverPods...) {
isReady, err := client.IsPodReady(ctx, pod.Name, "calico-system", metav1.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to check if pod %q is ready: %w", pod.Name, err)
Expand Down

0 comments on commit 5b08693

Please sign in to comment.