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(cspc): migrate pools from spc to cspc #1531

Closed
wants to merge 22 commits into from

Conversation

shubham14bajpai
Copy link
Contributor

@shubham14bajpai shubham14bajpai commented Nov 19, 2019

Signed-off-by: shubham [email protected]

What this PR does / why we need it:
This PR adds the functionality to migrate a pool from SPC to CSPC.
Refer openebs/openebs#2840 for design.

Example Migration Job yaml

---
apiVersion: batch/v1
kind: Job
metadata:
  name: migrate-spc-sparse-claim-auto
  namespace: openebs
spec:
  backoffLimit: 4
  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:
        - "pool"
        # name of the spc that is to be migrated
        - "--spc-name=sparse-claim-auto"

        #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: shubham1494/migrate:ci
      restartPolicy: OnFailure
---

Logs for the job executed for 3 pool SPC migration.

mayadata:setup$ kubectl -n openebs logs -f migrate-spc-sparse-claim-auto-79tmp 
I1210 12:10:12.633883       1 pool.go:73] Migrating spc sparse-claim-auto to cspc
I1210 12:10:12.657852       1 pool.go:256] Updating bdc bdc-26c12fb6-1b45-11ea-b9b2-42010aa00037 with cspc labels & finalizer.
I1210 12:10:12.666131       1 pool.go:256] Updating bdc bdc-26c4a58c-1b45-11ea-b9b2-42010aa00037 with cspc labels & finalizer.
I1210 12:10:12.671711       1 pool.go:256] Updating bdc bdc-2866fa95-1b45-11ea-b9b2-42010aa00037 with cspc labels & finalizer.
I1210 12:10:12.678051       1 pool.go:256] Updating bdc bdc-286a0ca1-1b45-11ea-b9b2-42010aa00037 with cspc labels & finalizer.
I1210 12:10:12.684106       1 pool.go:256] Updating bdc bdc-2a07a9ee-1b45-11ea-b9b2-42010aa00037 with cspc labels & finalizer.
I1210 12:10:12.690697       1 pool.go:256] Updating bdc bdc-2a082f89-1b45-11ea-b9b2-42010aa00037 with cspc labels & finalizer.
I1210 12:10:12.698127       1 pool.go:72] Creating equivalent cspc for spc sparse-claim-auto
I1210 12:10:17.758073       1 pool.go:286] Updating bdc bdc-26c12fb6-1b45-11ea-b9b2-42010aa00037 with cspc ownerRef.
I1210 12:10:17.768552       1 pool.go:286] Updating bdc bdc-26c4a58c-1b45-11ea-b9b2-42010aa00037 with cspc ownerRef.
I1210 12:10:17.778365       1 pool.go:286] Updating bdc bdc-2866fa95-1b45-11ea-b9b2-42010aa00037 with cspc ownerRef.
I1210 12:10:17.787820       1 pool.go:286] Updating bdc bdc-286a0ca1-1b45-11ea-b9b2-42010aa00037 with cspc ownerRef.
I1210 12:10:17.796191       1 pool.go:286] Updating bdc bdc-2a07a9ee-1b45-11ea-b9b2-42010aa00037 with cspc ownerRef.
I1210 12:10:17.807942       1 pool.go:286] Updating bdc bdc-2a082f89-1b45-11ea-b9b2-42010aa00037 with cspc ownerRef.
I1210 12:10:17.829258       1 pool.go:147] Migrating csp sparse-claim-auto-77dq to cspi sparse-claim-auto-vs62
I1210 12:10:17.829313       1 pool.go:208] Scaling down deployemnt sparse-claim-auto-vs62
I1210 12:12:13.084652       1 pool.go:310] Updating cvr pvc-5ad20014-1b45-11ea-b9b2-42010aa00037-sparse-claim-auto-vs62 with cspi sparse-claim-auto-77dq info.
I1210 12:12:13.110128       1 pool.go:147] Migrating csp sparse-claim-auto-hxbb to cspi sparse-claim-auto-wci1
I1210 12:12:13.110161       1 pool.go:208] Scaling down deployemnt sparse-claim-auto-wci1
I1210 12:12:58.306339       1 pool.go:310] Updating cvr pvc-5ad20014-1b45-11ea-b9b2-42010aa00037-sparse-claim-auto-wci1 with cspi sparse-claim-auto-hxbb info.
I1210 12:12:58.323553       1 pool.go:147] Migrating csp sparse-claim-auto-wgjz to cspi sparse-claim-auto-t6zm
I1210 12:12:58.323607       1 pool.go:208] Scaling down deployemnt sparse-claim-auto-t6zm
I1210 12:13:38.425799       1 pool.go:310] Updating cvr pvc-5ad20014-1b45-11ea-b9b2-42010aa00037-sparse-claim-auto-t6zm with cspi sparse-claim-auto-wgjz info.
I1210 12:13:38.444027       1 pool.go:79] Successfully migrated spc sparse-claim-auto to cspc

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Checklist:

  • Fixes #
  • Labelled this PR & related issue with documentation tag
  • PR messages has document related information
  • Labelled this PR & related issue with breaking-changes tag
  • PR messages has breaking changes related information
  • Labelled this PR & related issue with requires-upgrade tag
  • PR messages has upgrade related information
  • Commit has unit tests
  • Commit has integration tests

pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
@shubham14bajpai shubham14bajpai changed the title [WIP] feat(migrate): generate CSPC form given SPC feat(cspc): migrate pools from spc to cspc Nov 28, 2019
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
cmd/migrate/executor/setup_job.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/migration.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
cmd/cstor-pool-mgmt/pool/v1alpha2/import.go Outdated Show resolved Hide resolved
}

// PreRun will check for environement variables to be read and intialized.
func PreRun(cmd *cobra.Command, args []string) {

Choose a reason for hiding this comment

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

There is the same check-in upgrade code also. Can we have a common code?

NewMigratePoolJob(),
)

cmd.PersistentFlags().StringVarP(&options.openebsNamespace,

Choose a reason for hiding this comment

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

Are we overwriting the value of openebsNamespace after reading from env?

"replicas": 0
}
}`
cspNameLabel = "cstorpool.openebs.io/name"

Choose a reason for hiding this comment

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

Can we move these to APIs? So that we can use the same name wherever it required.

pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Show resolved Hide resolved
WithNamespace(openebsNamespace).
Update(&bdcObj)
if err != nil {
return errors.Wrapf(err, "failed to update bdc %s with cspc label & finalizer", bdcObj.Name)

Choose a reason for hiding this comment

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

I think we have to add a note to README.md. Once the user tried the migration process user should try until it succeeds or else there will be chances of stale BD's if the user triggers the deletion of the SPC process(Since CSPC is not yet created).

Choose a reason for hiding this comment

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

Here, In the worst case, there will be a chance of network failures.

pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/apis/openebs.io/v1alpha1/cas_keys.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Show resolved Hide resolved
if err != nil {
return nil, err
}
cspcObj, err = cspc.NewKubeClient().

Choose a reason for hiding this comment

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

nit: Good to have a client in Hands instead of every time generating client. In CSPC kubernetes package we can use sync.Once

pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/apis/openebs.io/v1alpha1/cstorpool_cluster.go Outdated Show resolved Hide resolved
pkg/algorithm/nodeselect/v1alpha2/build_csp.go Outdated Show resolved Hide resolved
@@ -0,0 +1,30 @@
/*

Choose a reason for hiding this comment

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

Can we remove this package?

@shubham14bajpai shubham14bajpai force-pushed the migrate branch 2 times, most recently from 1fa726e to fcc401b Compare December 27, 2019 07:04
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Found some fixes!

P.S. share your ideas, feedbacks or issues with us at https://github.com/fixmie/feedback (this message will be removed after the beta stage).

pkg/webhook/configuration.go Outdated Show resolved Hide resolved
pkg/webhook/configuration.go Outdated Show resolved Hide resolved
tests/localpv/hostdevice_test.go Outdated Show resolved Hide resolved
pkg/debug/inject_client.go Outdated Show resolved Hide resolved
pkg/debug/inject_client.go Outdated Show resolved Hide resolved
@shubham14bajpai shubham14bajpai force-pushed the migrate branch 4 times, most recently from e05d79e to b5cf01a Compare December 27, 2019 07:46
@kmova kmova added this to the 1.6.0 milestone Dec 31, 2019
cmd/cspi-mgmt/app/handler.go Outdated Show resolved Hide resolved
cmd/cspi-mgmt/app/handler.go Outdated Show resolved Hide resolved
annotations:
 - removed oldCSPUID schema change
 - added two generic annotation which can be used in different scenarios
 - renamed one function according to the functionality

Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Show resolved Hide resolved
pkg/cstor/migrate/cspc_generator.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
pkg/cstor/migrate/pool.go Outdated Show resolved Hide resolved
cmd/cstor-pool-mgmt/pool/v1alpha2/import.go Outdated Show resolved Hide resolved
Signed-off-by: shubham <[email protected]>
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 according to the current migration OEP. Enhancements are required based on CSPC & it's deployment changes.

@shubham14bajpai
Copy link
Contributor Author

This PR is replaced by openebs-archive/upgrade#4

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

Successfully merging this pull request may close these issues.

5 participants