Skip to content

bug: IPPrefix utilization drops to 0 on a newly created branch #9220

Description

@FragmentedPacket

Component

API Server / GraphQL

Infrahub version

1.9.3

Current Behavior

When an IpamIPPrefix reports non-zero utilization on main, creating a new branch from main causes the same prefix to report utilization: 0 on the branch — even though no data has been modified.

The effect shows up on every prefix that had non-zero utilization on main: a fully populated /32 sub-prefix (with its host IpamIPAddress assigned) and its /24 parent both flip to 0 on the branch. The exact percentages aren't the point — utilization values are not preserved on branch creation.

Expected Behavior

A freshly created branch should report the same utilization as main until data on the branch is modified.

Steps to Reproduce

  1. Load the models/base/ipam.yml schema, which provides IpamIPPrefix and IpamIPAddress (inheriting from BuiltinIPPrefix / BuiltinIPAddress):

    infrahubctl schema load models/base/ipam.yml
  2. Load the following objects on main:

    ---
    apiVersion: infrahub.app/v1
    kind: Object
    spec:
      kind: IpamIPPrefix
      data:
        - prefix: 10.100.0.0/24
          description: "Parent /24 — container for /32 sub-prefixes"
          member_type: prefix
    
    ---
    apiVersion: infrahub.app/v1
    kind: Object
    spec:
      kind: IpamIPPrefix
      data:
        - prefix: 10.100.0.1/32
          member_type: address
        - prefix: 10.100.0.2/32
          member_type: address
        - prefix: 10.100.0.3/32
          member_type: address
        - prefix: 10.100.0.4/32
          member_type: address
    
    ---
    apiVersion: infrahub.app/v1
    kind: Object
    spec:
      kind: IpamIPAddress
      data:
        - address: 10.100.0.1/32
        - address: 10.100.0.2/32
        - address: 10.100.0.3/32
        - address: 10.100.0.4/32
    infrahubctl object load ipam_utilization_bug_repro.yml
  3. Open the IPAM view at http://localhost:8000/ipam on main — the /24 and each /32 sub-prefix show non-zero utilization.

  4. Create a new branch:

    infrahubctl branch create test-1
  5. In the same IPAM view, switch the branch selector to test-1. Every prefix that reported non-zero utilization on main now reports 0 on test-1, while main is unchanged.

Additional Information

  • IPPrefix.utilization, IPPrefix.ip_addresses, and IPAddress.ip_prefix are all declared read_only=True with allow_override=NONE in backend/infrahub/core/schema/definitions/core/ipam.py (lines 116-122, 166-175, 219-228). The hierarchical prefix→address association is computed, not stored.
  • The sub-prefix and address objects themselves remain visible on the branch — only the utilization value is affected.

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expected

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions