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 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