Skip to content

Commit

Permalink
azurerm_storage_account - fix error handling for static_website a…
Browse files Browse the repository at this point in the history
…nd `queue_properties` availability checks (hashicorp#28279)
  • Loading branch information
jackofallops authored Dec 13, 2024
1 parent e751874 commit 14f86b4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
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)
}
}
}

0 comments on commit 14f86b4

Please sign in to comment.