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

CIF - ServerError: storage.AccountsClient#ListAccountSAS: TooManyRequests #3298

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions pkg/api/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const (
CloudErrorCodeScopeLocked = "ScopeLocked"
CloudErrorCodeRequestDisallowedByPolicy = "RequestDisallowedByPolicy"
CloudErrorCodeInvalidNetworkAddress = "InvalidNetworkAddress"
CloudErrorCodeThrottlingLimitExceeded = "ThrottlingLimitExceeded"
)

// NewCloudError returns a new CloudError
Expand Down
28 changes: 27 additions & 1 deletion pkg/util/storage/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package storage

import (
"context"
"net/http"
"net/url"
"time"

Expand All @@ -13,6 +14,7 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"

"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/storage"
)
Expand All @@ -33,6 +35,30 @@ func NewManager(env env.Core, subscriptionID string, authorizer autorest.Authori
}
}

func getCorrectErrWhenTooManyRequests(err error) error {
detailedError, ok := err.(autorest.DetailedError)
if !ok {
return err
}
if detailedError.StatusCode != http.StatusTooManyRequests {
return err
}
msg := "Requests are being throttled due to Azure Storage limits being exceeded. Please visit https://learn.microsoft.com/en-us/azure/openshift/troubleshoot#exceeding-azure-storage-limits for more details."
cloudError := &api.CloudError{
StatusCode: http.StatusTooManyRequests,
CloudErrorBody: &api.CloudErrorBody{
Code: api.CloudErrorCodeThrottlingLimitExceeded,
Message: "ThrottlingLimitExceeded",
Details: []api.CloudErrorBody{
{
Message: msg,
},
},
},
}
return cloudError
}

func (m *manager) BlobService(ctx context.Context, resourceGroup, account string, p mgmtstorage.Permissions, r mgmtstorage.SignedResourceTypes) (*azstorage.BlobStorageClient, error) {
t := time.Now().UTC().Truncate(time.Second)
res, err := m.storageAccounts.ListAccountSAS(ctx, resourceGroup, account, mgmtstorage.AccountSasParameters{
Expand All @@ -44,7 +70,7 @@ func (m *manager) BlobService(ctx context.Context, resourceGroup, account string
SharedAccessExpiryTime: &date.Time{Time: t.Add(24 * time.Hour)},
})
if err != nil {
return nil, err
return nil, getCorrectErrWhenTooManyRequests(err)
}

v, err := url.ParseQuery(*res.AccountSasToken)
Expand Down
Loading