Skip to content

Commit

Permalink
Improve bucket/folder creation
Browse files Browse the repository at this point in the history
Disable input notifications when output bucket/folders fail
  • Loading branch information
srisco committed Jul 30, 2020
1 parent 44818a6 commit 6eb3c35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pkg/handlers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func createBuckets(service *types.Service, cfg *types.Config) error {

// Check if the provider identifier is defined in StorageProviders
if !isStorageProviderDefined(provName, provID, service.StorageProviders) {
disableInputNotifications(service.GetMinIOWebhookARN(), service.Input, cfg.MinIOProvider)
return fmt.Errorf("The StorageProvider \"%s.%s\" is not defined", provName, provID)
}

Expand All @@ -246,9 +247,11 @@ func createBuckets(service *types.Service, cfg *types.Config) error {
if aerr.Code() == s3.ErrCodeBucketAlreadyExists || aerr.Code() == s3.ErrCodeBucketAlreadyOwnedByYou {
log.Printf("The bucket \"%s\" already exists\n", splitPath[0])
} else {
disableInputNotifications(service.GetMinIOWebhookARN(), service.Input, cfg.MinIOProvider)
return fmt.Errorf("Error creating bucket %s: %v", splitPath[0], err)
}
} else {
disableInputNotifications(service.GetMinIOWebhookARN(), service.Input, cfg.MinIOProvider)
return fmt.Errorf("Error creating bucket %s: %v", splitPath[0], err)
}
}
Expand All @@ -261,15 +264,19 @@ func createBuckets(service *types.Service, cfg *types.Config) error {
Key: aws.String(folderKey),
})
if err != nil {
disableInputNotifications(service.GetMinIOWebhookARN(), service.Input, cfg.MinIOProvider)
return fmt.Errorf("Error creating folder \"%s\" in bucket \"%s\": %v", folderKey, splitPath[0], err)
}
}
case types.OnedataName:
cdmiClient = service.StorageProviders.Onedata[provID].GetCDMIClient()
err := cdmiClient.CreateContainer(fmt.Sprintf("%s/%s", service.StorageProviders.Onedata[provID].Space, path), true)
if err != nil {
if err != cdmi.ErrBadRequest {
if err == cdmi.ErrBadRequest {
log.Printf("Error creating \"%s\" folder in Onedata. Error: %v\n", path, err)
} else {
disableInputNotifications(service.GetMinIOWebhookARN(), service.Input, cfg.MinIOProvider)
return fmt.Errorf("Error connecting to Onedata's Oneprovider \"%s\". Error: %v", service.StorageProviders.Onedata[provID].OneproviderHost, err)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
// OnedataName string representing the Onedata provider name
OnedataName = "onedata"

// ProviderSeparator separator character used for split provider's name and identifier
// ProviderSeparator separator character used to split provider's name and identifier
ProviderSeparator = "."
)

Expand Down

0 comments on commit 6eb3c35

Please sign in to comment.