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: do not panic if etcd local alpha phase is called when an external etcd config is used #69420

Merged
merged 1 commit into from
Oct 5, 2018

Conversation

ereslibre
Copy link
Contributor

@ereslibre ereslibre commented Oct 4, 2018

What this PR does / why we need it:

If etcd local alpha phase is called manually while the kubeadm configuration
points to an external etcd cluster kubeadm panics.

Which issue(s) this PR fixes
Fixes kubernetes/kubeadm#1127

Special notes for your reviewer:
None

Release note:

kubeadm: Fix a crash if the etcd local alpha phase is called when the configuration contains an external etcd cluster

/kind bug

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 4, 2018
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 4, 2018
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 4, 2018
@neolit123
Copy link
Member

@ereslibre
thank you for the PR.

the change SGTM.
one request, please add a release note explaining your change instead of NONE.

/ok-to-test
@kubernetes/sig-cluster-lifecycle-pr-reviews

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note-none Denotes a PR that doesn't merit a release note. labels Oct 4, 2018
@ereslibre
Copy link
Contributor Author

@neolit123 done!

@@ -37,6 +38,9 @@ const (

// CreateLocalEtcdStaticPodManifestFile will write local etcd static pod manifest file.
func CreateLocalEtcdStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.InitConfiguration) error {
if cfg.ClusterConfiguration.Etcd.External != nil {
return errors.New("etcd static pod manifest cannot be generated for cluster using external etcd")
Copy link
Member

Choose a reason for hiding this comment

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

Small nit
Please use fmt.Errorf, it is the current standard in kubeadm code base

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

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.

@ereslibre
Thanks for this PR!
Please address some nits to make the code more similar to the kubeadm codebase. After then, ready to lgtm for me 😉 !

@@ -37,6 +37,9 @@ const (

// CreateLocalEtcdStaticPodManifestFile will write local etcd static pod manifest file.
func CreateLocalEtcdStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.InitConfiguration) error {
if cfg.ClusterConfiguration.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.

Small nit
Please use fmt.Errorf. it is the standard in kubeadm codebase

Copy link
Member

Choose a reason for hiding this comment

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

but errors.New() makes good sense too if the are no arguments.
it's much cheaper on the CPU compared to fmt.Errorf().

in fact someone made a big PR to fix this across k8s, but he got tired of rebasing and closed.

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 don't have an opinion here because I am missing context on how the project wants to make error reporting homogeneous.

Copy link
Member

Choose a reason for hiding this comment

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

@neolit123
I'm in favour of errors too, but if we have to switch we should do this across all the kubeadm codebase.
In the meantime fmt.Errorf is the standard to use

Local: &kubeadmapi.LocalEtcd{
DataDir: "/var/lib/etcd",
Image: "k8s.gcr.io/etcd",
var tests = []struct {
Copy link
Member

Choose a reason for hiding this comment

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

Another nit for consistency with the rest of kubeadm codebase

Typically we are storing only input/output variables of the test cases in this variable, not the test execution logic.

In this case in the tests input is cfg, while the test output is expectedError.

The run function should go into the for loop,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! :)

…ernal etcd config is used

If etcd local alpha phase is called manually while the kubeadm configuration
points to an external etcd cluster kubeadm panics.
@ereslibre
Copy link
Contributor Author

/retest

@fabriziopandini
Copy link
Member

/lgtm
/approve

@ereslibre great first time contribution! 🥇

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 5, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ereslibre, fabriziopandini

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 Oct 5, 2018
@fabriziopandini
Copy link
Member

/test pull-kubernetes-e2e-gce-100-performance

@k8s-ci-robot k8s-ci-robot merged commit b836fa4 into kubernetes:master Oct 5, 2018
@ereslibre ereslibre deleted the fix-kubeadm-panic branch October 5, 2018 18:20
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix panic on "kubeadm alpha phase etcd" when invoked (improperly) with External Etcd
4 participants