Skip to content

Commit

Permalink
Fix wait conditions (kubernetes-sigs#198)
Browse files Browse the repository at this point in the history
* Fix unmanaged control planes wait

* Increase calico wait

* Fix wait conditions

* Update changelog
  • Loading branch information
kahun authored Jul 6, 2023
1 parent 9aa17fd commit b1303e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 0.17.0-0.3.0 (Upcoming)

* Fix wait conditions for unmanaged clusters

## 0.17.0-0.2.0 (2023-07-03)

* Add clusterAPI capabilities for AKS
Expand Down
17 changes: 3 additions & 14 deletions pkg/cluster/internal/create/actions/createworker/createworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,17 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
}

if provider.capxProvider != "azure" || !keosCluster.Spec.ControlPlane.Managed {
// Wait for the worker cluster creation
c = "kubectl -n " + capiClustersNamespace + " wait --for=condition=ready --timeout=15m --all md"
// Wait for all the machine deployments to be ready
c = "kubectl -n " + capiClustersNamespace + " wait --for=condition=Ready --timeout=15m --all md"
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "failed to create the worker Cluster")
}
}

if !keosCluster.Spec.ControlPlane.Managed && keosCluster.Spec.ControlPlane.HighlyAvailable {
// Wait for all control planes creation
c = "kubectl -n " + capiClustersNamespace + " wait --for=condition=ControlPlaneReady --timeout 10m cluster " + keosCluster.Metadata.Name
if err != nil {
return errors.Wrap(err, "failed to create the worker Cluster")
}
// Wait for all control planes to be ready
c = "kubectl -n " + capiClustersNamespace + " wait --for=jsonpath=\"{.status.unavailableReplicas}\"=0 --timeout 10m --all kubeadmcontrolplanes"
c = "kubectl -n " + capiClustersNamespace + " wait --for=jsonpath=\"{.status.readyReplicas}\"=3 --timeout 10m kubeadmcontrolplanes " + keosCluster.Metadata.Name + "-control-plane"
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "failed to create the worker Cluster")
Expand Down Expand Up @@ -545,12 +540,6 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
ctx.Status.Start("Creating cloud-provisioner Objects backup 🗄️")
defer ctx.Status.End(false)

c = "kubectl wait --for=condition=Ready -n " + capiClustersNamespace + " cluster " + keosCluster.Metadata.Name + " --timeout 15m"
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "timeout to cluster condition ready")
}

if _, err := os.Stat(localBackupPath); os.IsNotExist(err) {
if err := os.MkdirAll(localBackupPath, 0755); err != nil {
return errors.Wrap(err, "failed to create local backup directory")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func installCalico(n nodes.Node, k string, keosCluster commons.KeosCluster, allo
}

// Wait for calico-system namespace to be created
c = "timeout 30s bash -c 'until kubectl --kubeconfig " + kubeconfigPath + " get ns calico-system; do sleep 2s ; done'"
c = "timeout 60s bash -c 'until kubectl --kubeconfig " + kubeconfigPath + " get ns calico-system; do sleep 2s ; done'"
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "failed to wait for calico-system namespace")
Expand Down

0 comments on commit b1303e2

Please sign in to comment.