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

Error: Subnet either missing or multiple results returned by reading subnet after creation #43

Closed
MrKoopaKiller opened this issue May 31, 2022 · 6 comments · Fixed by #46
Assignees
Labels
enhancement New feature or request

Comments

@MrKoopaKiller
Copy link

MrKoopaKiller commented May 31, 2022

Affected resource
phpipam_subnet resource

Issue:

The phpIPAM allow us to disable the strict mode per section and also allow us to create more than one subnet using the same cidr in diferente sections. That being said, if we try to create 2 subnets with the same CIDR but in different sections, it should work, but in fact, it's not working and terraform throws an error:

Error: Subnet either missing or multiple results returned by reading subnet after creation

Seems the main reason is by this function that tries to retry if the subnet was correctly create querying by CIDR:

func (c *Controller) GetSubnetsByCIDR(cidr string) (out []Subnet, err error) {
err = c.SendRequest("GET", fmt.Sprintf("/subnets/cidr/%s/", cidr), &struct{}{}, &out)
return
}

But since we have more than 1 result, it throws the error:

if len(subnets) != 1 {
return errors.New("Subnet either missing or multiple results returned by reading subnet after creation")
}

Use case:
Just to give a quick explanation why I'm using this in that way. I have multiples AWS accounts, and I'm putting all the vpc and subnets from all this accounts and all regions in the phpIPAM. AWS regions has the default vpc, using the same CIDR and it causes the error. If for some reason the subnets weren't correctly architect and an overlap occurs, is it possible to face the same error even if the strict mode is disabled in the phpIPAM.

Expected Behavior
Be able to create subnets using the same CIDR.

@lord-kyron
Copy link
Owner

@pavel-z1 - is it possible to fix this one easily?

@pavel-z1 pavel-z1 self-assigned this Jun 14, 2022
@pavel-z1 pavel-z1 added the enhancement New feature or request label Jun 14, 2022
@pavel-z1 pavel-z1 linked a pull request Jun 16, 2022 that will close this issue
@pavel-z1
Copy link
Collaborator

Hi @MrKoopaKiller
I've updated phpipam-sdk and this provider to allow search CIDR in the specific section during subnet creation.

Check this feature in your environment

@MrKoopaKiller
Copy link
Author

Thanks @pavel-z1! I'll test the changes soon!

@lord-kyron Do you think is it possible to create a new tag including the latest commits?

@lord-kyron
Copy link
Owner

@MrKoopaKiller I will prepare new tag and new release build tomorrow!

@MrKoopaKiller
Copy link
Author

Ping @lord-kyron 🙏

@lord-kyron
Copy link
Owner

@MrKoopaKiller published with the latest release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants