Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jpayne3506 committed Jan 24, 2024
1 parent 09cb12f commit 4612a41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions test/internal/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ func RestartKubeProxyService(ctx context.Context, clientset *kubernetes.Clientse
return errors.Wrapf(err, "failed to get privileged pod on node %s", node.Name)
}

if len(pod.Items) == 0 {
return errors.Errorf("there are no privileged pods on node - %v", node.Name)
}
privilegedPod := pod.Items[0]
// exec into the pod and restart kubeproxy
_, err = ExecCmdOnPod(ctx, clientset, privilegedNamespace, privilegedPod.Name, restartKubeProxyCmd, config)
Expand Down
6 changes: 4 additions & 2 deletions test/validate/linux_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ func (v *Validator) validateRestartNetwork(ctx context.Context) error {
continue
}
// get the privileged pod
pod, err := acnk8s.GetPodsByNode(ctx, v.clientset, privilegedNamespace, privilegedLabelSelector, nodes.Items[index].Name)
pod, err := acnk8s.GetPodsByNode(ctx, v.clientset, privilegedNamespace, privilegedLabelSelector, node.Name)
if err != nil {
return errors.Wrapf(err, "failed to get privileged pod")
}

if len(pod.Items) == 0 {
return errors.Errorf("there are no privileged pods on node - %v", node.Name)
}
privilegedPod := pod.Items[0]
// exec into the pod to get the state file
_, err = acnk8s.ExecCmdOnPod(ctx, v.clientset, privilegedNamespace, privilegedPod.Name, restartNetworkCmd, v.config)
Expand Down
14 changes: 7 additions & 7 deletions test/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ func CreateValidator(ctx context.Context, clientset *kubernetes.Clientset, confi
switch os {
case "windows":
checks = windowsChecksMap[cni]
case "linux":
checks = linuxChecksMap[cni]
default:
return nil, errors.Errorf("unsupported os: %s", os)
}

if os == "windows" {
err := acnk8s.RestartKubeProxyService(ctx, clientset, privilegedNamespace, privilegedLabelSelector, config)
if err != nil {
return nil, errors.Wrapf(err, "failed to restart kubeproxy")
}
case "linux":
checks = linuxChecksMap[cni]
default:
return nil, errors.Errorf("unsupported os: %s", os)
}

return &Validator{
Expand Down Expand Up @@ -138,6 +135,9 @@ func (v *Validator) validateIPs(ctx context.Context, stateFileIps stateFileIpsFu
if err != nil {
return errors.Wrapf(err, "failed to get privileged pod")
}
if len(pod.Items) == 0 {
return errors.Errorf("there are no privileged pods on node - %v", nodes.Items[index].Name)
}
podName := pod.Items[0].Name
// exec into the pod to get the state file
result, err := acnk8s.ExecCmdOnPod(ctx, v.clientset, namespace, podName, cmd, v.config)
Expand Down
4 changes: 3 additions & 1 deletion test/validate/windows_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ func validateHNSNetworkState(ctx context.Context, nodes *corev1.NodeList, client
if err != nil {
return errors.Wrap(err, "failed to get privileged pod")
}

if len(pod.Items) == 0 {
return errors.Errorf("there are no privileged pods on node - %v", nodes.Items[index].Name)
}
podName := pod.Items[0].Name
// exec into the pod to get the state file
result, err := acnk8s.ExecCmdOnPod(ctx, clientset, privilegedNamespace, podName, hnsNetworkCmd, restConfig)
Expand Down

0 comments on commit 4612a41

Please sign in to comment.