diff --git a/flannel.yaml b/flannel.yaml index 8bb23c6d806..5f75e14c0ed 100644 --- a/flannel.yaml +++ b/flannel.yaml @@ -1,7 +1,7 @@ package: name: flannel version: "0.26.5" - epoch: 3 + epoch: 4 description: flannel is a network fabric for containers, designed for Kubernetes copyright: - license: Apache-2.0 @@ -34,8 +34,8 @@ pipeline: if [ "$(go env GOARCH)" = "amd64" ]; then CGO_ENABLED=1 fi - CGO_ENABLED=$(CGO_ENABLED) go build -o "${{targets.destdir}}"/usr/bin/flanneld \ - -ldflags '-extldflags "-static" -X github.com/flannel-io/flannel/pkg/version.version=${{package.version}}' + CGO_ENABLED=$CGO_ENABLED go build -o "${{targets.destdir}}"/usr/bin/flanneld \ + -ldflags "-extldflags \"-static\" -X github.com/flannel-io/flannel/pkg/version.Version=${{package.version}}" update: enabled: true @@ -44,8 +44,79 @@ update: strip-prefix: v test: + environment: + contents: + packages: + - ${{package.name}} + - etcd + - jq + - iproute2 pipeline: - # AUTOGENERATED - - runs: | - flanneld --version - flanneld --help + - name: "Test flanneld daemon output" + uses: test/daemon-check-output + with: + setup: | + #!/bin/sh -ex + # Start etcd in background with proper networking configuration + mkdir -p /tmp/etcd-data + etcd --data-dir=/tmp/etcd-data \ + --listen-client-urls=http://127.0.0.1:2379 \ + --advertise-client-urls=http://127.0.0.1:2379 > /tmp/etcd.log 2>&1 & + ETCD_PID=$! + + # Ensure etcd is ready before proceeding + for i in 1 2 3 4 5; do + if etcdctl --endpoints=http://127.0.0.1:2379 endpoint status --write-out=table; then + break + fi + sleep 1 + done + + # Store flannel network config in etcd + printf "{\"Network\": \"10.244.0.0/16\", \"Backend\": {\"Type\": \"host-gw\"}}" > /tmp/flannel-config.json + etcdctl --endpoints=http://127.0.0.1:2379 put /coreos.com/network/config "$(cat /tmp/flannel-config.json)" + + # Save PID for cleanup + echo "export ETCD_PID=$ETCD_PID" > /tmp/env.sh + # Disable iptables to avoid permission issues in unprivileged test environments and focus testing on core networking capabilities + start: | + sleep 3 + IFACE=$(ip -json route show default | jq -r '.[0].dev') + echo "export IFACE=$IFACE" >> /tmp/env.sh + flanneld --etcd-endpoints=http://127.0.0.1:2379 --iface=$IFACE --iptables-forward-rules=false + sleep 3 + IFACE=$(ip -json route show default | jq -r '.[0].dev') + echo "export IFACE=$IFACE" >> /tmp/env.sh + flanneld --etcd-endpoints=http://127.0.0.1:2379 --iface=$IFACE --iptables-forward-rules=false + timeout: 10 + expected_output: | + Created subnet manager + error_strings: | + "msg":"error connecting to etcd" + "level":"error" .* "could not create subnet manager" + "panic" + "fatal" + "Failed" + "Error: could not access etcd" + "error: could not allocate lease" + post: | + #!/bin/sh -ex + # Load etcd PID from setup phase + . /tmp/etcd_pid.sh + + # Verify flannel created the proper subnet configuration + if [ ! -f /run/flannel/subnet.env ]; then + echo "Subnet file not found" + exit 1 + fi + grep -q "FLANNEL_SUBNET=" /run/flannel/subnet.env ++ # Check leases: https://github.com/flannel-io/flannel/blob/b73b907459f317a25ba589c233784517eacf260c/Documentation/reservations.md#leases ++ LEASE_SUBNET_ETCD_KEY=$(etcdctl get /coreos.com/network/subnets --prefix --keys-only) ++ LEASE_PUBLIC_IP=$(etcdctl get $LEASE_SUBNET_ETCD_KEY --print-value-only=true | jq '.PublicIP' | tr -d "\"") ++ ++ LEASE_ETCD_LEASE_ID=$(etcdctl lease list | tail -1) ++ etcdctl lease timetolive --keys $LEASE_ETCD_LEASE_ID | grep $LEASE_SUBNET_ETCD_KEY ++ ip address show $IFACE | grep $LEASE_PUBLIC_IP ++ ip route get $LEASE_PUBLIC_IP + # Cleanup etcd process + kill $ETCD_PID || true