Skip to content

IPpools with identical NamePrefix fail IPAddress allocation due to name collision #1437

Description

@peppi-lotta

What steps did you take and what happened:

# Create cluster
kind create cluster
clusterctl init --infrastructure docker --ipam metal3


# Create namespace, IPPool and IPClaim
kubectl create namespace test-ns

kubectl apply -f - <<EOF
apiVersion: ipam.metal3.io/v1alpha1
kind: IPPool
metadata:
  name: ippool-a
  namespace: test-ns
spec:
  namePrefix: "a-prefix"
  pools:
    - start: "192.168.1.10"
      end: "192.168.1.100"
      subnet: "192.168.1.0/24"
      prefix: 24
      gateway: "192.168.1.1"
  prefix: 24
  gateway: "192.168.1.1"
---
apiVersion: ipam.metal3.io/v1alpha1
kind: IPClaim
metadata:
  name: a-claim
  namespace: test-ns
spec:
  pool:
    name: ippool-a
    namespace: test-ns
EOF

# Create second pool with same name prefix and ip range. 
# Observe how creating the second claim silently fails
kubectl apply -f - <<EOF
apiVersion: ipam.metal3.io/v1alpha1
kind: IPPool
metadata:
  name: ippool-b
  namespace: test-ns
spec:
  namePrefix: "a-prefix"       # <-- duplicates IPPool-A
  pools:
    - start: "192.168.1.10"
      end: "192.168.1.10"
      prefix: 24
---
apiVersion: ipam.metal3.io/v1alpha1
kind: IPClaim
metadata:
  name: b-claim
  namespace: test-ns
spec:
  pool:
    name: ippool-b
    namespace: test-ns
EOF

kubectl describe ippool -n test-ns ippool-b
# Does not show event for IPAddress creation

kubectl describe ipclaim -n test-ns b-claim
# Doesn not show allocated IP

kubectl get ipaddress.ipam.metal3.io -n test-ns
# Shows only one IPAddress
# NAME                    AGE
# a-prefix-192-168-1-10   8m48s

What did you expect to happen:
I expect there to be no silent failures.

Anything else you would like to add:
The issue happens because Kubernetes API prevents creating object with same kind/name/namespace combos. IPaddress name is created based on IPPool namePrefex and allocated IP.

Environment:

  • Cluster-api version: 1.13
  • IPAM version: 1.13
  • environment: kind cluster with clusterctl init --infrastructure docker --ipam metal3

/kind bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.priority/critical-urgentHighest priority. Must be actively worked on as someone's top priority right now.triage/acceptedIndicates an issue is ready to be actively worked on.

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions