Skip to content

Commit

Permalink
gha: Only retrieve IPv4 CIDR from docker network
Browse files Browse the repository at this point in the history
[ upstream commit b49f912 ]

[ backporter's notes: hit conflicts due to the usage of MetalLB rather
  than Cilium LB. Preserved the main hunk, and adapted the debug output. ]

It seems like github runner is enabled with docker dual stack, so the
current docker network inspect command might return IPv6 instead of
IPv6 CIDR, which breaks LB IPPool configuration. Sample output of
`docker network inspect kind` command can be found as per below.

This commit is to make sure that we only retrieve IPv4 CIDR in docker
network inspect command. Additionally, some echo/cat statement are added
to make similar issue more visible in the future.

```
[
    {
        "Name": "kind",
        "Id": "43e3b3267092150f5f2e6f2053157d912ad6b5a4ce20f700e1e9be547a437f75",
        "Created": "2024-06-12T14:18:17.733107881Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": true,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "fc00:f853:ccd:e793::/64"
                },
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "748d7161857ca5e610f196299828eacafcbdb069d38c00e4e6c14cdeefada9c5": {
                "Name": "chart-testing-control-plane",
                "EndpointID": "0f1a5bbeb14929200ed13cb289afd6bf5f9f455d4ed75bb3a26e167e67bf7784",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": "fc00:f853:ccd:e793::2/64"
            },
            "c2030425e24a11ea208b87c5d70e194b0f51eee133f09b67404fd2bf97410f13": {
                "Name": "chart-testing-worker",
                "EndpointID": "81489bd101e483be7270e2b5dd7e0bf3a0163b89650d7ef69cc4ce43454479e3",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": "fc00:f853:ccd:e793::3/64"
            }
        },
        "Options": {
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]
```

Signed-off-by: Tam Mach <tam.mach@cilium.io>
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
  • Loading branch information
sayboras authored and giorio94 committed Jun 13, 2024
1 parent 04f12e1 commit 0b108ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/conformance-gateway-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ jobs:
- name: Install metallb for LB service
timeout-minutes: 10
run: |
KIND_NET_CIDR=$(docker network inspect kind -f '{{(index .IPAM.Config 0).Subnet}}')
KIND_NET_CIDR=$(docker network inspect kind -f '{{json .IPAM.Config}}' | jq -r '.[] | select(.Subnet | test("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+")) | .Subnet')
echo "KIND_NET_CIDR: $KIND_NET_CIDR"
METALLB_IP_START=$(echo ${KIND_NET_CIDR} | sed "s@0.0/16@255.200@")
METALLB_IP_END=$(echo ${KIND_NET_CIDR} | sed "s@0.0/16@255.250@")
METALLB_IP_RANGE="${METALLB_IP_START}-${METALLB_IP_END}"
Expand All @@ -197,7 +198,8 @@ jobs:
psp:
create: false
EOF
cat metallb_values.yaml
helm install --namespace metallb-system \
--create-namespace \
--repo https://metallb.github.io/metallb metallb metallb \
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/conformance-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ jobs:
- name: Install metallb for LB service
timeout-minutes: 10
run: |
KIND_NET_CIDR=$(docker network inspect kind -f '{{(index .IPAM.Config 0).Subnet}}')
KIND_NET_CIDR=$(docker network inspect kind -f '{{json .IPAM.Config}}' | jq -r '.[] | select(.Subnet | test("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+")) | .Subnet')
echo "KIND_NET_CIDR: $KIND_NET_CIDR"
METALLB_IP_START=$(echo ${KIND_NET_CIDR} | sed "s@0.0/16@255.200@")
METALLB_IP_END=$(echo ${KIND_NET_CIDR} | sed "s@0.0/16@255.250@")
METALLB_IP_RANGE="${METALLB_IP_START}-${METALLB_IP_END}"
Expand All @@ -208,7 +209,8 @@ jobs:
psp:
create: false
EOF
cat metallb_values.yaml
helm install --namespace metallb-system \
--create-namespace \
--repo https://metallb.github.io/metallb metallb metallb \
Expand Down

0 comments on commit 0b108ad

Please sign in to comment.