diff --git a/internal/services/storage/custompollers/data_plane_static_website_availability_poller.go b/internal/services/storage/custompollers/data_plane_static_website_availability_poller.go index 9f4f4f718c2e..2857ef8f8fc4 100644 --- a/internal/services/storage/custompollers/data_plane_static_website_availability_poller.go +++ b/internal/services/storage/custompollers/data_plane_static_website_availability_poller.go @@ -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{ diff --git a/internal/services/storage/storage_account_data_plane_helpers.go b/internal/services/storage/storage_account_data_plane_helpers.go index db974e3a51df..ae4977f916be 100644 --- a/internal/services/storage/storage_account_data_plane_helpers.go +++ b/internal/services/storage/storage_account_data_plane_helpers.go @@ -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()) } diff --git a/internal/services/storage/storage_account_data_plane_helpers_test.go b/internal/services/storage/storage_account_data_plane_helpers_test.go new file mode 100644 index 000000000000..217fb8f8113b --- /dev/null +++ b/internal/services/storage/storage_account_data_plane_helpers_test.go @@ -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) + } + } +}