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

docker/podman: avoid creating overlapping networks with other tools (KVM,...) #10439

Merged
merged 5 commits into from
Feb 20, 2021

Conversation

prezha
Copy link
Contributor

@prezha prezha commented Feb 11, 2021

fixes #10005

make sure that the candidate for new container network does not overlap with any existing local networks

notes:

example

before

set docker net to kvm's default (static) one to simulate conflict:

❯ grep "const firstSubnetAddr" pkg/drivers/kic/oci/network_create.go
const firstSubnetAddr = "192.168.39.0"

❯ grep "ip address" pkg/drivers/kvm/network.go
  <ip address='192.168.39.1' netmask='255.255.255.0'>
❯ out/minikube start --driver=docker -p docker-192.168.39.0
😄  [docker-192.168.39.0] minikube v1.17.1 on Opensuse-Tumbleweed
✨  Using the docker driver based on user configuration
❗  docker is currently using the btrfs storage driver, consider switching to overlay2 for better performance
👍  Starting control plane node docker-192.168.39.0 in cluster docker-192.168.39.0
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "docker-192.168.39.0" cluster and "default" namespace by default
❯ ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           DOWN           192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
br-08ada8d5dfa4  UP             172.22.0.1/16
docker0          DOWN           172.17.0.1/16
br-ec7e0d3126e7  UP             192.168.39.1/24
❯ out/minikube start --driver=kvm -p kvm-192.168.39.0
😄  [kvm-192.168.39.0] minikube v1.17.1 on Opensuse-Tumbleweed
✨  Using the kvm2 driver based on user configuration
💿  Downloading VM boot image ...
    > minikube-v1.17.0.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s
    > minikube-v1.17.0.iso: 212.69 MiB / 212.69 MiB [] 100.00% 24.09 MiB p/s 9s
👍  Starting control plane node kvm-192.168.39.0 in cluster kvm-192.168.39.0
💾  Downloading Kubernetes v1.20.2 preload ...
    > preloaded-images-k8s-v8-v1....: 491.22 MiB / 491.22 MiB  100.00% 21.47 Mi
🔥  Creating kvm2 VM (CPUs=2, Memory=6000MB, Disk=20000MB) ...
🤦  StartHost failed, but will try again: creating host: create: Error creating machine: Error in driver during machine creation: creating network: creating network minikube-net: virError(Code=1, Domain=0, Message='internal error: Network is already in use by interface br-ec7e0d3126e7')
🔄  Restarting existing kvm2 VM for "kvm-192.168.39.0" ...
😿  Failed to start kvm2 VM. Running "minikube delete -p kvm-192.168.39.0" may fix it: driver start: ensuring active networks: deleting inoperable network minikube-net: destroying network: virError(Code=55, Domain=19, Message='Requested operation is not valid: network 'minikube-net' is not active')

❌  Exiting due to GUEST_PROVISION: Failed to start host: driver start: ensuring active networks: deleting inoperable network minikube-net: destroying network: virError(Code=55, Domain=19, Message='Requested operation is not valid: network 'minikube-net' is not active')

😿  If the above advice does not help, please let us know:
👉  https://github.com/kubernetes/minikube/issues/new/choose
❯ minikube profile list
|---------------------|-----------|---------|--------------|------|---------|---------|-------|
|       Profile       | VM Driver | Runtime |      IP      | Port | Version | Status  | Nodes |
|---------------------|-----------|---------|--------------|------|---------|---------|-------|
| docker-192.168.39.0 | docker    | docker  | 192.168.39.2 | 8443 | v1.20.2 | Running |     1 |
| kvm-192.168.39.0    | kvm2      | docker  |              | 8443 | v1.20.2 | Unknown |     1 |
|---------------------|-----------|---------|--------------|------|---------|---------|-------|
❯ minikube delete --all
🔥  Deleting "docker-192.168.39.0" in docker ...
🔥  Removing /home/prezha/.minikube/machines/docker-192.168.39.0 ...
💀  Removed all traces of the "docker-192.168.39.0" cluster.
🔥  Deleting "kvm-192.168.39.0" in kvm2 ...
💀  Removed all traces of the "kvm-192.168.39.0" cluster.
🔥  Successfully deleted all profiles
# virsh net-list --all
 Name           State      Autostart   Persistent
---------------------------------------------------
 default        active     yes         yes
 minikube-net   inactive   yes         yes

after

simulate conflict:

❯ grep "const firstSubnetAddr" pkg/drivers/kic/oci/network_create.go
const firstSubnetAddr = "192.168.49.0"

❯ grep "const firstSubnetAddr" pkg/drivers/kvm/network.go
const firstSubnetAddr = "192.168.49.0"
❯ out/minikube start --driver=docker -p docker-192.168.49.0
😄  [docker-192.168.49.0] minikube v1.17.1 on Opensuse-Tumbleweed
✨  Using the docker driver based on user configuration
❗  docker is currently using the btrfs storage driver, consider switching to overlay2 for better performance
👍  Starting control plane node docker-192.168.49.0 in cluster docker-192.168.49.0
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "docker-192.168.49.0" cluster and "default" namespace by default
❯ out/minikube start --driver=kvm -p kvm-192.168.49.0
😄  [kvm-192.168.49.0] minikube v1.17.1 on Opensuse-Tumbleweed
✨  Using the kvm2 driver based on user configuration
👍  Starting control plane node kvm-192.168.49.0 in cluster kvm-192.168.49.0
💾  Downloading Kubernetes v1.20.2 preload ...
    > preloaded-images-k8s-v8-v1....: 491.22 MiB / 491.22 MiB  100.00% 25.11 Mi
🔥  Creating kvm2 VM (CPUs=2, Memory=6000MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "kvm-192.168.49.0" cluster and "default" namespace by default
❯ ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           UP             192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
br-08ada8d5dfa4  UP             172.22.0.1/16
docker0          DOWN           172.17.0.1/16
br-33a6261ee1e8  UP             192.168.49.1/24
virbr1           UP             192.168.69.1/24
❯ minikube profile list
|---------------------|-----------|---------|---------------|------|---------|---------|-------|
|       Profile       | VM Driver | Runtime |      IP       | Port | Version | Status  | Nodes |
|---------------------|-----------|---------|---------------|------|---------|---------|-------|
| docker-192.168.49.0 | docker    | docker  | 192.168.49.2  | 8443 | v1.20.2 | Running |     1 |
| kvm-192.168.49.0    | kvm2      | docker  | 192.168.69.72 | 8443 | v1.20.2 | Running |     1 |
|---------------------|-----------|---------|---------------|------|---------|---------|-------|
❯ minikube delete --all
🔥  Deleting "docker-192.168.49.0" in docker ...
🔥  Removing /home/prezha/.minikube/machines/docker-192.168.49.0 ...
💀  Removed all traces of the "docker-192.168.49.0" cluster.
🔥  Deleting "kvm-192.168.49.0" in kvm2 ...
💀  Removed all traces of the "kvm-192.168.49.0" cluster.
🔥  Successfully deleted all profiles
codex:~ # virsh net-list --all
 Name      State    Autostart   Persistent
--------------------------------------------
 default   active   yes         yes

same goes for the other side:

❯ grep "const firstSubnetAddr" pkg/drivers/kic/oci/network_create.go
const firstSubnetAddr = "192.168.39.0"

❯ grep "const firstSubnetAddr" pkg/drivers/kvm/network.go
const firstSubnetAddr = "192.168.39.0"
❯ out/minikube start --driver=kvm -p kvm-192.168.39.0
😄  [kvm-192.168.39.0] minikube v1.17.1 on Opensuse-Tumbleweed
✨  Using the kvm2 driver based on user configuration
👍  Starting control plane node kvm-192.168.39.0 in cluster kvm-192.168.39.0
🔥  Creating kvm2 VM (CPUs=2, Memory=6000MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "kvm-192.168.39.0" cluster and "default" namespace by default
❯ out/minikube start --driver=docker -p docker-192.168.39.0
😄  [docker-192.168.39.0] minikube v1.17.1 on Opensuse-Tumbleweed
✨  Using the docker driver based on user configuration
❗  docker is currently using the btrfs storage driver, consider switching to overlay2 for better performance
👍  Starting control plane node docker-192.168.39.0 in cluster docker-192.168.39.0
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "docker-192.168.39.0" cluster and "default" namespace by default
❯ ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           UP             192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
br-08ada8d5dfa4  UP             172.22.0.1/16
docker0          DOWN           172.17.0.1/16
virbr1           UP             192.168.39.1/24
br-8616cbd0a692  UP             192.168.49.1/24
❯ minikube profile list
|---------------------|-----------|---------|----------------|------|---------|---------|-------|
|       Profile       | VM Driver | Runtime |       IP       | Port | Version | Status  | Nodes |
|---------------------|-----------|---------|----------------|------|---------|---------|-------|
| docker-192.168.39.0 | docker    | docker  | 192.168.49.2   | 8443 | v1.20.2 | Running |     1 |
| kvm-192.168.39.0    | kvm2      | docker  | 192.168.39.174 | 8443 | v1.20.2 | Running |     1 |
|---------------------|-----------|---------|----------------|------|---------|---------|-------|

additional examples (as per @medyagh's suggestion)

current master

❯ docker network list
NETWORK ID     NAME                 DRIVER    SCOPE
d4c6d1af63d9   br-test00            bridge    local
4caf32131f3f   br-test01            bridge    local
bafaa95e04c9   br-test02            bridge    local
82697145172a   br-test03            bridge    local
3fb60e8289eb   br-test04            bridge    local
f6bd05bf4625   br-test05            bridge    local
f62e9c91fe42   br-test06            bridge    local
a4dc3444d406   br-test07            bridge    local
661f7a0277f9   br-test08            bridge    local
de4b38920f04   br-test09            bridge    local
9816f4fd95a3   bridge               bridge    local
790f8998f0f6   host                 host      local
a9347ae22f3e   minikube             bridge    local
ee746e6d9be7   none                 null      local
❯ ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           DOWN           192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
docker0          DOWN           172.17.0.1/16
br-d4c6d1af63d9  DOWN           192.168.49.1/24
br-4caf32131f3f  DOWN           192.168.59.1/24
br-bafaa95e04c9  DOWN           192.168.70.1/24
br-82697145172a  DOWN           192.168.82.1/24
br-3fb60e8289eb  DOWN           192.168.95.1/24
br-f6bd05bf4625  DOWN           192.168.109.1/24
br-f62e9c91fe42  DOWN           192.168.124.1/24
br-a4dc3444d406  DOWN           192.168.140.1/24
br-661f7a0277f9  DOWN           192.168.157.1/24
br-de4b38920f04  DOWN           192.168.175.1/24
❯ minikube start                             
stacklog: logging to stack.slog, sampling every 125ms
😄  minikube v1.17.1 on Opensuse-Tumbleweed 
✨  Automatically selected the docker driver. Other choices: kvm2, ssh
❗  docker is currently using the btrfs storage driver, consider switching to overlay2 for better performance
👍  Starting control plane node minikube in cluster minikube
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
stacklog: stopped. stored 428 samples to stack.slog
 ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           DOWN           192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
docker0          DOWN           172.17.0.1/16
br-d4c6d1af63d9  DOWN           192.168.49.1/24
br-4caf32131f3f  DOWN           192.168.59.1/24
br-bafaa95e04c9  DOWN           192.168.70.1/24
br-82697145172a  DOWN           192.168.82.1/24
br-3fb60e8289eb  DOWN           192.168.95.1/24
br-f6bd05bf4625  DOWN           192.168.109.1/24
br-f62e9c91fe42  DOWN           192.168.124.1/24
br-a4dc3444d406  DOWN           192.168.140.1/24
br-661f7a0277f9  DOWN           192.168.157.1/24
br-de4b38920f04  DOWN           192.168.175.1/24
br-a9347ae22f3e  UP             192.168.194.1/24

slowjam [oci.CreateNetwork] duration: 1 sec

[ '265: machine.timedCreateHost', 'oci.CreateNetwork', '#808000', new Date(1874), new Date(2874) ],

pull request

❯ docker network list
NETWORK ID     NAME                 DRIVER    SCOPE
46c634fb4fda   br-test00            bridge    local
2c6a49c30e38   br-test01            bridge    local
6c6ad70ee603   br-test02            bridge    local
83e070309643   br-test03            bridge    local
2cac664e256c   br-test04            bridge    local
8fd544819864   br-test05            bridge    local
bacded214b6b   br-test06            bridge    local
40d9ff702bdc   br-test07            bridge    local
57f7eb9a4178   br-test08            bridge    local
1c6e55082f96   br-test09            bridge    local
9816f4fd95a3   bridge               bridge    local
790f8998f0f6   host                 host      local
817b88552774   minikube             bridge    local
ee746e6d9be7   none                 null      local
❯ ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           DOWN           192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
br-08ada8d5dfa4  UP             172.22.0.1/16
docker0          DOWN           172.17.0.1/16
br-46c634fb4fda  DOWN           192.168.49.1/24
br-2c6a49c30e38  DOWN           192.168.59.1/24
br-6c6ad70ee603  DOWN           192.168.69.1/24
br-83e070309643  DOWN           192.168.79.1/24
br-2cac664e256c  DOWN           192.168.89.1/24
br-8fd544819864  DOWN           192.168.99.1/24
br-bacded214b6b  DOWN           192.168.109.1/24
br-40d9ff702bdc  DOWN           192.168.119.1/24
br-57f7eb9a4178  DOWN           192.168.129.1/24
br-1c6e55082f96  DOWN           192.168.139.1/24
❯ minikube start
stacklog: logging to stack.slog, sampling every 125ms
😄  minikube v1.17.1 on Opensuse-Tumbleweed
✨  Automatically selected the docker driver. Other choices: kvm2, ssh
❗  docker is currently using the btrfs storage driver, consider switching to overlay2 for better performance
👍  Starting control plane node minikube in cluster minikube
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
stacklog: stopped. stored 422 samples to stack.slog
❯ ip -4 -br -o a s
lo               UNKNOWN        127.0.0.1/8
virbr0           DOWN           192.168.122.1/24
wlp113s0         UP             192.168.42.17/24
docker0          DOWN           172.17.0.1/16
br-46c634fb4fda  DOWN           192.168.49.1/24
br-2c6a49c30e38  DOWN           192.168.59.1/24
br-6c6ad70ee603  DOWN           192.168.69.1/24
br-83e070309643  DOWN           192.168.79.1/24
br-2cac664e256c  DOWN           192.168.89.1/24
br-8fd544819864  DOWN           192.168.99.1/24
br-bacded214b6b  DOWN           192.168.109.1/24
br-40d9ff702bdc  DOWN           192.168.119.1/24
br-57f7eb9a4178  DOWN           192.168.129.1/24
br-1c6e55082f96  DOWN           192.168.139.1/24
br-817b88552774  UP             192.168.149.1/24

slowjam [oci.CreateNetwork] duration: 0.751 sec

[ '278: machine.timedCreateHost', 'oci.CreateNetwork', '#da70d6', new Date(1749), new Date(2500) ],

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 11, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @prezha. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 11, 2021
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 11, 2021
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@medyagh
Copy link
Member

medyagh commented Feb 11, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 11, 2021
pkg/drivers/kic/oci/network_create.go Outdated Show resolved Hide resolved
@minikube-pr-bot
Copy link

kvm2 Driver
error collecting results for kvm2 driver: timing run 0 with Minikube (PR 10439): timing cmd: [/home/performance-monitor/.minikube/minikube-binaries/10439/minikube start --driver=kvm2]: starting cmd: fork/exec /home/performance-monitor/.minikube/minikube-binaries/10439/minikube: exec format error
docker Driver
error collecting results for docker driver: timing run 0 with Minikube (PR 10439): timing cmd: [/home/performance-monitor/.minikube/minikube-binaries/10439/minikube start --driver=docker]: starting cmd: fork/exec /home/performance-monitor/.minikube/minikube-binaries/10439/minikube: exec format error

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 15, 2021
@minikube-pr-bot
Copy link

kvm2 Driver
Times for minikube: 69.1s 68.6s 67.6s
Average time for minikube: 68.4s

Times for Minikube (PR 10439): 71.0s 67.3s 69.3s
Average time for Minikube (PR 10439): 69.2s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.1s     | 0.0s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the kvm2 driver based  | 0.0s     | 0.0s                |
| on user configuration          |          |                     |
| * Starting control plane node  | 0.0s     | 0.0s                |
| minikube in cluster minikube   |          |                     |
| * Creating kvm2 VM (CPUs=2,    | 42.3s    | 41.7s               |
| Memory=3700MB, Disk=20000MB)   |          |                     |
| ...                            |          |                     |
| * Preparing Kubernetes v1.20.2 | 2.2s     | 2.2s                |
| on Docker 20.10.2 ...          |          |                     |
|   - Generating certificates    | 4.2s     | 5.4s                |
| and keys ...                   |          |                     |
|   - Booting up control plane   | 15.8s    | 15.8s               |
| ...                            |          |                     |
|   - Configuring RBAC rules ... | 1.5s     | 1.5s                |
| * Verifying Kubernetes         | 1.7s     | 1.7s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.6s     | 1.2s                |
| storage-provisioner,           |          |                     |
| default-storageclass           |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

docker Driver
Times for minikube: 27.4s 26.4s 26.3s
Average time for minikube: 26.7s

Times for Minikube (PR 10439): 25.8s 26.1s 27.3s
Average time for Minikube (PR 10439): 26.4s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.2s     | 0.2s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the docker driver      | 0.1s     | 0.1s                |
| based on user configuration    |          |                     |
| * Starting control plane node  | 0.1s     | 0.1s                |
| minikube in cluster minikube   |          |                     |
| * Creating docker container    | 10.1s    | 9.8s                |
| (CPUs=2, Memory=3700MB) ...    |          |                     |
| * Preparing Kubernetes v1.20.2 | 15.1s    | 15.1s               |
| on Docker 20.10.2 ...          |          |                     |
| * Verifying Kubernetes         | 1.0s     | 1.0s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.1s     | 0.1s                |
| storage-provisioner,           |          |                     |
| default-storageclass           |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

pkg/drivers/kic/oci/network_create.go Outdated Show resolved Hide resolved
pkg/util/network.go Outdated Show resolved Hide resolved
pkg/util/network.go Outdated Show resolved Hide resolved
pkg/drivers/kic/oci/network_create.go Outdated Show resolved Hide resolved
@minikube-pr-bot
Copy link

kvm2 Driver
Times for minikube: 72.5s 66.4s 69.5s
Average time for minikube: 69.5s

Times for Minikube (PR 10439): 67.9s 68.7s 67.5s
Average time for Minikube (PR 10439): 68.0s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.1s     | 0.0s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the kvm2 driver based  | 0.0s     | 0.0s                |
| on user configuration          |          |                     |
| * Starting control plane node  | 0.0s     | 0.0s                |
| minikube in cluster minikube   |          |                     |
| * Creating kvm2 VM (CPUs=2,    | 42.3s    | 42.3s               |
| Memory=3700MB, Disk=20000MB)   |          |                     |
| ...                            |          |                     |
| * Preparing Kubernetes v1.20.2 | 17.1s    | 2.1s                |
| on Docker 20.10.2 ...          |          |                     |
|   - Generating certificates    | 1.5s     | 4.1s                |
| and keys ...                   |          |                     |
|   - Booting up control plane   | 5.2s     | 15.8s               |
| ...                            |          |                     |
|   - Configuring RBAC rules ... | 0.9s     | 1.5s                |
| * Verifying Kubernetes         | 1.6s     | 1.7s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.5s     | 0.9s                |
| default-storageclass,          |          |                     |
| storage-provisioner            |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

docker Driver
Times for minikube: 31.8s 33.1s 35.8s
Average time for minikube: 33.6s

Times for Minikube (PR 10439): 31.9s 31.8s 26.6s
Average time for Minikube (PR 10439): 30.1s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.2s     | 0.2s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the docker driver      | 0.1s     | 0.1s                |
| based on user configuration    |          |                     |
| * Starting control plane node  | 0.1s     | 0.1s                |
| minikube in cluster minikube   |          |                     |
| * Creating docker container    | 16.5s    | 13.9s               |
| (CPUs=2, Memory=3700MB) ...    |          |                     |
| * Preparing Kubernetes v1.20.2 | 15.4s    | 14.8s               |
| on Docker 20.10.2 ...          |          |                     |
| * Verifying Kubernetes         | 1.2s     | 0.9s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.1s     | 0.1s                |
| storage-provisioner,           |          |                     |
| default-storageclass           |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

@minikube-pr-bot
Copy link

kvm2 Driver
Times for minikube: 71.7s 69.3s 71.5s
Average time for minikube: 70.8s

Times for Minikube (PR 10439): 70.3s 70.2s 69.5s
Average time for Minikube (PR 10439): 70.0s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.0s     | 0.0s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the kvm2 driver based  | 0.0s     | 0.0s                |
| on user configuration          |          |                     |
| * Starting control plane node  | 0.0s     | 0.0s                |
| minikube in cluster minikube   |          |                     |
| * Creating kvm2 VM (CPUs=2,    | 43.8s    | 42.3s               |
| Memory=3700MB, Disk=20000MB)   |          |                     |
| ...                            |          |                     |
| * Preparing Kubernetes v1.20.2 | 16.9s    | 2.3s                |
| on Docker 20.10.2 ...          |          |                     |
|   - Generating certificates    | 1.4s     | 4.9s                |
| and keys ...                   |          |                     |
|   - Booting up control plane   | 5.2s     | 16.3s               |
| ...                            |          |                     |
|   - Configuring RBAC rules ... | 1.0s     | 1.6s                |
| * Verifying Kubernetes         | 1.9s     | 1.7s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.6s     | 0.9s                |
| default-storageclass,          |          |                     |
| storage-provisioner            |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

docker Driver
Times for minikube: 28.1s 26.3s 25.7s
Average time for minikube: 26.7s

Times for Minikube (PR 10439): 26.1s 25.9s 26.0s
Average time for Minikube (PR 10439): 26.0s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.2s     | 0.2s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the docker driver      | 0.1s     | 0.1s                |
| based on user configuration    |          |                     |
| * Starting control plane node  | 0.1s     | 0.1s                |
| minikube in cluster minikube   |          |                     |
| * Creating docker container    | 10.4s    | 9.7s                |
| (CPUs=2, Memory=3700MB) ...    |          |                     |
| * Preparing Kubernetes v1.20.2 | 14.9s    | 14.8s               |
| on Docker 20.10.2 ...          |          |                     |
| * Verifying Kubernetes         | 0.9s     | 1.0s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.1s     | 0.1s                |
| storage-provisioner,           |          |                     |
| default-storageclass           |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

@prezha prezha requested a review from medyagh February 15, 2021 17:02
}

// FreeSubnet will try to find free private network beginning with startSubnet, incrementing it in steps up to number of tries.
func FreeSubnet(startSubnet string, step, tries int) (*Parameters, error) {
Copy link
Member

Choose a reason for hiding this comment

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

can u verify that this logic still works for Docker networks ?
manually create a docker network that is assigned to a dummy container
also we need to verify this does NOT add any slow down in minikube container create

to verify we can use Slow Jam https://github.com/google/slowjam

minikube supports setting the Stack Track that u can use with slowjam to generate the report

https://github.com/medyagh/minikube/blob/5359a6cea1398c3cc6e92d1c34260a8fdc3abe17/cmd/minikube/main.go#L64

Copy link
Contributor Author

@prezha prezha Feb 17, 2021

Choose a reason for hiding this comment

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

@medyagh i've verified that docker still works with conflicting networks (i've put some examples in the pr's description, but i've also added now another set according to your proposal - with dummy docker networks)

slow jam is a great tool, thank you for pointing out!

happy to report that this pr improves on speed 25% on 10 conflicting network attempts (added in the pr's description at the end) - this is expected as we are now calling oci.tryCreateDockerNetwork() for each address candidate and detect that the network is taken by failing there, we now first check if subnet is free and only then call oci.tryCreateDockerNetwork() just once to create docker network

@minikube-pr-bot
Copy link

kvm2 Driver
Times for minikube: 66.6s 69.1s 69.0s
Average time for minikube: 68.2s

Times for Minikube (PR 10439): 70.1s 66.5s 70.1s
Average time for Minikube (PR 10439): 68.9s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.0s     | 0.0s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the kvm2 driver based  | 0.0s     | 0.0s                |
| on user configuration          |          |                     |
| * Starting control plane node  | 0.0s     | 0.0s                |
| minikube in cluster minikube   |          |                     |
| * Creating kvm2 VM (CPUs=2,    | 42.8s    | 42.0s               |
| Memory=3700MB, Disk=20000MB)   |          |                     |
| ...                            |          |                     |
| * Preparing Kubernetes v1.20.2 | 15.9s    | 9.4s                |
| on Docker 20.10.2 ...          |          |                     |
|   - Generating certificates    | 1.3s     | 3.3s                |
| and keys ...                   |          |                     |
|   - Booting up control plane   | 5.4s     | 10.4s               |
| ...                            |          |                     |
|   - Configuring RBAC rules ... | 0.7s     | 1.2s                |
| * Verifying Kubernetes         | 1.5s     | 1.7s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.4s     | 0.8s                |
| default-storageclass,          |          |                     |
| storage-provisioner            |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

docker Driver
Times for minikube: 27.9s 27.3s 26.6s
Average time for minikube: 27.3s

Times for Minikube (PR 10439): 28.0s 26.1s 27.6s
Average time for Minikube (PR 10439): 27.2s

Averages Time Per Log

+--------------------------------+----------+---------------------+
|              LOG               | MINIKUBE | MINIKUBE (PR 10439) |
+--------------------------------+----------+---------------------+
| * minikube v1.17.1 on Debian   | 0.2s     | 0.2s                |
| 9.11 (kvm/amd64)               |          |                     |
| * Using the docker driver      | 0.1s     | 0.1s                |
| based on user configuration    |          |                     |
| * Starting control plane node  | 0.1s     | 0.1s                |
| minikube in cluster minikube   |          |                     |
| * Creating docker container    | 10.1s    | 10.4s               |
| (CPUs=2, Memory=3700MB) ...    |          |                     |
| * Preparing Kubernetes v1.20.2 | 15.6s    | 15.4s               |
| on Docker 20.10.2 ...          |          |                     |
| * Verifying Kubernetes         | 1.1s     | 1.0s                |
| components...                  |          |                     |
| * Enabled addons:              | 0.1s     | 0.1s                |
| storage-provisioner,           |          |                     |
| default-storageclass           |          |                     |
| * Done! kubectl is now         | 0.0s     | 0.0s                |
| configured to use "minikube"   |          |                     |
| cluster and "default"          |          |                     |
| namespace by default           |          |                     |
+--------------------------------+----------+---------------------+

@medyagh medyagh merged commit fb27ab7 into kubernetes:master Feb 20, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh, prezha

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 Feb 20, 2021
@medyagh medyagh changed the title prevent oci try to create overlapping network docker/podman: avoid creating overlapping networks with other tools (KVM,...) Feb 20, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Check KVM existing networks so that docker custom network doesn't overlap
5 participants