From c8159de7871408add804d9002ac83f35472eb183 Mon Sep 17 00:00:00 2001 From: Grant Griffiths Date: Tue, 1 Oct 2019 14:39:06 -0700 Subject: [PATCH] Update cloud migrate group backup access denied message Signed-off-by: Grant Griffiths --- api/server/sdk/cloud_backup.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/server/sdk/cloud_backup.go b/api/server/sdk/cloud_backup.go index 86ba86ba6..21f6937fb 100644 --- a/api/server/sdk/cloud_backup.go +++ b/api/server/sdk/cloud_backup.go @@ -18,6 +18,7 @@ package sdk import ( "context" + "fmt" "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/volume" @@ -150,6 +151,20 @@ func (s *CloudBackupServer) GroupCreate( Id: req.GetGroupId(), }, }, api.Ownership_Read); err != nil { + statusError, ok := status.FromError(err) + if ok && statusError.Code() == codes.PermissionDenied { + var locatorContents string + switch { + case len(req.GetLabels()) > 0 && len(req.GetGroupId()) > 0: + locatorContents = fmt.Sprintf("labels %s and group ID %s", req.GetLabels(), req.GetGroupId()) + case len(req.GetLabels()) > 0: + locatorContents = fmt.Sprintf("labels %s", req.GetLabels()) + case len(req.GetGroupId()) > 0: + locatorContents = fmt.Sprintf("group ID %s", req.GetGroupId()) + } + return nil, status.Errorf(codes.PermissionDenied, "Access denied to at least one volume with %s", locatorContents) + } + return nil, err } }