You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug report is not security related, security issues should be disclosed privately via netbox operator maintainers.
Existing open issues have been checked and this is not a duplicate.
What happened?
If there is a mismatch of .spec.prefixLength and the prefix length of the Prefix in NetBox that would be restored, it will restore it and the PrefixClaim/Prefix in the Kubernetes API will inconsistent (.spec.prefixLength and the length of .status.prefix don't match).
What did you expect to happen?
The Prefix should not be restored, the controller should have failed. RestoreExistingPrefixByHash() should contain a check and return an error if the length does not match.
How can we reproduce it (as minimally and precisely as possible)?
Make sure config/samples/netbox_v1_prefixclaim.yaml has preserveInNetbox set to true.
# Create the PrefixClaim
kubectl apply -f config/samples/netbox_v1_prefixclaim.yaml
# Make sure .spec.prefixLength matches with the mask
kubectl get px,pxc
NAME PREFIX READY ID URL
prefix.netbox.dev/prefixclaim-sample 2.0.4.0/28 True 104 http://netbox.default.svc.cluster.local/ipam/prefixes/104
NAME PREFIX READY PREFIXASSIGNED
prefixclaim.netbox.dev/prefixclaim-sample 2.0.4.0/28 True True
# Delete the PrefixClaim
kubectl delete -f config/samples/netbox_v1_ipaddressclaim.yaml
# Then manually change the Prefix Length in NetBox (e.g. to /24)# Apply the sample PrefixClaim again ("restore" the PrefixClaim)
kubectl apply -f config/samples/netbox_v1_prefixclaim.yaml
# Now the PrefixClaim has the wrong mask!
kubectl get px,pxc
NAME PREFIX READY ID URL
prefix.netbox.dev/prefixclaim-sample 2.0.4.0/24 True 104 http://netbox.default.svc.cluster.local/ipam/prefixes/104
NAME PREFIX READY PREFIXASSIGNED
prefixclaim.netbox.dev/prefixclaim-sample 2.0.4.0/24 True True
# Or more detailed (shortened):
kubectl get pxc prefixclaim-sample -oyaml
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-sample
namespace: default
spec:
parentPrefix: 2.0.0.0/16
prefixLength: /28
preserveInNetbox: true
status:
conditions:
- lastTransitionTime: "2024-10-01T10:40:35Z"
message: New prefix fetched from NetBox and prefix CR was created
reason: PrefixCRCreated
status: "True"
type: PrefixAssigned
- lastTransitionTime: "2024-10-01T10:40:36Z"
message: PrefixClaim Resource is ready
reason: PrefixClaimResourceReady
status: "True"
type: Ready
prefix: 2.0.4.0/24
Bug report criteria
What happened?
If there is a mismatch of .spec.prefixLength and the prefix length of the Prefix in NetBox that would be restored, it will restore it and the PrefixClaim/Prefix in the Kubernetes API will inconsistent (.spec.prefixLength and the length of .status.prefix don't match).
What did you expect to happen?
The Prefix should not be restored, the controller should have failed.
RestoreExistingPrefixByHash()
should contain a check and return an error if the length does not match.How can we reproduce it (as minimally and precisely as possible)?
Make sure
config/samples/netbox_v1_prefixclaim.yaml
haspreserveInNetbox
set totrue
.Netbox operator version
docker pull ghcr.io/netbox-community/netbox-operator:sha-d3d6f7e
Netbox operator configuration (command line flags or environment variables)
No response
Relevant log output
No response
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: