Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat CustomKubeletIdentityMissingPermissionError as retryable #3286

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package customizations
import (
"context"
"fmt"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/core"
theunrepentantgeek marked this conversation as resolved.
Show resolved Hide resolved
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice"
Expand Down Expand Up @@ -181,3 +182,43 @@ func clusterProvisioningStateBlocksReconciliation(provisioningState *string) boo

return !nonBlockingManagedClusterProvisioningStates.Contains(strings.ToLower(*provisioningState))
}

var _ extensions.ErrorClassifier = &ManagedClusterExtension{}

// ClassifyError evaluates the provided error, returning including whether it is fatal or can be retried.
// cloudError is the error returned from ARM.
// apiVersion is the ARM API version used for the request.
// log is a logger than can be used for telemetry.
// next is the next implementation to call.
func (ext *ManagedClusterExtension) ClassifyError(
cloudError *genericarmclient.CloudError,
apiVersion string,
log logr.Logger,
next extensions.ErrorClassifierFunc,
) (core.CloudErrorDetails, error) {
details, err := next(cloudError)
if err != nil {
return core.CloudErrorDetails{}, err
}

// Override is to treat Conflict as retryable for Redis, if the message contains "try again later"
theunrepentantgeek marked this conversation as resolved.
Show resolved Hide resolved
if isRetryableClusterError(cloudError) {
details.Classification = core.ErrorRetryable
}

return details, nil
}

func isRetryableClusterError(err *genericarmclient.CloudError) bool {
if err == nil {
return false
}

// A CustomKubeletIdentityMissingPermissionError can occur if the user-assigned identity required by the cluster
// hasn't yet been provisioned; we want to retry so that we finish provisioning the cluster once it is available.
if err.Code() == "CustomKubeletIdentityMissingPermissionError" {
return true
}

return false
}