Skip to content

bug: CoreNumberPool doesn't allow upsert #5636

Description

@BaptisteGi

Component

API Server / GraphQL

Infrahub version

1.1.6

Current Behavior

I have a script loading some data, it's designed in a way that I can run it multiple times. However when I run it a second time I hit an exception related with CoreNumberPool

['CoreNumberPoolUpsert'] The fields 'node' or 'node_attribute' can't be changed.

Expected Behavior

I expect the script to run especially since I'm not changing the value of that particular field.

Steps to Reproduce

async def run(
    client: InfrahubClient, log: logging.Logger, branch: str, **kwargs
) -> None:
    log.info("Generate all prefixes related data...")
    await create_prefixes(client=client, branch=branch, log=log)


async def create_prefixes(
    client: InfrahubClient, log: logging.Logger, branch: str
) -> None:
    # Create l2 domain
    l2_domain = await client.create(
        kind="IpamL2Domain",
        name="default",
    )
    await l2_domain.save(allow_upsert=True)

    # Create public prefix
    public_prefix = await client.create(
        kind="IpamPrefix",
        status="active",
        prefix="203.0.113.0/24",
        member_type="prefix",
        role="public",
    )
    await public_prefix.save(allow_upsert=True)

    # Create management prefix
    management_prefix = await client.create(
        kind="IpamPrefix",
        status="active",
        prefix="172.16.1.0/24",
        member_type="address",
        role="management",
    )
    await management_prefix.save(allow_upsert=True)

    # Create management ip pool
    management_pool = await client.create(
        kind="CoreIPAddressPool",
        name="Management IP pool",
        default_prefix_type="IpamIPPrefix",
        default_prefix_length=24,
        default_address_type="IpamIPAddress",
        default_member_type="address",
        ip_namespace="default",
        resources=[management_prefix],
    )
    await management_pool.save(allow_upsert=True)

    customer_prefix_pool = await client.create(
        kind="CoreIPPrefixPool",
        name="Customer prefixes pool",
        default_prefix_type="IpamPrefix",
        default_prefix_length=29,
        default_member_type="address",
        ip_namespace="default",
        resources=[public_prefix],
    )
    await customer_prefix_pool.save(allow_upsert=True)

    customer_vlan_pool = await client.create(
        kind="CoreNumberPool",
        name="Customer vlan pool",
        node="IpamVLAN",
        node_attribute="vlan_id",
        start_range=1000,
        end_range=2000,
    )
    await customer_vlan_pool.save(allow_upsert=True)
  • First time it should work, second time it should fail with exception message

Additional Information

No response

Metadata

Metadata

Assignees

Labels

group/backendIssue related to the backend (API Server, Git Agent)priority/2This issue stalls work on the project or its dependents, it's a blocker for a releasetype/bugSomething isn't working as expected

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions