Skip to content

Commit

Permalink
wrap all resolv.conf job steps in eventually
Browse files Browse the repository at this point in the history
  • Loading branch information
tsatam committed Feb 7, 2024
1 parent a6cd697 commit 3c0a29b
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions test/e2e/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
)

var (
nameserverRegex = regexp.MustCompile("nameserver [0-9.]*")
verifyResolvConfTimeout = 5 * time.Minute
verifyResolvConfPollInterval = 1 * time.Second
nodesReadyPollInterval = 2 * time.Second
nicUpdateWaitTime = 5 * time.Second
nameserverRegex = regexp.MustCompile("nameserver [0-9.]*")
resolvConfJobIsCompleteTimeout = 2 * time.Minute
resolvConfJobIsCompletePolling = 5 * time.Second
verifyResolvConfTimeout = 30 * time.Second
verifyResolvConfPollInterval = 1 * time.Second
nodesReadyPollInterval = 2 * time.Second
nicUpdateWaitTime = 5 * time.Second
)

const (
Expand Down Expand Up @@ -147,6 +149,7 @@ var _ = Describe("ARO cluster DNS", func() {
By("verifying each worker node's resolv.conf via a one-shot Job per node")
for wn, ip := range workerNodes {
createResolvConfJob(ctx, clients.Kubernetes, wn, testNamespace)
resolvConfJobIsComplete(ctx, clients.Kubernetes, wn, testNamespace)

Eventually(verifyResolvConf).
WithContext(ctx).
Expand Down Expand Up @@ -193,6 +196,7 @@ var _ = Describe("ARO cluster DNS", func() {

for wn, ip := range workerNodes {
createResolvConfJob(ctx, clients.Kubernetes, wn, testNamespace)
resolvConfJobIsComplete(ctx, clients.Kubernetes, wn, testNamespace)

Eventually(verifyResolvConf).
WithContext(ctx).
Expand Down Expand Up @@ -293,6 +297,20 @@ func createResolvConfJob(ctx context.Context, cli kubernetes.Interface, nodeName
CreateK8sObjectWithRetry(ctx, cli.BatchV1().Jobs(namespace).Create, job, metav1.CreateOptions{})
}

func resolvConfJobIsComplete(ctx context.Context, cli kubernetes.Interface, nodeName string, namespace string) {
Eventually(func(ctx context.Context) (bool, error) {
job, err := cli.BatchV1().Jobs(namespace).Get(ctx, resolvConfJobName(nodeName), metav1.GetOptions{})
if err != nil {
return false, err
}
return job.Status.Succeeded == 1, nil
}).
WithContext(ctx).
WithTimeout(resolvConfJobIsCompleteTimeout).
WithPolling(resolvConfJobIsCompletePolling).
Should(BeTrue())
}

func deleteResolvConfJob(ctx context.Context, cli kubernetes.Interface, nodeName string, namespace string) {
dpb := metav1.DeletePropagationBackground
deleteFunc := cli.BatchV1().Jobs(namespace).Delete
Expand Down

0 comments on commit 3c0a29b

Please sign in to comment.