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

Add migration logic for moving from in-tree to out-of-tree #484

Merged
merged 2 commits into from
Aug 28, 2020

Conversation

prashanth26
Copy link
Contributor

@prashanth26 prashanth26 commented Jul 7, 2020

What this PR does / why we need it:
This PR adds migration logic for moving from in-tree to out-of-tree

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:

Added migration logic for moving from provider-specific machine class to generic machine classes in out of tree code path. On migration, the machine.sapcloud.io/migrated annotation set on the old machine class.
New flag `delete-migrated-machine-class` is introduced. When set to true (defaulted to false), deletes any provider-specific machine class (e.g. AWSMachineClass) that has the machine.sapcloud.io/migrated annotation set on it. 
The machine controller adds finalizer only when machine reference is present, deletes it otherwise.

@prashanth26 prashanth26 requested review from ggaurav10 and a team as code owners July 7, 2020 08:01
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jul 7, 2020
@prashanth26
Copy link
Contributor Author

/hold

@gardener-robot gardener-robot added the reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies label Jul 7, 2020
@prashanth26 prashanth26 removed the reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies label Jul 7, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Jul 7, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Jul 7, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jul 7, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jul 7, 2020
@prashanth26
Copy link
Contributor Author

/hold until this is tested through the Gardener

@gardener-robot gardener-robot added the reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies label Jul 9, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Jul 13, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Jul 15, 2020
@prashanth26
Copy link
Contributor Author

/unhold open for review

@gardener-robot gardener-robot removed the reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies label Jul 15, 2020
Copy link

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

@prashanth26 Thanks for the PR! I have some minor comments. However, the main one is regarding passing machine class client in the MigrateMachineClass call.

This driver call will be called by the Machine Controller to try to perform a machineClass migration for an unknown machineClass Kind. This helps in migration of one kind of machineClass to another kind. For instance an machineClass custom resource of `AWSMachineClass` to `MachineClass`.

- On successful migration of machine class the Provider MUST reply `0 OK` (or) `nil` error.
- `MigrateMachineClassRequest` expects the `ClassSpec` containing the `type ClassSpec struct`. It also expects a `MachineClass` client that can be used to communicate with the cluster containing the machine objects. It also passes the `Namespace` where these objects can be found.

Choose a reason for hiding this comment

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

Why not pass the existing provider machine class as a parameter and expect a filled up generic machine class object in return? If type is a problem, it could be just bytes with the callee decoding it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


- On successful migration of machine class the Provider MUST reply `0 OK` (or) `nil` error.
- `MigrateMachineClassRequest` expects the `ClassSpec` containing the `type ClassSpec struct`. It also expects a `MachineClass` client that can be used to communicate with the cluster containing the machine objects. It also passes the `Namespace` where these objects can be found.
- `MigrateMachineClass` is responsible for creating the new `CR` of the new kind (MachinClass) with the same name as the previous one. It also responsible for annotating the old machineClass CR with an migrated annotation.

Choose a reason for hiding this comment

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

Why not just receive the filled up generic machine class object from the MigrateMachineClass and actually create the CR instance in the caller library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This reason I have been avoiding this is because, then this code of annotating the old machine class would go into the current reconciliation loop. And this would mean multiple different calls might have to be made to different machineClass clients while annotation, however keeping it inside the provider spec it would be easier to determine which call to exactly make. However, now what I re-think about it. It seems fine to me.

Let me try making such changes with the new GCP provider and test it out. And see if I face any difficulties.

Choose a reason for hiding this comment

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

👍

The existing in-tree code already has the logic based on the old typed machine classes. So, this would be one more place. Also, this would be only for migration, we can phase this code out via deprecation over a couple of releases. But it if is there in the providers, then phasing it out also is then multiplied by the number of providers.

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 makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved the common logic into this pkg with this commit. Also the leftover at the provider can be seen here at the provider. I hope this is what you meant.

pkg/controller/machineset_util.go Show resolved Hide resolved
pkg/util/provider/driver/driver.go Outdated Show resolved Hide resolved
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 4, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 4, 2020
@hardikdr hardikdr added this to the v0.34.0 milestone Aug 25, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 25, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 25, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 25, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 25, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 25, 2020
@prashanth26
Copy link
Contributor Author

@amshuman-kr & @hardikdr - I have made all the requested code changes to the best of my knowledge, let me know if I missed something. Also, I have added a few tests for verifying the migration code path.

@hardikdr
Copy link
Member

@prashanth26 tests are failing, can you please check.
I'll take a final look soon.

@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 26, 2020
@prashanth26
Copy link
Contributor Author

@hardikdr - Sorry, missed out some things while running the final tests. Seems to be working now.

@hardikdr
Copy link
Member

@prashanth26 It'd be nice to squash & re-arrange a few of the commits in a meaningful order.

@amshuman-kr @ggaurav10 Can you please take a final look and approve if possible?

@hardikdr
Copy link
Member

/lgtm

/hold till commits are squashed.

@gardener-robot gardener-robot added reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies reviewed/lgtm Has approval for merging labels Aug 27, 2020
@prashanth26
Copy link
Contributor Author

@prashanth26 It'd be nice to squash & re-arrange a few of the commits in a meaningful order.

Yes Hardik. Shall do that once all comments are addressed.

- Any changes/updates to class.Kind propagates top-down without rolling updates
- Ignore reconciling machines with unknown ClassKind at MCM
- Updated docs to reflect these changes
- Updated old machine class finalizers
- Introduced a new flag to delete old machine classes on migration
- The machineClass controllers add finalizer only when reference is present, and removes it otherwise
- There is also logic for setting the deletion timestamp if migration annotation and delete-migrated-machine-class flag is set
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2020
@hardikdr
Copy link
Member

/unhold

@gardener-robot gardener-robot removed the reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies label Aug 28, 2020
Copy link
Contributor

@ggaurav10 ggaurav10 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

LGTM

@prashanth26
Copy link
Contributor Author

Thank you, guys. Will merge it once the tests pass.

@prashanth26 prashanth26 merged commit 90f8b67 into gardener:master Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants