Fail pod create correctly when ANNOTATE_POD_IP is configured with No IPs in datastore
jayanthvn opened this issue · 3 comments
What happened:
When IP address is not available in IPAMD we see the below error in logs -
DataStore has no available IP/Prefix addresses
And we return non-nil error -
amazon-vpc-cni-k8s/pkg/ipamd/rpc_handler.go
Line 152 in d49c8a3
"", -1, errors.New("assignPodIPv4AddressUnsafe: no available IP/Prefix addresses")
When ANNOTATE_POD_IP is not configured then we just return non-nil and CNI will fail add.
But when ANNOTATE_POD_IP is configured -
amazon-vpc-cni-k8s/pkg/ipamd/rpc_handler.go
Lines 182 to 202 in d49c8a3
We end up overwriting the "err" hence we would see this log with err overwritten with "nil" -
{"level":"info","ts":"2023-11-02T23:00:02.817Z","caller":"rpc/rpc.pb.go:713","msg":"Send AddNetworkReply: IPv4Addr , IPv6Addr: , DeviceNumber: -1, err: <nil>"}
Hence we will not land here - https://github.com/aws/amazon-vpc-cni-k8s/blob/master/cmd/routed-eni-cni-plugin/cni.go#L178-L182
Leading to setupPodNetwork with nil IP.
{"level":"error","ts":"2023-11-02T23:00:02.818Z","caller":"routed-eni-cni-plugin/cni.go:126","msg":"Failed SetupPodNetwork for container ********:
SetupPodNetwork:
failed to setup veth pair: failed to setup veth network: setup NS network:
failed to add default gateway: one of Dst.IP, Src, or Gw must not be nil"}
Attach logs
What you expected to happen:
Check non-nil err or device -1 or nil IP here -
amazon-vpc-cni-k8s/pkg/ipamd/rpc_handler.go
Line 182 in d49c8a3
How to reproduce it (as minimally and precisely as possible):
Exhaust IP and have ANNOTATE_POD_IP set
Anything else we need to know?: N/A
Environment:
- Kubernetes version (use
kubectl version
): - CNI Version
- OS (e.g:
cat /etc/os-release
): - Kernel (e.g.
uname -a
):
Nice catch, yeah this needs a guard
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.