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

kubeadm: Refactor the .Etcd substruct in the v1alpha2 API #64066

Merged
merged 2 commits into from May 24, 2018

Conversation

luxas
Copy link
Member

@luxas luxas commented May 19, 2018

What this PR does / why we need it:
Splits the monolithic .Etcd struct with all the options as fields to a more modular and clear design with two sub-structs for the different modes of hosting etcd we support.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of kubernetes/community#2131

Special notes for your reviewer:
Depends on:

Follows up: #63871
TODO: I still need to write unit tests for this.

Release note:

[action required] kubeadm: The `:Etcd` struct has been refactored in the v1alpha2 API. All the options now reside under either `.Etcd.Local` or `.Etcd.External`. Automatic conversions from the v1alpha1 API are supported.

@kubernetes/sig-cluster-lifecycle-pr-reviews @liztio

@k8s-ci-robot k8s-ci-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 19, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: luxas

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2018
Copy link
Member

@dixudx dixudx left a comment

Choose a reason for hiding this comment

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

The old configurations for Etcd are replaced by Etcd.Local and Etcd.External respectively. The is a big change, but makes the configurations more concise.

Better add a notice somewhere to warn the users, since this new change will block in-place updates with old config file.

@luxas
Copy link
Member Author

luxas commented May 21, 2018

@timothysc this is ready to merge.

Better add a notice somewhere to warn the users, since this new change will block in-place updates with old config file.

@dixudx we support full backwards-compability. All existing users will be upgraded to the new config automatically, thanks to the automatic API machinery conversations from v1alpha1 to v1alpha2. Also, a release note with action required is automatically created from this PR.

@luxas
Copy link
Member Author

luxas commented May 21, 2018

/retest

@neolit123
Copy link
Member

/test pull-kubernetes-e2e-kops-aws

@timothysc
Copy link
Member

/assign @detiber @stealthybox

They are the last two to update this area, they should have a say.

allErrs = append(allErrs, ValidateCertSANs(e.Local.PeerCertSANs, localPath.Child("peerCertSANs"))...)
}
if e.External != nil {
allowHTTP := false
Copy link
Member

Choose a reason for hiding this comment

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

I think that requireHTTPS is more clear (the logic should be changed accordingly)

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you/I please follow-up on that?

Copy link
Member

Choose a reason for hiding this comment

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

Might be a new issue help/wanted for new contributors 😉

@@ -51,8 +51,7 @@ func CreatePKIAssets(cfg *kubeadmapi.MasterConfiguration) error {
CreateAPIServerEtcdClientCertAndKeyFiles,
}

// Currently this is the only way we have to identify static pod etcd vs external etcd
if len(cfg.Etcd.Endpoints) == 0 {
if cfg.Etcd.Local != nil || cfg.Etcd.External == nil {
Copy link
Member

Choose a reason for hiding this comment

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

|| cfg.Etcd.External == nil seems not necessary

Copy link
Member Author

Choose a reason for hiding this comment

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

There is an edge case here actually when we don't know which one of the structs are defined or the other undefined (in unit tests), so hence I added this. It doesn't hurt I guess...?

Copy link
Member

Choose a reason for hiding this comment

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

Ok. If possible this should be annotated in comments because this is the only place where this is required

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, now I changed the unit tests instead, so now it works as you wanted it 👍

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

+💯 for cleaning up the etcd configuration
Only two minor comments from my side

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 22, 2018
@stealthybox
Copy link
Member

@luxas should we bump the api version for the featureGates struct and regenerate the config conversions before we merge this so that we have an independent patch for fixing the previous config issue we introduced with v1.10.0 ?

@luxas
Copy link
Member Author

luxas commented May 23, 2018

@luxas should we bump the api version for the featureGates struct and regenerate the config conversions before we merge this so that we have an independent patch for fixing the previous config issue we introduced with v1.10.0 ?

I've worked a lot the latest week on building on top of @liztio's initial great patch for that in order to make this all work flawlessly. See the earlier PRs linked in kubernetes/community#2131

Basically what happens can be read in https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/util/config/masterconfig.go#L109-L160.
TL;DR; The featureGates and lack of TypeMeta when marshalled issues are resolved for the v1alpha1 version. That's the first that happens. Internally, when loading a v1alpha1 version in kubeadm v1.11, it will be automatically converted to the internal version which equals v1alpha2 which is the output format.
Also see the testcases in util/config/testdata

Does that answer your question?
I'm rebasing now and addressing @fabriziopandini's nits so we can merge.

@luxas luxas force-pushed the kubeadm_etcd_refactor branch 2 times, most recently from 6adb790 to 0038aba Compare May 23, 2018 14:02
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 23, 2018
@stealthybox
Copy link
Member

stealthybox commented May 23, 2018

/test pull-kubernetes-bazel-test

@luxas that does answer my question -- I'm glad the serialization issues are remedied.

@luxas
Copy link
Member Author

luxas commented May 23, 2018

/retest

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

Automatic merge from submit-queue (batch tested with PRs 64127, 63895, 64066, 64215, 64202). If you want to cherry-pick this change to another branch, please follow the instructions here.

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. area/kubeadm 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-action-required Denotes a PR that introduces potentially breaking changes that require user action. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants