From 7654658851e4844316198b2e6ca1bcf083c9db29 Mon Sep 17 00:00:00 2001 From: mayank Date: Tue, 5 May 2020 19:33:26 +0530 Subject: [PATCH 1/2] restore api to return failure if cstorrestore is in invalid state Signed-off-by: mayank --- cmd/cstor-pool-mgmt/controller/restore/handler.go | 4 ++++ cmd/maya-apiserver/app/server/restore_endpoint_v1alpha1.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/cstor-pool-mgmt/controller/restore/handler.go b/cmd/cstor-pool-mgmt/controller/restore/handler.go index f046f0bf94..0fea3d9e63 100644 --- a/cmd/cstor-pool-mgmt/controller/restore/handler.go +++ b/cmd/cstor-pool-mgmt/controller/restore/handler.go @@ -44,6 +44,10 @@ func (c *RestoreController) syncHandler(key string, operation common.QueueOperat return fmt.Errorf("can not retrieve CStorRestore %q", key) } + if IsDoneStatus(rst) || IsFailedStatus(rst) { + return nil + } + status, err := c.rstEventHandler(operation, rst) if status == "" { return nil diff --git a/cmd/maya-apiserver/app/server/restore_endpoint_v1alpha1.go b/cmd/maya-apiserver/app/server/restore_endpoint_v1alpha1.go index 8fe9dbdaae..455baf8021 100644 --- a/cmd/maya-apiserver/app/server/restore_endpoint_v1alpha1.go +++ b/cmd/maya-apiserver/app/server/restore_endpoint_v1alpha1.go @@ -230,7 +230,7 @@ func getRestoreStatus(rst *v1alpha1.CStorRestore) (v1alpha1.CStorRestoreStatus, switch rstStatus { case v1alpha1.RSTCStorStatusInProgress: rstStatus = v1alpha1.RSTCStorStatusInProgress - case v1alpha1.RSTCStorStatusFailed: + case v1alpha1.RSTCStorStatusFailed, v1alpha1.RSTCStorStatusInvalid: if nr.Status != rstStatus { // Restore for given CVR may failed due to node failure or pool failure // Let's update status for given CVR's restore to failed From b2f934af67e173e45a4857298d589ae39dc6acb5 Mon Sep 17 00:00:00 2001 From: mayank Date: Tue, 5 May 2020 19:45:19 +0530 Subject: [PATCH 2/2] adding changelog Signed-off-by: mayank --- changelogs/unreleased/1682-mynktl | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/unreleased/1682-mynktl diff --git a/changelogs/unreleased/1682-mynktl b/changelogs/unreleased/1682-mynktl new file mode 100644 index 0000000000..5aae11bc35 --- /dev/null +++ b/changelogs/unreleased/1682-mynktl @@ -0,0 +1 @@ +fix(cstor-restore): fixing restore api to return failure if cstorrestore is in invalid state