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(migrate): add support for cstor volume migration #9

Merged
merged 5 commits into from
Jun 12, 2020

Conversation

shubham14bajpai
Copy link
Contributor

Signed-off-by: shubham [email protected]

This PR adds support Cstor volume migration from external provisioner volume spec to CSI volume spec.

Example yaml:

---
apiVersion: batch/v1
kind: Job
metadata:
  name: migrate-pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7
  namespace: openebs
spec:
  backoffLimit: 0
  template:
    spec:
      #VERIFY the value of serviceAccountName is pointing to service account
      # created within openebs namespace. Use the non-default account.
      # by running `kubectl get sa -n <openebs-namespace>`
      serviceAccountName: openebs-maya-operator
      containers:
      - name:  migrate
        args:
        - "cstor-volume"
        # name of the volume that is to be migrated
        - "--pv-name=pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7"

        #Following are optional parameters
        #Log Level
        - "--v=4"
        #DO NOT CHANGE BELOW PARAMETERS
        env:
        - name: OPENEBS_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        tty: true
        image: openebs/migrate-amd64:ci
      restartPolicy: Never
---

Example logs:

mayadata:setup$ k logs -f migrate-pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7-qwbrl
I0604 09:17:07.857403       1 cstor_volume.go:73] Migrating volume pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7 to csi spec
I0604 09:17:07.887308       1 volume.go:709] Creating temporary policy pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7 for migration
I0604 09:17:07.906579       1 volume.go:130] Checking volume is not mounted on any application
I0604 09:17:08.031803       1 volume.go:136] Retaining PV to migrate into csi volume
I0604 09:17:08.045848       1 volume.go:444] Updating storageclass openebs-cstor-override-ns with csi parameters
I0604 09:17:08.206131       1 volume.go:187] Generating equivalent CSI PVC
I0604 09:17:08.219053       1 volume.go:193] Recreating equivalent CSI PVC
I0604 09:17:13.388287       1 volume.go:203] Generating equivalent CSI PV
I0604 09:17:13.398245       1 volume.go:209] Recreating equivalent CSI PV
I0604 09:17:18.687862       1 volume.go:644] creating target service pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7 in openebs namespace
I0604 09:17:18.722439       1 volume.go:166] Creating CVC to bound the volume and trigger CSI driver
I0604 09:17:18.749838       1 volume.go:403] Patching the target svc with cvc owner ref
I0604 09:17:18.768170       1 volume.go:765] Validating the migrated volume
I0604 09:17:18.768194       1 volume.go:770] Waiting for cvrs to come to Healthy state
I0604 09:17:23.876711       1 volume.go:770] Waiting for cvrs to come to Healthy state
I0604 09:17:24.144843       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:29.150333       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:34.166534       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:39.332978       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:44.340519       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:49.344701       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:54.348128       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:17:59.351107       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:18:04.387127       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:18:09.389766       1 volume.go:797] Waiting for cv to come to Healthy state
I0604 09:18:09.433507       1 volume.go:849] Cleaning up old volume resources
I0604 09:18:09.588986       1 cstor_volume.go:80] Successfully migrated volume pvc-b12c1a29-3144-4ac9-8b89-2c1ff4998dc7

Copy link

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

Yet to review from migratePV

pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
},
}
if targetDeploy.Spec.Template.Spec.Affinity != nil {
tempPolicy.Spec.Target.PodAffinity = targetDeploy.Spec.Template.Spec.Affinity.PodAffinity

Choose a reason for hiding this comment

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

Do we need to handle nodeAffinity also?
cc: @prateekpandey14

pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
Copy link

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

Provided comments

pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
if pvObj.Spec.PersistentVolumeSource.CSI == nil {
csiPV := &corev1.PersistentVolume{}
csiPV.Name = pvObj.Name
csiPV.Annotations = map[string]string{

Choose a reason for hiding this comment

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

If user-configured labels and annotations for some other purpose we will lose them

pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
 - adds code to patch skip-validation annotation
 - improves wait mechanism for validations after migration due to time
taking rebuilds
 - address review comments

Signed-off-by: shubham <[email protected]>
@shubham14bajpai
Copy link
Contributor Author

@mittachaitu Addressed the review comments. Will take label and annotation literal changes as well as snapshot migration in separate PR.

pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
pkg/migrate/cstor/volume.go Outdated Show resolved Hide resolved
pkg/migrate/cstor/volume.go Show resolved Hide resolved
Copy link

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

}
if cvcObj.Status.Phase != cstor.CStorVolumeConfigPhaseBound {
klog.Infof("Waiting for cvc %s to become Bound, got: %s", v.PVName, cvcObj.Status.Phase)
time.Sleep(10 * time.Second)

Choose a reason for hiding this comment

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

This is sleep time is much high we can change it to 3 seconds

pkg/migrate/cstor/volume.go Show resolved Hide resolved
Signed-off-by: shubham <[email protected]>
Copy link

@prateekpandey14 prateekpandey14 left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants