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

allow to add ips to vrouter nics #565

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Thiryn
Copy link

@Thiryn Thiryn commented Jul 29, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for PR followers and do not help prioritize the request

Description

References

closes #564

New or Affected Resource(s)

  • opennebula_virtual_router_nic

Checklist

  • I have created an issue and I have mentioned it in References
  • My code follows the style guidelines of this project (use go fmt)
  • My changes generate no new warnings or errors
  • I have updated the unit tests and they pass succesfuly
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation (if needed)
  • I have updated the changelog file

@Thiryn
Copy link
Author

Thiryn commented Jul 29, 2024

Will update docs and changelog if this gets accepted

@Thiryn
Copy link
Author

Thiryn commented Aug 20, 2024

Found out the reason why the CI is failing, I didn't see the provider tests are creating 2 VRouter instance, and obviously we can't attach 2 non-floating IP to the instances.
What's the best way to tackle this in your opinion ? Should I isolate the NIC IP attachement test in a separate test file? I'm not familiar enough with the provider test to know if there is a way to delete a specific resource from a previous test step.

Scratch that, I didn't see that the test contained previous resources too, I think I should be able to update the test to cover the use cases correctly.

adapt the tests to ensure there is only one vrouter instance when creating nic with non-floating IPs
@Thiryn Thiryn marked this pull request as draft August 21, 2024 13:12
@Thiryn
Copy link
Author

Thiryn commented Aug 21, 2024

just putting this back as draft until I fix the tests entirely

@Thiryn
Copy link
Author

Thiryn commented Aug 26, 2024

A couple things have changed:

  • The NIC delete function now waits on the leases to be freed. There is a sync issue in ON where even when the NIC gets freed, the IP lease isn't quite free for another few seconds. I made this specific error a retry-able error.
  • I added some tests:
    • Testing with and without floating IP
    • Removing the 2nd vrouter instance before attaching the first NIC, as we obviously can't assign a static IP to 2 different VRouter VMs
    • Did some housekeeping and arranged the test terraform for that file in a uniform manner (4-spaces seemed to be the standard, I used that)

@Thiryn Thiryn marked this pull request as ready for review August 26, 2024 12:24
Copy link

This pull request is stale because it has been open for 30 days with no activity and it is not in a milestone. Remove 'status: stale' label or comment, or this will be closed in 5 days.

Copy link
Collaborator

@treywelsh treywelsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick look at the PR. Thanks for this contribution.
It's nice to have some tests in it.

Reworking the commit history would be nice:
Please take a look at master commit names, they're often prepended with an issue number and F for feature, B for bug (I tried to keep more or less then OpenNebula way to name the commits)
As a side note: formatting the acceptance test adds a bit of noise to the whole PR changes, maybe that should be in a separate commit but it's not a big deal

resource.TestCheckResourceAttrSet("opennebula_virtual_router.test", "gid"),
resource.TestCheckResourceAttrSet("opennebula_virtual_router.test", "uname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_router.test", "gname"),
resource.TestCheckResourceAttr("opennebula_virtual_router_nic.nic_floating_IP_specified", "floating_ip", "true"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when snake case is used, keep it lowercase to be consistent

@@ -209,6 +219,13 @@ func resourceOpennebulaVirtualRouterNICRead(ctx context.Context, d *schema.Resou

floatingIP, _ := nic.GetStr("FLOATING_IP")
floatingOnly, _ := nic.GetStr("FLOATING_ONLY")
ip, _ := nic.Get("IP")

// For VRouter NICs, floating IPs are set using the "IP" field, but it is represented in the ON API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny typo: ONE

@@ -101,6 +101,13 @@ func vrNICAttach(ctx context.Context, timeout time.Duration, controller *goca.Co
updatedNICsLoop:
for i, nic := range updatedNICs {

// For VRouter NICs, floating IPs are set using the "IP" field, but it is represented in the ON API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless I miss something it seems that this whole code part in helpers_vr.go is useless ?

})
return diags
}
err = resource.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you ensured that prepending the Delete call with a waitForVNetworkState call wouldn't fix this ?
As a side note, you're using TimeoutCreate in the delete method here

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

Successfully merging this pull request may close these issues.

Add IP to opennebula_virtual_router_nic
2 participants