Skip to content

Commit

Permalink
fix(cstor-restore): fixing restore api to return failure if cstorrest…
Browse files Browse the repository at this point in the history
…ore is in invalid state (#1682)

This PR updates the REST api for cstore restore to report failure if cstorrestore resource is in invalid state. There is one additional change in restore controller in cstor-pool-mgmt to ignore the update if cstorrestore CR is having state Done or Failed

Following tests were executed with this change:
Restart the cstor-pool pod when restore is in-progress state
- outcome is restore failed
Restart the cstor-pool pod before it process the cstorrestore CR
- outcome is restore failed
Restart the cstor-pool pod once it update the cstorrestore CR to init state
- outcome is restore failed
Restart the cstor-pool pod once the restore completes
- outcome is cstorrestore status remains same

Signed-off-by: mayank <mayank.patel@mayadata.io>
  • Loading branch information
mynktl authored May 5, 2020
1 parent 36f188d commit 220895a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/1682-mynktl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix(cstor-restore): fixing restore api to return failure if cstorrestore is in invalid state
4 changes: 4 additions & 0 deletions cmd/cstor-pool-mgmt/controller/restore/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/maya-apiserver/app/server/restore_endpoint_v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 220895a

Please sign in to comment.