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 to rename spc while migrating to cspc #13

Merged
merged 6 commits into from
Jul 7, 2020

Conversation

shubham14bajpai
Copy link
Contributor

@shubham14bajpai shubham14bajpai commented Jul 1, 2020

Signed-off-by: shubham [email protected]

This PR adds the flag cspc-name to rename the spc while migrating it to cspc. It also adds checks to prevent deletion of a spc if already a cspc exists with the same name as spc.

This PR fixes this Issue: openebs/openebs#3074

Sample job yaml:

---
apiVersion: batch/v1
kind: Job
metadata:
  name: migrate-spc-sparse-claim-auto
  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-spc"
        # name of the spc that is to be migrated
        - "--spc-name=sparse-claim"
        # optional flag to rename the spc to a specific name
        - "--cspc-name=sparse-claim-migrated"

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

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

@mittachaitu mittachaitu requested a review from sonasingh46 July 2, 2020 06:12
@mittachaitu mittachaitu self-requested a review July 2, 2020 11:10
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 please take a look

pkg/migrate/cstor/pool.go Show resolved Hide resolved
pkg/migrate/cstor/pool.go Outdated Show resolved Hide resolved
if k8serrors.IsNotFound(err) {
return nil
}
if err == nil {

Choose a reason for hiding this comment

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

Now I have another concern with configuration if the user does in below manner:

  • The user has multiple SPCs in his setup and launched a job(By applying job YAML by setting cspc-name argument) to migrate to CSPC(Consider pool is successfully migrated).
  • He reused the same Job YAML to migrate another SPC but now somehow he didn't change the cspc-name with this steps things will wrong(I can see job will update the blockdeviceclaim labels with cspc-name argument and return error).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can overcome this by adding old spc name on the cspc and verify that it isn't from another migrated spc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Choose a reason for hiding this comment

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

Still, this problem exists but now it will patch SPC and fail(Can we prevent updating SPC annotation itself?) @shubham14bajpai

@mittachaitu mittachaitu self-requested a review July 3, 2020 07:57
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 few comments PTAL

pkg/migrate/cstor/pool.go Show resolved Hide resolved
pkg/migrate/cstor/pool.go Outdated Show resolved Hide resolved
if k8serrors.IsNotFound(err) {
return nil
}
if err == nil {

Choose a reason for hiding this comment

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

Still, this problem exists but now it will patch SPC and fail(Can we prevent updating SPC annotation itself?) @shubham14bajpai

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

pkg/migrate/cstor/pool.go Show resolved Hide resolved
cspcObj.Annotations = map[string]string{
// This annotation will be used to disable reconciliation on the dependants.
// In this case that will be CSPI
types.OpenEBSDisableDependantsReconcileKey: "true",
"openebs.io/migrated-from": spcName,

Choose a reason for hiding this comment

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

nit: Instead of passing spcName as an argument we can make use of c.SPCObj.Name

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