зеркало из https://github.com/Azure/ARO-RP.git
Merge pull request #2359 from carvalhe/asyncDelete_newCloudError
CloudError added for clusterDelete
This commit is contained in:
Коммит
0f950d78f1
|
@ -96,7 +96,8 @@ const (
|
||||||
CloudErrorCodeDuplicateDomain = "DuplicateDomain"
|
CloudErrorCodeDuplicateDomain = "DuplicateDomain"
|
||||||
CloudErrorCodeResourceQuotaExceeded = "ResourceQuotaExceeded"
|
CloudErrorCodeResourceQuotaExceeded = "ResourceQuotaExceeded"
|
||||||
CloudErrorCodeQuotaExceeded = "QuotaExceeded"
|
CloudErrorCodeQuotaExceeded = "QuotaExceeded"
|
||||||
CloudErrorResourceProviderNotRegistered = "ResourceProviderNotRegistered"
|
CloudErrorCodeResourceProviderNotRegistered = "ResourceProviderNotRegistered"
|
||||||
|
CloudErrorCodeCannotDeleteLoadBalancerByID = "CannotDeleteLoadBalancerWithPrivateLinkService"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCloudError returns a new CloudError
|
// NewCloudError returns a new CloudError
|
||||||
|
|
|
@ -34,7 +34,7 @@ func (dv *dynamic) ValidateProviders(ctx context.Context) error {
|
||||||
} {
|
} {
|
||||||
if providerMap[provider].RegistrationState == nil ||
|
if providerMap[provider].RegistrationState == nil ||
|
||||||
*providerMap[provider].RegistrationState != "Registered" {
|
*providerMap[provider].RegistrationState != "Registered" {
|
||||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorResourceProviderNotRegistered, "", "The resource provider '%s' is not registered.", provider)
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeResourceProviderNotRegistered, "", "The resource provider '%s' is not registered.", provider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ func (m *manager) deleteResources(ctx context.Context) error {
|
||||||
m.log.Printf("deleting %s", *resource.ID)
|
m.log.Printf("deleting %s", *resource.ID)
|
||||||
future, err := m.resources.DeleteByID(ctx, *resource.ID, apiVersion)
|
future, err := m.resources.DeleteByID(ctx, *resource.ID, apiVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return deleteByIdCloudError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
futures = append(futures, future)
|
futures = append(futures, future)
|
||||||
|
@ -251,6 +251,23 @@ func (m *manager) deleteResources(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteByIdCloudError(err error) error {
|
||||||
|
detailedError, ok := err.(autorest.DetailedError)
|
||||||
|
if !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case strings.Contains(detailedError.Original.Error(), "CannotDeleteLoadBalancerWithPrivateLinkService"):
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeCannotDeleteLoadBalancerByID,
|
||||||
|
"features.ResourcesClient#DeleteByID", detailedError.Original.Error())
|
||||||
|
|
||||||
|
case strings.Contains(detailedError.Original.Error(), "AuthorizationFailed"):
|
||||||
|
return api.NewCloudError(http.StatusForbidden, api.CloudErrorCodeForbidden,
|
||||||
|
"features.ResourcesClient#DeleteByID", detailedError.Original.Error())
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (m *manager) deleteRoleAssignments(ctx context.Context) error {
|
func (m *manager) deleteRoleAssignments(ctx context.Context) error {
|
||||||
resourceGroupID := m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID
|
resourceGroupID := m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID
|
||||||
resourceGroup := stringutils.LastTokenByte(m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID, '/')
|
resourceGroup := stringutils.LastTokenByte(m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID, '/')
|
||||||
|
|
Загрузка…
Ссылка в новой задаче