-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Conversation
@ereslibre the change SGTM. /ok-to-test |
@neolit123 done! |
cmd/kubeadm/app/phases/etcd/local.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
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.
/retest |
/lgtm @ereslibre great first time contribution! 🥇 |
[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 |
/test pull-kubernetes-e2e-gce-100-performance |
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:
/kind bug