-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
DNAT: allow different src/translated port #14437
Conversation
@robcoward could you have a look please, anything else needed? FYI |
@ewypych could you look too please? I integrated your code for the test, as that part was missing. |
@Boran LGTM. If everything works properly, I don't mind merging. 👍 Hope it will be merged. 😄 |
Awesome- looks great. @robcoward has left UKCloud now so not sure he'll be checking these alerts. Would be great if you could merge please @ewypych |
@Boran LGTM. Like @bobbydeveaux said, I no longer work for UKCloud so dont have the infrastructure to test this against, but the logic looks sound. |
@robcoward @bobbydeveaux If you mean whether it works with vCloud, I can compile and test it on vCloud Director (8.2 and 8.0 for SP, have access only to these versions). Unfortunately, Sunday evening is the first possible date. I've made my version (didn't notice that @Boran made it first) and it works fine with the infrastructure (you can look at the code here #14709). Code is similar, so I assume that everything is great and there should be no problems. And Bobby - bad news, I haven't permissions to merge, I'm just an ordinary contributor. 😄 But I have the same view - merging would be great! |
I have tested on vCloud Director 8.02.4348775 @bobbydeveaux: Have you merge rights? |
Afraid not. I can merge anything UKCloud, but not Hashicorp! :) |
@jbardin Could you help, or know who could help us get this PR merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
There's a few comments in-line. We also need the output from an acceptance test run.
I'll hand this off to someone who does more providers to give it the final review and merge.!
@@ -77,7 +89,7 @@ func resourceVcdDNATCreate(d *schema.ResourceData, meta interface{}) error { | |||
return fmt.Errorf("Error completing tasks: %#v", err) | |||
} | |||
|
|||
d.SetId(d.Get("external_ip").(string) + "_" + portString) | |||
d.SetId(d.Get("external_ip").(string) + ":" + portString + " > " + d.Get("internal_ip").(string) + ":" + trlateportString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is changing the ID going effect existing resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the current ID is not unique and is a bug if left so (in my opinion).
@@ -49,6 +55,10 @@ func resourceVcdDNATCreate(d *schema.ResourceData, meta interface{}) error { | |||
vcdClient.Mutex.Lock() | |||
defer vcdClient.Mutex.Unlock() | |||
portString := getPortString(d.Get("port").(int)) | |||
trlateportString := portString // default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this variable a little easier to read? translatedPortString
isn't much longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, change committed.
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckVcdDNATExists("vcd_dnat.bar", &e), | ||
resource.TestCheckResourceAttr( | ||
"vcd_dnat.bar", "external_ip", os.Getenv("VCD_EXTERNAL_IP")), | ||
resource.TestCheckResourceAttr( | ||
"vcd_dnat.bar", "port", "77"), | ||
"vcd_dnat.bar", "port", "7777"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since existing configs are still valid, I'd rather leave the existing test and add a new test case with a translated port.
@bobbydeveaux I merged the latest terraform master + govcloudair before starting acceptance tests. On compiling now getting
Any idea where govair is expecting that type to come from? |
@Boran I had this before.. it's a pain and I'm unsure why go vendor requires this step, but you need to fetch all 3 directories in govcloudair: govendor fetch github.com/ukcloud/govcloudair I'm guessing you only did the first one, as the LinkList is in types/v56/link.go HTH! :) |
Hmm. It took 20mins to get those, but it helped thanks!
|
Very odd. You've done all three? |
yes, and doing a "grep -R Client github.com/hashicorp/terraform/vendor/github.com/ukcloud/govcloudair" I do not see where Client is defined.
|
terraform/vendor/github.com/ukcloud/govcloudair/api.go:19 // Client provides a client to vCloud Air, values can be populated automatically using the Authenticate method. |
Does Personally, I use; |
There is no api.go I realise now how I did this before: |
I understand that one uses "make plugin-dev" to build only the plugin and link it in dynamically on startup. I prefer to build the full binary. @jbardin, @catsby: So I have now been able to run acceptance tests and as requested, have separated the TestAccVcdDNAT_Basic into TestAccVcdDNAT_Basic and TestAccVcdDNAT_tlate. 14:47 $ make testacc TEST=./builtin/providers/vcd There is one fail, but not related to this PR |
@Boran : Thanks a lot! Sounds like this PR is ready to go then? |
Sorry @Boran didn't see your other replies. Glad you're up and running and this LGTM! |
@catsby : have you had a chance to review/look? :-) |
Move this PR to the new vcd provider repo. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Initial work on #12384.
Building with UKCloud/govcloudair@81750aa
The corresponding issue in govair is vmware-archive/govcloudair#37 and UKCloud/govcloudair#3
Added a new (optional) param translated_port, keeping the existing port as the src port.
If translated_port is not specified use port - allows backward compatibility.
The name translated_port was selected because it is closer to the api and is less confusing than internal/external for example.
vcd_dnat.test-ssh1: Creation complete (ID: 193.1.1.1:22 > 172.16.8.36:40022)