forked from Azure/azure-service-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes Azure#4057
- Loading branch information
Showing
89 changed files
with
69,354 additions
and
10,913 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
v2/api/compute/customizations/disk_access_extension_types_gen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 6 additions & 2 deletions
8
v2/api/compute/customizations/disk_encryption_set_extension_types_gen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT license. | ||
*/ | ||
|
||
package customizations | ||
|
||
import ( | ||
"regexp" | ||
|
||
"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 = &DiskExtension{} | ||
|
||
// diskAccessNotFoundRegex matches the error returned by CRP when the DiskAccess doesn't exist yet. | ||
var diskAccessNotFoundRegex = regexp.MustCompile("DiskAccess.*not found") | ||
|
||
// diskAccessFailedStateRegex matches the error returned by CRP when a DiskAccess is not in successful state yet. | ||
// Note that even though this says failed, this is returned even if the resource is in a transitioning state (and | ||
// will succeed eventually) | ||
var diskAccessFailedStateRegex = regexp.MustCompile("DiskAccess.*is in failed state.") | ||
|
||
//var retryableList = []*regexp.Regexp{ | ||
// diskAccessNotFoundRegex, | ||
// diskAccessFailedStateRegex, | ||
//} | ||
|
||
// ClassifyError evaluates the provided error, returning whether it is fatal or can be retried. | ||
func (e *DiskExtension) 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 the DiskAccess doesn't exist yet, we retry as it may be being created | ||
if retryable(details) { | ||
details.Classification = core.ErrorRetryable | ||
} | ||
|
||
return details, nil | ||
} | ||
|
||
func retryable(details core.CloudErrorDetails) bool { | ||
if details.Code == "BadRequest" && diskAccessNotFoundRegex.MatchString(details.Message) { | ||
return true | ||
} | ||
|
||
if details.Code == "Conflict" && diskAccessFailedStateRegex.MatchString(details.Message) { | ||
return true | ||
} | ||
|
||
return false | ||
} |
8 changes: 6 additions & 2 deletions
8
v2/api/compute/customizations/snapshot_extension_types_gen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.