chainguard-dev/actions

metallb setup fails in Kind action

Closed this issue · 3 comments

See here. This probably started failing on ubuntu-latest (there is a runner image update happening) due to some docker upgrade?

Error from server (parsing address pool config: invalid CIDR "fc00:f853:ccd:e793::/64.255.1-fc00:f853:ccd:e793::/64.255.250" in pool "config": invalid IP range "fc00:f853:ccd:e793::/64.255.1-fc00:f853:ccd:e793::/64.255.250": invalid start IP "fc00:f853:ccd:e793::/64.255.1"): error when creating "./metallb-crds.yaml": admission webhook "ipaddresspoolvalidationwebhook.metallb.io" denied the request: parsing address pool config: invalid CIDR "fc00:f853:ccd:e793::/64.255.1-fc00:f853:ccd:e793::/64.255.250" in pool "config": invalid IP range "fc00:f853:ccd:e793::/64.255.1-fc00:f853:ccd:e793::/64.255.250": invalid start IP "fc00:f853:ccd:e793::/64.255.1"

Getting the net config is not valid anymore as it needs to use the second index.
The following should do the trick (tested locally), not sure about compatibility across envs:

"$(docker network inspect kind -f '{{.IPAM.Config}}' |  grep -Po '(\d+\.){3}\d+' | head -n 1 | cut -d '.' -f1,2)"

@skonto tested on MacOS, does not work there:

grep: invalid option -- P

But should not be relevant, as this is only used on GH actions anyway. Alternative could be to use jq (which is included in the GH runner images)

network=$(docker network inspect kind | jq -r '.[0].IPAM.Config[] | select(.Subnet | test("^[0-9]+\\.")) | .Subnet' | cut -d '.' -f1,2)

Tested here.

@skonto do you want to PR your changes to fix this?

-P is for gnu grep. Yeah I thought about jq bu wast not sure if all runner images have it, as probably the repo is used elsewhere, besides Serving. It seems they have it with some version diff.

Also this should work:

docker network inspect kind -f '{{json .}}' | jq -r '.IPAM.Config.[].Subnet | select(. | contains("::") | not)' |  cut -d '.' -f1,2

or

docker network inspect kind -f '{{json .}}' | jq -r '.IPAM.Config.[].Subnet | select(. | test("^[0-9]+\\."))' |  cut -d '.' -f1,2

I will go with the latter, I will create a PR shortly.