Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(local-snapshot-restore, velero) : support to restore local snapshot to different namespace using velero #1575

Merged
merged 13 commits into from
Mar 26, 2020

Conversation

mynktl
Copy link
Contributor

@mynktl mynktl commented Jan 6, 2020

Ref: openebs/openebs#2844

Changes:

  • Added support to restore local snapshot to different namespace using velero-plugin. Restored PV (and cstorVolume) will have cstor-clone- prefix.

Sample output:

kubectl get pv 
NAME                                               CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                         STORAGECLASS           REASON   AGE
cstor-clone-37458540-3bc4-42ae-b0ba-57ba116bb72f   5G         RWO            Delete           Bound    ns2/demo-cstor-vol-claim-1    openebs-cstor-sparse            5m55s
cstor-clone-7db69671-1243-4d96-99f7-7041ad9f3c2b   5G         RWO            Delete           Bound    ns1/demo-cstor-vol-claim-1    openebs-cstor-sparse            10s
pvc-109d7f73-699c-11ea-9326-42010a9a0064           5G         RWO            Delete           Bound    test/demo-cstor-vol-claim-1   openebs-cstor-sparse            3h52m

In above output, first two PVs are created from pvc-109d7f73-699c-11ea-9326-42010a9a0064 PV.

PVC output:

kubectl get pvc -A 
NAMESPACE   NAME                     STATUS   VOLUME                                             CAPACITY   ACCESS MODES   STORAGECLASS           AGE
ns1         demo-cstor-vol-claim-1   Bound    cstor-clone-7db69671-1243-4d96-99f7-7041ad9f3c2b   5G         RWO            openebs-cstor-sparse   18s
ns2         demo-cstor-vol-claim-1   Bound    cstor-clone-37458540-3bc4-42ae-b0ba-57ba116bb72f   5G         RWO            openebs-cstor-sparse   6m3s
test        demo-cstor-vol-claim-1   Bound    pvc-109d7f73-699c-11ea-9326-42010a9a0064           5G         RWO            openebs-cstor-sparse   3h52m

CStorVolume output:

kubectl get cstorvolume -n openebs
NAME                                               STATUS    AGE     CAPACITY
cstor-clone-37458540-3bc4-42ae-b0ba-57ba116bb72f   Healthy   13m     5G
cstor-clone-7db69671-1243-4d96-99f7-7041ad9f3c2b   Healthy   8m13s   5G
pvc-109d7f73-699c-11ea-9326-42010a9a0064           Healthy   4h      5G

For documentation:

  • For local snapshot(or remote backup) CV, related to PV, must be in healthy state.
  • If local snapshot( or remote backup) failed then check the backup logs for the error:
    error taking snapshot of volume: rpc error: code = Unknown desc = Failed to send backup request: Error calling REST api: Status error{Bad Request}

@mynktl mynktl changed the title fix(restore, velero) : using volume API to create a volume during velero restore [WIP]fix(restore, velero) : using volume API to create a volume during velero restore Feb 3, 2020
@mynktl mynktl modified the milestones: 1.7.0, 1.9 Mar 17, 2020
@mynktl mynktl changed the title [WIP]fix(restore, velero) : using volume API to create a volume during velero restore fix(local-snapshot-restore, velero) : support to restore local snapshot to different snapshot using velero Mar 19, 2020
@mynktl mynktl requested a review from vishnuitta March 19, 2020 08:42
@mynktl mynktl changed the title fix(local-snapshot-restore, velero) : support to restore local snapshot to different snapshot using velero feat(local-snapshot-restore, velero) : support to restore local snapshot to different snapshot using velero Mar 19, 2020
@mynktl mynktl requested a review from prateekpandey14 March 19, 2020 09:29
@mynktl
Copy link
Contributor Author

mynktl commented Mar 19, 2020

@prateekpandey14 Can you verify https://github.com/openebs/maya/pull/1575/files#diff-861ad0cc410461be20924c447e61bc86R281. I am creating volume through pkg/volume/volume.go. If i remember correctly, you are calling this volume creation API multiple times through provisioner. Do i need to add similar behavior here?

@mynktl mynktl requested a review from kmova March 20, 2020 06:49
@prateekpandey14 prateekpandey14 changed the title feat(local-snapshot-restore, velero) : support to restore local snapshot to different snapshot using velero feat(local-snapshot-restore, velero) : support to restore local snapshot to different namespace using velero Mar 24, 2020
@@ -62,7 +64,7 @@ func (rOps *restoreAPIOps) create() (interface{}, error) {
}

// namespace is expected
if len(strings.TrimSpace(restore.Namespace)) == 0 {
if !restore.Spec.Local && len(strings.TrimSpace(restore.Namespace)) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we throw error if Local and NameSpace is NOT 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of local We are not using namespace. We are ignoring it so skipped the check.

Copy link
Contributor

@vishnuitta vishnuitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things like adding comments, testcases are required. Overall flow looks to be good, however one more round of review need to be done.
APIs are changed however backup compatibility is maintained.
This involves good amount of changes with respect to approach as well. Now, storage classes with 'WatiForFirstConsumer' may not work. So, its better to get into the early cycles of testing.
Approving this in order to get into early cycles of testing.

@kmova
Copy link
Contributor

kmova commented Mar 25, 2020

@mynktl - can you verify that mayactl volume list works with cloned volumes being present.

Though there is not a lot of information obtained by looking at mayactl volume list for cstor volumes, it should not result in - inability to fetch the jiva volumes list, as it is the only way to know the status of jiva volumes.

If there are issue listing the cStor volumes - we can raise another PR to deprecate including cStor volumes in the mayactl volume list

@kmova
Copy link
Contributor

kmova commented Mar 25, 2020

In addition to @vishnuitta comments, this PR also will need to document the following:

  • Cases / Pre-requisites for this feature to work.
  • For instance
    • If the volume is not healthy, how is the snapshot failure communicated?
    • If volume is healthy with two replicas, and snapshot is taken, what will happen when the a new Replica gets added and a clone request comes before the Replica had a chance to rebuild.

@kmova kmova added pr/documentation-pending pr/release-note PR should be included in release notes pr/hold-merge Hold on the merge to complete few activities. labels Mar 25, 2020
Copy link
Contributor

@kmova kmova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are good.

A few follow-up items are mentioned as review comments, once they are verified and backlogs are created, the merge can proceed.

return nil, errors.Wrapf(err, "Failed to get restore volume details")
}
} else {
return cvol, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this possible in case of cloud backup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, In case of cloud backups we are creating volume through PVC from velero-plugin. So this will return the existing volume. Added comment.

return cvol, nil
}

return vOps.Create()
Copy link
Contributor

@vishnuitta vishnuitta Mar 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be for local backup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It serves for local and cloud backup. As of now we are creating volume through PVC from velero-plugin in case of remote restore So this will not execute for remote backup. #1575 (comment)

@mynktl
Copy link
Contributor Author

mynktl commented Mar 26, 2020

@kmova

  • For jiva volumes with mayactl We already have a test case which uses mayactl to fetch volumes.
  • For CStor volumes I verified locally.
bash-4.3# /tmp/mayactl  volume list --volname cstor-clone-d1a8fdce-30e0-4df5-b616-97a05192ed71
Namespace  Name                                              Status   Type   Capacity  StorageClass          Access Mode
---------  ----                                              ------   ----   --------  -------------         -----------
openebs    cstor-clone-d1a8fdce-30e0-4df5-b616-97a05192ed71  Running  cstor  5G        openebs-cstor-sparse  ReadWriteOnce
openebs    pvc-559e2dc4-6f3b-11ea-86cd-d89c67d5e4a1          Running  cstor  5G        openebs-cstor-sparse  ReadWriteOnce
bash-4.3# /tmp/mayactl  volume stats --volname pvc-559e2dc4-6f3b-11ea-86cd-d89c67d5e4a1 --namespace openebs
 
Portal Details :
---------------
Volume  :   pvc-559e2dc4-6f3b-11ea-86cd-d89c67d5e4a1
Size    :   5.000000

Performance Stats :
--------------------
r/s      w/s      r(MB/s)      w(MB/s)      rLat(ms)      wLat(ms)
----     ----     --------     --------     ---------     ---------
0        0        0.000        0.000        0.000         0.000    

Capacity Stats :
---------------
LOGICAL(GB)      USED(GB)
------------     ---------
0.000            0.000    
bash-4.3# /tmp/mayactl  volume stats --volname cstor-clone-d1a8fdce-30e0-4df5-b616-97a05192ed71 --namespace openebs 
 
Portal Details :
---------------
Volume  :   cstor-clone-d1a8fdce-30e0-4df5-b616-97a05192ed71
Size    :   5.000000

Performance Stats :
--------------------
r/s      w/s      r(MB/s)      w(MB/s)      rLat(ms)      wLat(ms)
----     ----     --------     --------     ---------     ---------
0        0        0.000        0.000        0.000         0.000    

Capacity Stats :
---------------
LOGICAL(GB)      USED(GB)
------------     ---------

@mynktl
Copy link
Contributor Author

mynktl commented Mar 26, 2020

For documentation I've covered it in openebs/velero-plugin#53.

@mynktl
Copy link
Contributor Author

mynktl commented Mar 26, 2020

@kmova @vishnuitta PTAL. I've addressed the review comments.

@kmova kmova merged commit 7daa3c6 into openebs-archive:master Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/documentation-pending pr/hold-merge Hold on the merge to complete few activities. pr/release-note PR should be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants