whereabouts icon indicating copy to clipboard operation
whereabouts copied to clipboard

[BUG] Using the range from-to syntax, some IPv6 addresses fail

Open dougbtv opened this issue 3 years ago • 0 comments

Describe the bug The "range" configuration parameter allows addresses in a from-to format, e.g.

"range": "2001:d3ad:b33f:f00d:d00d:d00d:000:0000-2001:d3ad:b33f:f00d:d00d:d00d:0000:0004/64",

Which would allocate 5 IPv6 addresses. Some IPv6 addresses however, wind up parsing into a name key for the CRD names that are invalid. With the above range resulting in an error such as:

Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create pod network sandbox k8s_samplepod_default_3f6249c4-191e-44ea-9ef3-f5d8b5d707a6_0(a2dd58c84fcf5069c52b2c229d66639f1e8fd510f1b8a05058e25d89666944fd): error adding pod default_samplepod to CNI network "multus-cni-network": plugin type="multus" name="multus-cni-network" failed (add): [default/samplepod/3f6249c4-191e-44ea-9ef3-f5d8b5d707a6:wb-rangeerror-conf]: error adding container to network "wb-rangeerror-conf": error at storage engine: OverlappingRangeIPReservation.whereabouts.cni.cncf.io "2001-d3ad-b33f-f00d-d00d-d00d--" is invalid: metadata.name: Invalid value: "2001-d3ad-b33f-f00d-d00d-d00d--": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Expected behavior Parses properly.

To Reproduce Steps to reproduce the behavior, use this set of yaml:

---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: macvlan-conf
spec:
  config: '{
	"cniVersion": "0.3.1",
	"name": "wb-rangeerror-conf",
	"plugins": [{
		"type": "macvlan",
		"master": "eth0",
		"mode": "bridge",
		"ipam": {
			"type": "whereabouts",
			"range": "2001:d3ad:b33f:f00d:d00d:d00d:000:0000-2001:d3ad:b33f:f00d:d00d:d00d:0000:0004/64",
			"gateway": "2001:d3ad:b33f:f00d::1"
		}
	}]
}'
---
apiVersion: v1
kind: Pod
metadata:
  name: samplepod
  annotations:
    k8s.v1.cni.cncf.io/networks: macvlan-conf
spec:
  containers:
  - name: samplepod
    command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
    image: alpine

Environment:

  • Whereabouts version : master
  • Kubernetes version (use kubectl version): v1.23.6
  • OS (e.g. from /etc/os-release): Fedora 35

dougbtv avatar Aug 18 '22 11:08 dougbtv