From 15050911748a87903994afeb14258dcec20c8316 Mon Sep 17 00:00:00 2001 From: Matthew Christopher Date: Thu, 3 Aug 2023 07:55:59 -0700 Subject: [PATCH] SQL error classification improvement The "PasswordNotComplex" error should be treated as fatal --- .../customizations/server_extension_types.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 v2/api/sql/customizations/server_extension_types.go diff --git a/v2/api/sql/customizations/server_extension_types.go b/v2/api/sql/customizations/server_extension_types.go new file mode 100644 index 00000000000..f60bf687b83 --- /dev/null +++ b/v2/api/sql/customizations/server_extension_types.go @@ -0,0 +1,38 @@ +/* +Copyright (c) Microsoft Corporation. +Licensed under the MIT license. +*/ + +package customizations + +import ( + "github.com/go-logr/logr" + + "github.com/Azure/azure-service-operator/v2/internal/genericarmclient" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime/core" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime/extensions" +) + +var _ extensions.ErrorClassifier = &ServerExtension{} + +// ClassifyError evaluates the provided error, returning 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 (e *ServerExtension) 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 + } + + if cloudError.Code() == "PasswordNotComplex" { + details.Classification = core.ErrorFatal + } + + return details, nil +}