Skip to content

Commit

Permalink
Adding loop retry for strictAffinity
Browse files Browse the repository at this point in the history
  • Loading branch information
knabben committed Apr 7, 2024
1 parent 7f8245a commit 7478467
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions pkg/pwsh/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ func (r *Runner) InstallCNI(calicoVersion, cpKubernetes, controlPlaneIP string)
{"kubectl", "create", "-f", "./specs/installation.yaml"},
{"kubectl", "create", "-f", cpTempFile},
{"kubectl", "create", "-f", kpTempFile},
{"sleep 10"},
{"kubectl", "patch", "ipamconfig", "default", "--type", "merge", "--patch=" + string(templates.GetSpecAffinity())},
}

for i := 0; i <= len(steps)-1; i++ {
cmd := strings.Join(steps[i], " ")
resc.Printf("Running: %v\n", cmd)
Expand All @@ -254,5 +253,20 @@ func (r *Runner) InstallCNI(calicoVersion, cpKubernetes, controlPlaneIP string)
}
}

// strictAffinity exists after the Installation object ready, this can take a while
// try in loop each 10 seconds.
loop:
for {
select {
case <-time.After(10 * time.Second):
cmd := []string{"kubectl", "patch", "ipamconfig", "default", "--type", "merge", "--patch='" + string(templates.GetSpecAffinity()) + "'"}
if err := r.runL(strings.Join(cmd, " ")); err != nil {
bad.Printf("calico error: %v\n", err)
} else {
break loop
}
}
}

return nil
}
2 changes: 1 addition & 1 deletion samples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
calicoVersion: v3.27.3
controlPlane:
kubernetesVersion: v1.28.3
minikube: false
minikube: true
workload:
containerdVersion: 1.7.14
kubernetesVersion: v1.29.0
Expand Down

0 comments on commit 7478467

Please sign in to comment.