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

support ancient versions of docker again (template parsing issue) #10362

Closed
medyagh opened this issue Feb 4, 2021 · 6 comments · Fixed by #10369
Closed

support ancient versions of docker again (template parsing issue) #10362

medyagh opened this issue Feb 4, 2021 · 6 comments · Fixed by #10369
Assignees
Labels
co/docker-driver Issues related to kubernetes in container kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@medyagh
Copy link
Member

medyagh commented Feb 4, 2021

we broke it since 16.01

the ancient verions of docker 18.09.7 fails at template parse

cmd := exec.Command(Docker, "network", "inspect", name, "--format", `{"Name": "{{.Name}}","Driver": "{{.Driver}}","Subnet": "{{range .IPAM.Config}}{{.Subnet}}{{end}}","Gateway": "{{range .IPAM.Config}}{{.Gateway}}{{end}}","MTU": {{if (index .Options "com.docker.network.driver.mtu")}}{{(index .Options "com.docker.network.driver.mtu")}}{{else}}0{{end}},{{$first := true}} "ContainerIPs": [{{range $k,$v := .Containers }}{{if $first}}{{$first = false}}{{else}}, {{end}}"{{$v.IPv4Address}}"{{end}}]}`)

errors out:

Template parsing error: template: :1: unexpected "=" in operand
@medyagh medyagh added this to the v1.18.0 milestone Feb 4, 2021
@medyagh medyagh added kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Feb 4, 2021
@medyagh medyagh modified the milestones: v1.18.0, v.1.19.0-candidate Feb 4, 2021
@medyagh medyagh changed the title support ancient versions of docker again support ancient versions of docker again (template parsing issue) Feb 4, 2021
@afbjorklund
Copy link
Collaborator

afbjorklund commented Feb 4, 2021

@medyagh : you should upgrade to 18.09.9, only the latest minor version in each track is "supported"

20.10

https://docs.docker.com/engine/release-notes/

20.10.3

2021-02-01

19.03

https://docs.docker.com/engine/release-notes/19.03/

19.03.15

2021-02-01

18.09 (tolerated)

https://docs.docker.com/engine/release-notes/18.09/

18.09.9

2019-09-03

18.06 (unsupported)

https://docs.docker.com/engine/release-notes/18.06/

18.06.3-ce

2019-02-19

Obsolete


Similar to #9077 but also very much related to #10089

@afbjorklund afbjorklund added the co/docker-driver Issues related to kubernetes in container label Feb 4, 2021
@prezha
Copy link
Contributor

prezha commented Feb 4, 2021

i'll have a look
/assign

@prezha
Copy link
Contributor

prezha commented Feb 4, 2021

@afbjorklund is right - it works with the latest v18.09 patch version 9:


v18.09.7 fails:

Client: Docker Engine - Community
 Version:           18.09.7
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        2d0083d
 Built:             Thu Jun 27 17:54:15 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.9
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.11.13
  Git commit:       039a7df9ba
  Built:            Wed Sep  4 16:55:50 2019
  OS/Arch:          linux/amd64
  Experimental:     false
❯ minikube start
😄  minikube v1.17.1 on Opensuse-Tumbleweed
✨  Automatically selected the docker driver. Other choices: kvm2, ssh
💨  For improved Docker performance, enable the overlay Linux kernel module using 'modprobe overlay'
❗  docker is currently using the btrfs storage driver, consider switching to overlay2 for better performance
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
❗  This container is having trouble accessing https://k8s.gcr.io
💡  To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...| E0204 15:32:19.529662    6891 start.go:99] Unable to get host IP: network inspect: docker network inspect minikube --format "{"Name": "{{.Name}}","Driver": "{{.Driver}}","Subnet": "{{range .IPAM.Config}}{{.Subnet}}{{end}}","Gateway": "{{range .IPAM.Config}}{{.Gateway}}{{end}}","MTU": {{if (index .Options "com.docker.network.driver.mtu")}}{{(index .Options "com.docker.network.driver.mtu")}}{{else}}0{{end}},{{$first := true}} "ContainerIPs": [{{range $k,$v := .Containers }}{{if $first}}{{$first = false}}{{else}}, {{end}}"{{$v.IPv4Address}}"{{end}}]}": exit status 64
stdout:

stderr:
Template parsing error: template: :1: unexpected "=" in operand
E0204 15:32:19.530306    6891 out.go:330] unable to execute Failed to setup kubeconfig: network inspect: docker network inspect minikube --format "{"Name": "{{.Name}}","Driver": "{{.Driver}}","Subnet": "{{range .IPAM.Config}}{{.Subnet}}{{end}}","Gateway": "{{range .IPAM.Config}}{{.Gateway}}{{end}}","MTU": {{if (index .Options "com.docker.network.driver.mtu")}}{{(index .Options "com.docker.network.driver.mtu")}}{{else}}0{{end}},{{$first := true}} "ContainerIPs": [{{range $k,$v := .Containers }}{{if $first}}{{$first = false}}{{else}}, {{end}}"{{$v.IPv4Address}}"{{end}}]}": exit status 64
stdout:

stderr:
Template parsing error: template: :1: unexpected "=" in operand
: template: Failed to setup kubeconfig: network inspect: docker network inspect minikube --format "{"Name": "{{.Name}}","Driver": "{{.Driver}}","Subnet": "{{range .IPAM.Config}}{{.Subnet}}{{end}}","Gateway": "{{range .IPAM.Config}}{{.Gateway}}{{end}}","MTU": {{if (index .Options "com.docker.network.driver.mtu")}}{{(index .Options "com.docker.network.driver.mtu")}}{{else}}0{{end}},{{$first := true}} "ContainerIPs": [{{range $k,$v := .Containers }}{{if $first}}{{$first = false}}{{else}}, {{end}}"{{$v.IPv4Address}}"{{end}}]}": exit status 64
stdout:

stderr:
Template parsing error: template: :1: unexpected "=" in operand
:1:253: executing "Failed to setup kubeconfig: network inspect: docker network inspect minikube --format \"{\"Name\": \"{{.Name}}\",\"Driver\": \"{{.Driver}}\",\"Subnet\": \"{{range .IPAM.Config}}{{.Subnet}}{{end}}\",\"Gateway\": \"{{range .IPAM.Config}}{{.Gateway}}{{end}}\",\"MTU\": {{if (index .Options \"com.docker.network.driver.mtu\")}}{{(index .Options \"com.docker.network.driver.mtu\")}}{{else}}0{{end}},{{$first := true}} \"ContainerIPs\": [{{range $k,$v := .Containers }}{{if $first}}{{$first = false}}{{else}}, {{end}}\"{{$v.IPv4Address}}\"{{end}}]}\": exit status 64\nstdout:\n\nstderr:\nTemplate parsing error: template: :1: unexpected \"=\" in operand\n" at <index .Options "com.docker.network.driver.mtu">: error calling index: index of untyped nil - returning raw string.


❌  Exiting due to GUEST_START: Failed to setup kubeconfig: network inspect: docker network inspect minikube --format "{"Name": "{{.Name}}","Driver": "{{.Driver}}","Subnet": "{{range .IPAM.Config}}{{.Subnet}}{{end}}","Gateway": "{{range .IPAM.Config}}{{.Gateway}}{{end}}","MTU": {{if (index .Options "com.docker.network.driver.mtu")}}{{(index .Options "com.docker.network.driver.mtu")}}{{else}}0{{end}},{{$first := true}} "ContainerIPs": [{{range $k,$v := .Containers }}{{if $first}}{{$first = false}}{{else}}, {{end}}"{{$v.IPv4Address}}"{{end}}]}": exit status 64
stdout:

stderr:
Template parsing error: template: :1: unexpected "=" in operand


😿  If the above advice does not help, please let us know:
👉  https://github.com/kubernetes/minikube/issues/new/choose

v18.09.9 works:

❯ docker version
Client: Docker Engine - Community
 Version:           18.09.9
 API version:       1.39
 Go version:        go1.11.13
 Git commit:        039a7df9ba
 Built:             Wed Sep  4 16:50:02 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.9
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.11.13
  Git commit:       039a7df9ba
  Built:            Wed Sep  4 16:55:50 2019
  OS/Arch:          linux/amd64
  Experimental:     false
❯ minikube start
😄  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
🚜  Pulling base image ...
🔥  Creating docker container (CPUs=2, Memory=16000MB) ...
❗  This container is having trouble accessing https://k8s.gcr.io
💡  To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

i'll see if we can easily cover/support v18.09.7 as well

@afbjorklund
Copy link
Collaborator

afbjorklund commented Feb 4, 2021

If we want to support the older / system versions, then most likely that inspect code needs a fallback...

For instance you could dump the whole thing as JSON, and then do the complex parsing in Go instead ?

@medyagh
Copy link
Member Author

medyagh commented Feb 4, 2021

If we want to support the older / system versions, then most likely that inspect code needs a fallback...

yeah I recommend we have a fall back dokcer network insepect that if the first one fails we use the other one.
there are many corps and user who HAVE to use the old ubuntu 16.04 for tech-debt reasons (needing python2) so we wanna still allow them use minikube (but still warn them that plz updgrade ur docker)

@prezha
Copy link
Contributor

prezha commented Feb 5, 2021

ok, i think i've found the problem - for this and several other issues mentioning Template parsing error: template: :1: unexpected "=" in operand / exit status 64 (eg, #9811, #10036, #10282, #10323, etc)

namely, the above error refers to the go template parsing process and manifests with docker v18.09.7 (and older); that specific docker version uses go v1.10.8, and = operator, as used in dockerInsepctGetter for docker network inspect <name> --format, is supported only from go v1.11 onwards (ref: https://golang.org/doc/go1.11#text/template)

i've removed the workaround using = operator to avoid extra , at the end of the slice in parsed ContainerIPs and removed it in the dockerInsepctGetter itself, after the parsing is done and before returning the value

pr will follow shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/docker-driver Issues related to kubernetes in container kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants