Browse Source

Fixing AKS creation failure

When the capz.kubeconfig file was missing, the creation of AKS cluster
by the bootstrap container would fail when retrieving its kubeconfig
file. The issue was that the container tries to delete an existing
kubeconfig file and would fail if it didn't exist.

The fix was to check if the kubeconfig file existed prior to deleting
it.

Change-Id: Ibf135a11ae1928fc69c35cacdf0e1339629027f2
changes/19/769819/1
Sidney Shiba 7 months ago
parent
commit
a13dbd0dd1
  1. 11
      bootstrap_capz/config/aks_cluster.go

11
bootstrap_capz/config/aks_cluster.go

@ -136,10 +136,13 @@ func prepareAKSCluster(azConfig *AzureConfig, isCreate bool) error {
kubeconfig := dstMount + "/" + kubeconfigFile
// Delete existing Kubeconfig file, if any
err = os.Remove(kubeconfig)
if err != nil {
log.Printf("Failed to remove existing kubeconfig file %s.\n", kubeconfig)
return err
_, err = os.Stat(kubeconfig)
if err == nil {
err = os.Remove(kubeconfig)
if err != nil {
log.Printf("Failed to remove existing kubeconfig file %s.\n", kubeconfig)
return err
}
}
// Retrieving the Kubeconfig file for the cluster

Loading…
Cancel
Save