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

wip: Fix stop containers for containerd. #7545

Closed
wants to merge 4 commits into from

Conversation

medyagh
Copy link
Member

@medyagh medyagh commented Apr 9, 2020

hopefully closes #7521
which after miniube was stopped for containerd, on the start you would sometimes see this in the logs:

	  - Error: failed to create listener: failed to listen on 0.0.0.0:8444: listen tcp 0.0.0.0:8444: bind: address already in use

the problem was in kic we were trying to stop containers before kic stop to avoid
bind address problem

but the command stop container was wrong in the lib, it was rm
and even if the lib writer meant remove, u can not remove a not stopped container. so I changed to stop, we might need to do both stop and rm but I dont think rm is needed.

this doesnt work in crictl:

docker@minikube:~$ sudo crictl rm 5c3039d13ecadafdd46c1cabe936f4cc48114f1596c60c86e2ca7d33b7358be5
ERRO[0000] container "5c3039d13ecadafdd46c1cabe936f4cc48114f1596c60c86e2ca7d33b7358be5" is running, please stop it first 
FATA[0000] unable to remove container(s)

but this works:


docker@minikube:~$ sudo crictl stop 5c3039d13ecadafdd46c1cabe936f4cc48114f1596c60c86e2ca7d33b7358be5
5c3039d13ecadafdd46c1cabe936f4cc48114f1596c60c86e2ca7d33b7358be5

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 9, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh

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 Apr 9, 2020
@medyagh medyagh changed the title fix stop containers for containerd Fix stop containers for containerd Apr 9, 2020
@medyagh medyagh changed the title Fix stop containers for containerd Fix stop containers for containerd. Apr 9, 2020
@medyagh
Copy link
Member Author

medyagh commented Apr 9, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Apr 9, 2020
@minikube-pr-bot
Copy link

Error: running mkcmp
2020/04/09 07:24:25 Executing run 1/3...
2020/04/09 07:24:25 Running: [/home/performance-monitor/minikube/out/minikube start]...
2020/04/09 07:24:25 Running: [/home/performance-monitor/minikube/out/minikube start]...
2020/04/09 07:25:38 Running: [/home/performance-monitor/.minikube/minikube-binaries/7545/minikube start]...
2020/04/09 07:25:38 Running: [/home/performance-monitor/.minikube/minikube-binaries/7545/minikube start]...
2020/04/09 07:25:38 error deleting minikube: fork/exec /home/performance-monitor/.minikube/minikube-binaries/7545/minikube: exec format error
: exit status 1

@codecov-io
Copy link

Codecov Report

Merging #7545 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7545   +/-   ##
=======================================
  Coverage   36.69%   36.69%           
=======================================
  Files         146      146           
  Lines        8988     8988           
=======================================
  Hits         3298     3298           
  Misses       5297     5297           
  Partials      393      393           
Impacted Files Coverage Δ
pkg/minikube/cruntime/cri.go 38.57% <100.00%> (ø)

@minikube-pr-bot
Copy link

Times for minikube: [69.642782215 66.478358537 65.91416543]
Average time for minikube: 67.34510206066666

Times for Minikube (PR 7545): [68.559998493 66.82173064599999 66.26329182399999]
Average time for Minikube (PR 7545): 67.21500698766665

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.062304 |           0.053780 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.021136 |           0.019860 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.004018 |           0.003891 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 41.963445 |          41.328196 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 23.014927 |          23.492582 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.196746 |           2.222008 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.079360 |           0.087874 |
| configured to use "minikube"   |           |                    |
|                                |  0.003166 |           0.006815 |
+--------------------------------+-----------+--------------------+

@minikube-pr-bot
Copy link

Times for minikube: [69.018850534 68.66266183 66.928241411]
Average time for minikube: 68.20325125833334

Times for Minikube (PR 7545): [68.642177001 68.525873759 66.414367633]
Average time for Minikube (PR 7545): 67.860806131

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.060209 |           0.056192 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.021243 |           0.020622 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.003811 |           0.003260 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 42.640446 |          41.212858 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 23.071201 |          24.122438 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.328916 |           2.359824 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.074310 |           0.080344 |
| configured to use "minikube"   |           |                    |
|                                |  0.003116 |           0.005269 |
+--------------------------------+-----------+--------------------+

@minikube-pr-bot
Copy link

Times for minikube: [65.634584023 66.59397426899999 68.001445409]
Average time for minikube: 66.74333456699999

Times for Minikube (PR 7545): [65.555876831 65.131053814 66.36321817000001]
Average time for Minikube (PR 7545): 65.68338293833334

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.063145 |           0.055341 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.022844 |           0.020226 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.004308 |           0.003897 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 40.781192 |          40.489324 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 23.380042 |          22.712860 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.406348 |           2.316285 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.082524 |           0.081055 |
| configured to use "minikube"   |           |                    |
|                                |  0.002932 |           0.004395 |
+--------------------------------+-----------+--------------------+

@k8s-ci-robot
Copy link
Contributor

@medyagh: PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2020
@@ -316,33 +316,40 @@ func (d *Driver) Start() error {
func (d *Driver) Stop() error {
// on init this doesn't get filled when called from cmd
d.exec = command.NewKICRunner(d.MachineName, d.OCIBinary)
// docker does not send right SIG for systemd to know to stop the systemd.
// to avoid bind address be taken on an upgrade. more info https://github.com/kubernetes/minikube/issues/7171
if err := kubelet.Stop(d.exec); err != nil {
Copy link
Contributor

@tstromberg tstromberg Apr 9, 2020

Choose a reason for hiding this comment

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

Why did this move? I think the kubelet should stop first - otherwise it may restart containers on you.

}
}
// to avoid https://github.com/kubernetes/minikube/issues/7521
if _, err := d.exec.RunCmd(exec.Command("sudo", "/bin/bash", "-c", "kill -9 $(pgrep kube-apiserver)")); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't stopping the container take care of this? Do we have proof that this helps?

@@ -195,7 +195,7 @@ func stopCRIContainers(cr CommandRunner, ids []string) error {
glog.Infof("Stopping containers: %s", ids)

crictl := getCrictlPath(cr)
args := append([]string{crictl, "rm"}, ids...)
args := append([]string{crictl, "stop", "--timeout=2"}, ids...)
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 timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

default time out is 10seconds, I thought it would better if we tweak it so we dont wait long ... but maybe not.

@minikube-pr-bot
Copy link

Times for minikube: [66.508048593 69.124683805 67.763322201]
Average time for minikube: 67.79868486633335

Times for Minikube (PR 7545): [66.539862787 64.451360596 67.12617210500001]
Average time for Minikube (PR 7545): 66.03913182933333

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.061861 |           0.055888 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.022286 |           0.020047 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.003665 |           0.003228 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 41.732470 |          41.001123 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 23.692408 |          22.753733 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.207559 |           2.122728 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.073978 |           0.076815 |
| configured to use "minikube"   |           |                    |
|                                |  0.004458 |           0.005569 |
+--------------------------------+-----------+--------------------+

@minikube-pr-bot
Copy link

Times for minikube: [70.46217426 69.362016633 71.168487795]
Average time for minikube: 70.33089289600001

Times for Minikube (PR 7545): [65.5233439 66.94999124300001 69.086857996]
Average time for Minikube (PR 7545): 67.18673104633332

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.063082 |           0.054981 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.022311 |           0.021744 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.003930 |           0.003194 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 43.738786 |          41.543711 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 23.982366 |          23.541215 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.436545 |           1.934648 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.079495 |           0.083023 |
| configured to use "minikube"   |           |                    |
|                                |  0.004377 |           0.004214 |
+--------------------------------+-----------+--------------------+

@minikube-pr-bot
Copy link

Times for minikube: [65.159318801 69.44426764 67.36778160299998]
Average time for minikube: 67.323789348

Times for Minikube (PR 7545): [64.854058299 65.75686646299998 66.536224421]
Average time for Minikube (PR 7545): 65.71571639433333

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.063207 |           0.056130 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.021309 |           0.021293 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.003802 |           0.003379 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 40.926882 |          41.459994 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 23.744735 |          21.932285 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.479135 |           2.167149 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.078150 |           0.071606 |
| configured to use "minikube"   |           |                    |
|                                |  0.006569 |           0.003880 |
+--------------------------------+-----------+--------------------+

@minikube-pr-bot
Copy link

Times for minikube: [66.535640968 66.615333903 65.26584139799999]
Average time for minikube: 66.13893875633333

Times for Minikube (PR 7545): [65.60682616199998 67.84454655799999 71.294241319]
Average time for Minikube (PR 7545): 68.24853801299999

Averages Time Per Log

+--------------------------------+-----------+--------------------+
|              LOG               | MINIKUBE  | MINIKUBE (PR 7545) |
+--------------------------------+-----------+--------------------+
| * minikube v1.9.2 on Debian    |  0.063215 |           0.055472 |
|                           9.11 |           |                    |
| * Using the kvm2 driver based  |  0.021524 |           0.020281 |
| on user configuration          |           |                    |
| * Starting control plane node  |  0.003716 |           0.007229 |
| minikube in cluster minikube   |           |                    |
| * Creating kvm2 VM (CPUs=2,    | 42.185275 |          42.728416 |
| Memory=3700MB, Disk=20000MB)   |           |                    |
| ...                            |           |                    |
| * Preparing Kubernetes v1.18.0 | 21.684058 |          23.107002 |
| on Docker 19.03.8 ...          |           |                    |
| * Enabling addons:             |  2.094356 |           2.246475 |
| default-storageclass,          |           |                    |
| storage-provisioner            |           |                    |
| * Done! kubectl is now         |  0.083350 |           0.079639 |
| configured to use "minikube"   |           |                    |
|                                |  0.003444 |           0.004024 |
+--------------------------------+-----------+--------------------+

@tstromberg
Copy link
Contributor

tstromberg commented Apr 10, 2020

This PR have a very positive impact. Looking forward to it!

PS - I had no idea that the Docker driver used containerd inside.

@medyagh medyagh changed the title Fix stop containers for containerd. wip: Fix stop containers for containerd. Apr 10, 2020
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 10, 2020
@medyagh medyagh closed this Apr 10, 2020
@medyagh medyagh deleted the kic_stop_improve branch May 2, 2020 22:31
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Docker_Linux: TestStartStop/group/containerd: listen tcp 0.0.0.0:8444: bind: address already in use
6 participants