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 TPR to CRD migration helper. #46677

Merged
merged 1 commit into from
Jun 1, 2017

Conversation

enisoc
Copy link
Member

@enisoc enisoc commented May 31, 2017

This is a helper for migrating TPR data to CustomResource. It's rather hacky because it requires crossing apiserver boundaries, but doing it this way keeps the mess contained to the TPR code, which is scheduled for deletion anyway.

It's also not completely hands-free because making it resilient enough to be completely automated is too involved to be worth it for an alpha-to-beta migration, and would require investing significant effort to fix up soon-to-be-deleted TPR code. Instead, this feature will be documented as a best-effort helper whose results should be verified by hand.

The intended benefit of this over a totally manual process is that it should be possible to copy TPR data into a CRD without having to tear everything down in the middle. The process would look like this:

  1. Upgrade to k8s 1.7. Nothing happens to your TPRs.
  2. Create CRD with group/version and resource names that match the TPR. Still nothing happens to your TPRs, as the CRD is hidden by the overlapping TPR.
  3. Delete the TPR. The TPR data is converted to CustomResource data, and the CRD begins serving at the same REST path.

Note that the old TPR data is left behind by this process, so watchers should not receive DELETE events. This also means the user can revert to the pre-migration state by recreating the TPR definition.

Ref. #45728

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 31, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 31, 2017
@enisoc enisoc added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels May 31, 2017
// Freeze TPR data to prevent new writes via this apiserver process.
// Other apiservers can still write. This is best-effort because there
// are worse problems with TPR data than the possibility of going back
// in time when migrating to CRD [citation needed].
Copy link
Contributor

Choose a reason for hiding this comment

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

The original issue 95. :)

frozen atomic.Value
}

func (r *REST) Freeze() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: a comment that this is a one way trip.

@deads2k
Copy link
Contributor

deads2k commented May 31, 2017

This is a strong start.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, enisoc

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 31, 2017
@deads2k
Copy link
Contributor

deads2k commented May 31, 2017

One thing I haven't handled yet is resetting watchers and preventing them from receiving DELETE events. I also need to add tests, which will likely need to be either e2e or CLI-based. But the core approach can be reviewed now.

What if you detected that this was a migration (you're already doing that) and just didn't delete the original TPR data from etcd? We'd have dangling entries, but no one would be reading them anymore and no delete events would get sent. The watch would be dropped and the client's next list/watch would be satisfied by CRD.

}

// Talk directly to CustomResource storage.
// We have to bypass the API server because TPR is shadowing CRD at this point.
Copy link
Contributor

Choose a reason for hiding this comment

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

will a client observe the deletions? Thinking about the etcd operator deleting its storage volumes.

Copy link
Contributor

Choose a reason for hiding this comment

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

will a client observe the deletions? Thinking about the etcd operator deleting its storage volumes.

I think I would handle that as I indicated #46677 (comment) . I've also suggested manually stopping the controller here: kubernetes/website#3940

I think abandoning the etcd data can happen as a followup or bug fix if necessary.

Copy link
Contributor

@sttts sttts May 31, 2017

Choose a reason for hiding this comment

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

If I understand the PR correctly, you delete the TPR and it automatically is migrated (if successful) to the CRD (if it exists). This feels pretty counter-intuitive. I would have expected an start-cdr-migration annotation on the TPR, or even an automatic migration as soon as the CRD shows up.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand the PR correctly, you delete the TPR and it automatically is migrated (if successful) to the CRD (if it exists). This feels pretty counter-intuitive. I would have expected an start-cdr-migration annotation on the TPR, or even an automatic migration as soon as the CRD shows up.

I'm ok with either change as a followup/issue/bugfix if the TPR structure makes that possible. I don't know that updates are plumbed through.

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow-up bugfix is fine.

@enisoc enisoc force-pushed the tpr-migrate-etcd branch 2 times, most recently from 6bcec9a to 73921cb Compare June 1, 2017 00:20
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2017
@enisoc enisoc force-pushed the tpr-migrate-etcd branch from 73921cb to ba59e14 Compare June 1, 2017 02:07
@enisoc enisoc added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2017
@sttts
Copy link
Contributor

sttts commented Jun 1, 2017

@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

@nikhita
Copy link
Member

nikhita commented Jun 1, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 43505, 45168, 46439, 46677, 46623)

@k8s-github-robot k8s-github-robot merged commit 98e5496 into kubernetes:master Jun 1, 2017
@enisoc enisoc deleted the tpr-migrate-etcd branch June 1, 2017 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants