diff --git a/azure/services/vmextensions/vmextensions.go b/azure/services/vmextensions/vmextensions.go index a19694eb53a..b5fe35dbfee 100644 --- a/azure/services/vmextensions/vmextensions.go +++ b/azure/services/vmextensions/vmextensions.go @@ -19,9 +19,8 @@ package vmextensions import ( "context" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-04-01/compute" - "github.com/Azure/go-autorest/autorest/to" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -34,9 +33,7 @@ const serviceName = "vmextensions" type VMExtensionScope interface { azure.Authorizer azure.AsyncStatusUpdater - azure.ClusterDescriber VMExtensionSpecs() []azure.ResourceSpecGetter - SetBootstrapConditions(context.Context, string, string) error } // Service provides operations on Azure resources. @@ -77,25 +74,21 @@ func (s *Service) Reconcile(ctx context.Context) error { // Order of precedence (highest -> lowest) is: error that is not an operationNotDoneError (i.e. error creating) -> operationNotDoneError (i.e. creating in progress) -> no error (i.e. created) var resultErr error for _, extensionSpec := range specs { - result, err := s.CreateResource(ctx, extensionSpec, serviceName) + _, err := s.CreateResource(ctx, extensionSpec, serviceName) if err != nil { if !azure.IsOperationNotDoneError(err) || resultErr == nil { resultErr = err } - } else { - vmextension, ok := result.(compute.VirtualMachineExtension) - if !ok { - return errors.Errorf("%T is not a compute.VirtualMachineExtension", result) - } - - // check the extension status and set the associated conditions. - if retErr := s.Scope.SetBootstrapConditions(ctx, to.String(vmextension.ProvisioningState), extensionSpec.ResourceName()); retErr != nil { - // TODO: what precedence should this error have? - return retErr - } } } + if azure.IsOperationNotDoneError(resultErr) { + resultErr = errors.Wrapf(resultErr, "extension is still in provisioning state. This likely means that bootstrapping has not yet completed on the VM") + } else if resultErr != nil { + resultErr = errors.Wrapf(resultErr, "extension state failed. This likely means the Kubernetes node bootstrapping process failed or timed out. Check VM boot diagnostics logs to learn more") + } + + s.Scope.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, resultErr) return resultErr }