Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: IPPrefixPool has IP addresses in the resource allocated tab #5316

Open
BaptisteGi opened this issue Dec 24, 2024 · 0 comments
Open

bug: IPPrefixPool has IP addresses in the resource allocated tab #5316

BaptisteGi opened this issue Dec 24, 2024 · 0 comments
Labels
type/bug Something isn't working as expected

Comments

@BaptisteGi
Copy link
Contributor

Component

Not Sure

Infrahub version

1.0.9

Current Behavior

I have a IPPrefixPool that has linked IpamIPAddress resource allocated:

image

Expected Behavior

My IPPrefixPool allocates only IpamPrefix as per set type. I do not expect any IPAddress object in this tab.

Steps to Reproduce

  • Create prefix
  • Create a IPPrefixPool and link the previous prefix as resource
  • Allocate a few prefixes out of this pool
  • Then create an IP linked to the allocated prefix

From the prefix pool standpoint you should have something like this:
image

  • Then pick one of the prefix and delete it
  • Go back to the prefix pool tab
image

-> Somehow the IP that I created under the prefix ended up in the resource pool allocated resources tab

Additional Information

Here is a sample of the code that creates prefix and IP:

    SERVICE_PREFIX_POOL: str = "Customer prefixes pool"
    
    # Get resource pool
    resource_pool = await self.client.get(
        kind=CoreIPPrefixPool,
        name__value=SERVICE_PREFIX_POOL,
    )
    
    # Craft the data dict for prefix
    prefix_data: dict = {
        "status": "active",
        "description": f"Prefix allocated to service...",
        "role": "server",
    }
    
    # Create resource from the pool
    prefix_obj = await self.client.allocate_next_ip_prefix(
        resource_pool, data=prefix_data, prefix_length=29
    )
    
    address = f"{str(next(prefix_obj.prefix.value.hosts()))}/{str(prefix_length)}"
    
    gateway_ip = await self.client.create(
        kind="IpamIPAddress",
        address=address,
    )
    await gateway_ip.save()
    
    # Add gateway to prefix
    prefix_obj.gateway = gateway_ip
    await prefix_obj.save(allow_upsert=True)
@BaptisteGi BaptisteGi added the type/bug Something isn't working as expected label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

1 participant