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

return the detailed error when the connection fails #1648

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion component/azstorage/azstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (az *AzStorage) configureAndTest(isParent bool) error {
err = az.storage.TestPipeline()
if err != nil {
log.Err("AzStorage::configureAndTest : Failed to validate credentials [%s]", err.Error())
return fmt.Errorf("failed to authenticate credentials for %s", az.Name())
return fmt.Errorf("failed to authenticate credentials for %s, [%s]", az.Name(), err.Error())
}
}

Expand Down
7 changes: 5 additions & 2 deletions component/azstorage/block_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"syscall"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
Expand Down Expand Up @@ -199,8 +200,10 @@ func (bb *BlockBlob) TestPipeline() error {
// we are just validating the auth mode used. So, no need to iterate over the pages
_, err := listBlobPager.NextPage(context.Background())
if err != nil {
log.Err("BlockBlob::TestPipeline : Failed to validate account with given auth %s", err.Error)
return err
var respErr *azcore.ResponseError
errors.As(err, &respErr)
log.Err("BlockBlob::TestPipeline : Failed to validate account with given auth %s", err.Error())
return fmt.Errorf("BlockBlob: [%s]", respErr.ErrorCode)
}

return nil
Expand Down
13 changes: 13 additions & 0 deletions component/azstorage/block_blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,19 @@ func (s *blockBlobTestSuite) TestNoEndpoint() {
s.assert.Nil(err)
}

func (s *blockBlobTestSuite) TestContainerNotFound() {
defer s.cleanupTest()
// Setup
s.tearDownTestHelper(false) // Don't delete the generated container.
config := fmt.Sprintf("azstorage:\n account-name: %s\n type: block\n account-key: %s\n mode: key\n container: %s\n fail-unsupported-op: true",
storageTestConfigurationParameters.BlockAccount, storageTestConfigurationParameters.BlockKey, "foo")
s.setupTestHelper(config, "foo", false)

err := s.az.storage.TestPipeline()
s.assert.NotNil(err)
s.assert.Contains(err.Error(), "ContainerNotFound")
}

func (s *blockBlobTestSuite) TestListContainers() {
defer s.cleanupTest()
// Setup
Expand Down
7 changes: 5 additions & 2 deletions component/azstorage/datalake.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package azstorage

import (
"context"
"errors"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -199,8 +200,10 @@ func (dl *Datalake) TestPipeline() error {
// we are just validating the auth mode used. So, no need to iterate over the pages
_, err := listPathPager.NextPage(context.Background())
if err != nil {
log.Err("Datalake::TestPipeline : Failed to validate account with given auth %s", err.Error)
return err
var respErr *azcore.ResponseError
errors.As(err, &respErr)
log.Err("Datalake::TestPipeline : Failed to validate account with given auth %s", err.Error())
return fmt.Errorf("Datalake: [%s]", respErr.ErrorCode)
}

return dl.BlockBlob.TestPipeline()
Expand Down
13 changes: 13 additions & 0 deletions component/azstorage/datalake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ func (s *datalakeTestSuite) TestNoEndpoint() {
s.assert.Nil(err)
}

func (s *datalakeTestSuite) TestFileSystemNotFound() {
defer s.cleanupTest()
// Setup
s.tearDownTestHelper(false) // Don't delete the generated container.
config := fmt.Sprintf("azstorage:\n account-name: %s\n type: adls\n account-key: %s\n mode: key\n container: %s\n fail-unsupported-op: true",
storageTestConfigurationParameters.AdlsAccount, storageTestConfigurationParameters.AdlsKey, "foo")
s.setupTestHelper(config, "foo", false)

err := s.az.storage.TestPipeline()
s.assert.NotNil(err)
s.assert.Contains(err.Error(), "FilesystemNotFound")
}

func (s *datalakeTestSuite) TestListContainers() {
defer s.cleanupTest()
// Setup
Expand Down
Loading