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

Implement kubeadm reset #34807

Merged
merged 1 commit into from Oct 15, 2016
Merged

Conversation

luxas
Copy link
Member

@luxas luxas commented Oct 14, 2016

@kubernetes/sig-cluster-lifecycle


This change is Reviewable

@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 Oct 14, 2016
@luxas luxas added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Oct 14, 2016
Copy link
Contributor

@dgoodwin dgoodwin left a comment

Choose a reason for hiding this comment

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

This worked great on CentOS, just a few questions and one very minor request for changes.

@@ -150,7 +150,7 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, skipPreFlight
}

if !skipPreFlight {
fmt.Println("<cmd/init> Running pre-flight checks")
fmt.Println("Running pre-flight checks")
Copy link
Contributor

Choose a reason for hiding this comment

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

Intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I think we decided to drop it
At least it was dropped in join

Copy link
Contributor

Choose a reason for hiding this comment

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

Drop it.

PortOpenCheck{port: 10250},
PortOpenCheck{port: 10251},
PortOpenCheck{port: 10252},
Copy link
Contributor

Choose a reason for hiding this comment

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

Did these turn out to not be 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.

This is for the node, 10251 and 10252 for cm and scheduler and 8080 for unsecured apiserver

exec.Command("sh", "-c", "cat /proc/mounts | awk '{print $2}' | grep '/var/lib/kubelet' | xargs umount").Run()

dirsToRemove := []string{"/var/lib/kubelet", "/var/lib/etcd", "/etc/kubernetes"}
fmt.Printf("Deleting the stateful directories: [%v]\n", dirsToRemove)
Copy link
Contributor

Choose a reason for hiding this comment

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

This shows up as: Deleting the stateful directories: [[/var/lib/kubelet /var/lib/etcd /etc/kubernetes]]

Can probably drop the [] in code.


fmt.Printf("Stopping all running docker containers...")
if err := exec.Command("sh", "-c", "docker ps -q | xargs docker kill").Run(); err != nil {
fmt.Printf("failed to stop the running containers")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we actually clean these up or just kill? My reset script I'd been clearing them out entirely.

Also should we only hit containers with a k8s prefix?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking we may want to filter to k8s containers only, I could envision a developer deciding to init master on their workstation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, leads to more work, but is probably worth it

Not sure if we should remove them though... the user might want to read logs

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 we should use docker rm --force --volumes here.

the user might want to read logs

Maybe, but more user will complain about disk space used up by those containers.

fmt.Printf("Stopping the %s service...\n", serviceToStop)
initSystem.ServiceStop(serviceToStop)
} else {
fmt.Printf("no supported init system detected, skipping service checks for %s. kubeadm reset may not have full effect now.\n", serviceToStop)
Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't initsystem.GetInitSystem() return that string as an error?


fmt.Printf("Unmounting directories in /var/lib/kubelet...\n")
// Don't check for errors here, since umount will return a non-zero exit code if there is no directories to umount
exec.Command("sh", "-c", "cat /proc/mounts | awk '{print $2}' | grep '/var/lib/kubelet' | xargs umount").Run()
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 find /var/lib/kubelet | xargs -n 1 findmnt -n -t tmpfs -o TARGET -T | uniq | xargs -r umount is cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

If you depend on awk, you don't have to use grep, i.e. awk '$2 ~ /\/var\/lib\/kubelet { print $2 }' | xargs umount, or even awk '$2 ~ /\/var\/lib\/kubelet { system("umount "$2) }, on the other hand you don't even have to shell out...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should improve that later on...
I don't think find /var/lib/kubelet | xargs -n 1 findmnt -n -t tmpfs -o TARGET -T | uniq | xargs -r umount is better because it will do a find in the whole /var/lib/kubelet dir which may be large.

/proc/mounts is a very small file with the information we need.

I couldn't get awk working standalone, so someone can take that as a fun thing improve later :)


fmt.Printf("Stopping all running docker containers...")
if err := exec.Command("sh", "-c", "docker ps -q | xargs docker kill").Run(); err != nil {
fmt.Printf("failed to stop the running containers")
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 we should use docker rm --force --volumes here.

the user might want to read logs

Maybe, but more user will complain about disk space used up by those containers.

@luxas
Copy link
Member Author

luxas commented Oct 14, 2016

@luxas
Copy link
Member Author

luxas commented Oct 14, 2016

I'd like to get this lgtm'd ASAP, if @mikedanese could do it, it would be awesome! (Ilya is offline now)

@k8s-ci-robot
Copy link
Contributor

Jenkins verification failed for commit e4268db1a84db9667d3a8745905f95965b9547fe. Full PR test history.

The magic incantation to run this job again is @k8s-bot verify test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Copy link
Contributor

@dgoodwin dgoodwin left a comment

Choose a reason for hiding this comment

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

LGTM

@luxas
Copy link
Member Author

luxas commented Oct 15, 2016

Applying @dgoodwin's LGTM

@luxas luxas added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2016
}

func RunReset(out io.Writer, cmd *cobra.Command, skipPreFlight bool) error {

Copy link
Contributor

Choose a reason for hiding this comment

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

Why the empty line?

fmt.Println("Running pre-flight checks")
err := preflight.RunResetCheck()
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break pre-flight checks. It should be return &preflight.PreFlightError{Msg: err.Error()}} instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I copied as it was for init and join after the original preflight PR, which seems to have had this bug then.

Will fix

@luxas luxas removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2016
@luxas
Copy link
Member Author

luxas commented Oct 15, 2016

Fixed @pires' comments, waiting for the build to be green before applying lgtm again

Copy link
Contributor

@pires pires left a comment

Choose a reason for hiding this comment

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

LGTM

@luxas luxas added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2016
@luxas luxas added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Oct 15, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 88d6d7a into kubernetes:master Oct 15, 2016
k8s-github-robot pushed a commit that referenced this pull request Oct 15, 2016
Automatic merge from submit-queue

kubeadm join: Added support for config file.

As more behavior (#34719, #34807, fix for #33641) is added to `kubeadm join`, this will be eventually very much needed. Makes sense to go in sooner rather than later.

Also references #34501 and #34884.

/cc @luxas @mikedanese
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. 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.

None yet

7 participants