-
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
Get the etcd data path from kubeadm config or etcd pod manifest on kubeadm reset #70003
Get the etcd data path from kubeadm config or etcd pod manifest on kubeadm reset #70003
Conversation
/kind bug @yagonobre |
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.
thank you for this bug fix PR!
i have added some minor comments but in general - LGTM.
cmd/kubeadm/app/cmd/reset.go
Outdated
if err == nil { | ||
dirsToClean = append(dirsToClean, etcdDataDir) | ||
} else { | ||
glog.Warningf("[reset] WARNING: invalid etcd manifest, etcd data directorie will not be cleaned") |
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.
please change to:
glog.Warningf("[reset] etcd data path will not be cleaned: %v", err)
i'm assuming this is what we are going to get on external etcd?
cmd/kubeadm/app/cmd/reset.go
Outdated
"k8s.io/kubernetes/pkg/util/initsystem" | ||
utilsexec "k8s.io/utils/exec" | ||
) | ||
|
||
const etcdVolumeName = "etcd-data" |
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.
please move this constant to the function that uses it.
cmd/kubeadm/app/cmd/reset.go
Outdated
@@ -175,6 +183,25 @@ func (r *Reset) Run(out io.Writer) error { | |||
return nil | |||
} | |||
|
|||
func getEtcdDataDir(manifestPath string) (string, error) { |
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.
SGTM, using the podspec volume.
cmd/kubeadm/app/cmd/reset_test.go
Outdated
|
||
dataDir, err := getEtcdDataDir(manifestPath) | ||
if (err != nil) != test.expectErr { | ||
t.Errorf( |
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.
t.Fatalf()?
cmd/kubeadm/app/cmd/reset_test.go
Outdated
dataDir, err := getEtcdDataDir(manifestPath) | ||
if (err != nil) != test.expectErr { | ||
t.Errorf( | ||
"getEtcdDataDir failed\n%s\nexpected error: %t\n\tgot: %t\nerror: %v", |
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.
please use https://github.com/lithammer/dedent
we already vendor it in kubeadm.
cmd/kubeadm/app/cmd/reset_test.go
Outdated
} | ||
|
||
if dataDir != test.dataDir { | ||
t.Errorf("getEtcdDataDir failed\n%s\n\texpected: %s\ngot: %s", name, test.dataDir, dataDir) |
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.
we should use t.Fatalf() + dedent here too.
cmd/kubeadm/app/cmd/reset_test.go
Outdated
if test.writeManifest { | ||
err := ioutil.WriteFile(manifestPath, []byte(test.podYaml), 0644) | ||
if err != nil { | ||
t.Fatalf("failed to write pod manifest\n%s\n\tfatal error: %v", name, err) |
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.
please use https://github.com/lithammer/dedent
we already vendor it in kubeadm.
@neolit123 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.
@yagonobre thanks for this PR!
My first impression reading this PR is that the etcd folder detection process should initially try to read the kubeadm config and only as a fallback parse the etcd manifest. This could have several advantages, especially if we consider all the variants of etcd we supports (external etcd Vs local etcd Vs stacked etcd)
What do you think about?
@timothysc @detiber opinions?
@fabriziopandini This will just apply when used local/stacked etcd and both use the same spec. But where I can get the kubeadm config? in the configmap? |
@yagonobre However, as suggested in my previous I would appreciate some other opinion about this and then decide if to iterate on this PR or if to leave this PR as it is (+ eventually open an issue for keeping track of the possible improvement with kubeadm config map) |
agreed /assign @timothysc |
@fabriziopandini @timothysc updated! |
ecc491c
to
8d980bf
Compare
/approve |
/retest |
1 similar comment
/retest |
8948828
to
839e8da
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini, yagonobre 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 |
@yagonobre: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest |
@yagonobre it seems you have to run /hack/update-bazel.sh to fix your test |
@fabriziopandini done |
/remove-area kubelet |
@yagonobre please squash the commits to 1 or 2 (one for code, one for autogenerated bazel). |
839e8da
to
b35e22a
Compare
@neolit123 done |
LGTM |
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.
Thx for the patch!
Comments for next time, and they are non-blocking
/lgtm
@@ -175,6 +185,33 @@ func (r *Reset) Run(out io.Writer) error { | |||
return nil | |||
} | |||
|
|||
func getEtcdDataDir(manifestPath string, client clientset.Interface) (string, error) { | |||
const etcdVolumeName = "etcd-data" |
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.
const for this really shouldn't be localized.
|
||
etcdPod, err := utilstaticpod.ReadStaticPodFromDisk(manifestPath) | ||
if err != nil { | ||
return "", err |
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.
it's weird to return empty strings vs. nil objects.
What type of PR is this?
/kind bug
What this PR does / why we need it:
This clean up the correct etcd data path on kubeadm reset
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes kubernetes/kubeadm#1169
Does this PR introduce a user-facing change?:
/sig cluster-lifecycle