Skip to content

bug: prefix pool assigning same prefix multiple times #981

@BaptisteGi

Description

@BaptisteGi

Component

Python SDK

Infrahub SDK version

1.20.0

Current Behavior

I have a generator that consumes pools and prefixes. Somehow the pool can allocate multiple times the same prefix:

❯   uv run infrahubctl generator site_pool_generator --branch=test-123456 name=placeholder-site
Allocated underlay prefix `172.16.0.156/30` for identifier `underlay_leafs`
Allocated prefix `172.16.0.156/30` from pool `placeholder-site-underlay_leafs-pool` for identifier `underlay_leafs-sub-1`
Allocated prefix `172.16.0.156/30` from pool `placeholder-site-underlay_leafs-pool` for identifier `underlay_leafs-sub-2`
Allocated underlay prefix `172.16.0.160/30` for identifier `underlay_spines`
Allocated prefix `172.16.0.160/30` from pool `placeholder-site-underlay_spines-pool` for identifier `underlay_spines-sub-1`
Allocated prefix `172.16.0.160/30` from pool `placeholder-site-underlay_spines-pool` for identifier `underlay_spines-sub-2`
Allocated underlay prefix `172.16.0.164/30` for identifier `underlay_oob`
Allocated prefix `172.16.0.164/30` from pool `placeholder-site-underlay_oob-pool` for identifier `underlay_oob-sub-1`
Allocated prefix `172.16.0.164/30` from pool `placeholder-site-underlay_oob-pool` for identifier `underlay_oob-sub-2`

Expected Behavior

I guess pool should return a "no more resource available" kind of message.

Steps to Reproduce

  • Load this schema uv run infrahubctl schema load site_pool_schema.yml

site_pool_schema.yml

  • Load objects uv run infrahubctl object load objects

00_groups.yml

  • create branch uv run infrahubctl branch create test-123
  • run generator toward that branch uv run infrahubctl generator site_pool_generator --branch=test-123 name=placeholder-site
---
schemas:
  - site_pool_schema.yml

objects:
  - objects

queries:
  - name: site_pools
    file_path: queries/site_pools.gql

generator_definitions:
  - name: site_pool_generator
    file_path: generators/site_pool_generator.py
    class_name: SitePoolGenerator
    query: site_pools
    targets: location_sites
    parameters:
      name: name__value

site_pool_generator.py

Additional Information

The interesting bit here is that parent prefix is a /30 and we try to allocate various /30 out of it. This seems to be a prerequisite for this issue to happen cause it works well if parent is /28 and allocate /30 from it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    state/need-triageThis issue needs to be triagedtype/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions