From 93d4042fdae5de65c24eef3af7a598550bf162fc Mon Sep 17 00:00:00 2001 From: Grant Griffiths Date: Wed, 2 Oct 2019 17:04:48 -0700 Subject: [PATCH] Update cloud migrate group backup access denied message (#1261) 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 } }