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

azurerm_storage_account - fix error handling for static_website and queue_properties availability checks #28279

Merged
merged 1 commit into from
Dec 13, 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
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func NewDataPlaneStaticWebsiteAvailabilityPoller(ctx context.Context, client *st
func (d *DataPlaneStaticWebsiteAvailabilityPoller) Poll(ctx context.Context) (*pollers.PollResult, error) {
resp, err := d.client.GetServiceProperties(ctx, d.storageAccountId.StorageAccountName)
if err != nil {
if !response.WasNotFound(resp.HttpResponse) {
if resp.HttpResponse == nil {
return nil, pollers.PollingDroppedConnectionError{
Message: err.Error(),
}
if resp.HttpResponse == nil {
return nil, pollers.PollingDroppedConnectionError{
Message: err.Error(),
}
}
if !response.WasNotFound(resp.HttpResponse) {
return nil, pollers.PollingFailedError{
Message: err.Error(),
HttpResponse: &client.Response{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ func connectionError(e error) bool {
return true
}

return regexp.MustCompile(`dial tcp .*:`).MatchString(e.Error()) || regexp.MustCompile(`EOF$`).MatchString(e.Error())
return regexp.MustCompile(`dial tcp`).MatchString(e.Error()) || regexp.MustCompile(`EOF$`).MatchString(e.Error())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package storage

import (
"errors"
"testing"
)

func TestConnectionError(t *testing.T) {
testcases := []struct {
Name string
Error error
ShouldMatch bool
}{
{
Name: "No Route TO Host",
Error: errors.New("dial tcp: connecting to example.blob.core.windows.net no route to host"),
ShouldMatch: true,
},
{
Name: "DNS No Such Host",
Error: errors.New("dial tcp: lookup example.blob.core.windows.net on 10.0.0.1:53: no such host"),
ShouldMatch: true,
},
{
Name: "Proxy Dropped",
Error: errors.New("EOF"),
ShouldMatch: true,
},
}

for _, tc := range testcases {
if connectionError(tc.Error) != tc.ShouldMatch {
t.Errorf("expected %s to match but it did not", tc.Name)
}
}
}
Loading