-
Notifications
You must be signed in to change notification settings - Fork 76
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
Openapi TestConnection new method #447
Conversation
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
Fix small issue with OpenApiPostItem since it wasnt unmarshalling 200 OK responses Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
I guess I'm still missing the use case: who/where/when will call the new OpenApiTestConnection function? Thanks! |
Yeah, maybe I didn't get much context. If you check the HTTP traffic using a traffic sniffer, when you fill everything and click the OK button, you can see two POST calls being generated by the frontend.
Let me know if this make it clear 😄 |
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.
LGTM, and thanks for explaining how we will use it at #447 (comment)
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.
Two parts
OpenAPI function adjustment
Looks good in general, but because functions in openapi.go
are a backbone for all OpenAPI requests I have a few minor addition requests which I left inline, but also here as I can't comment untouched code lines.
- Could you also adjust sister function
OpenApiPostItemSync
so that these behave the same way insync
operations. Also it's documentation. For a test you could manually submit the payload for testConnnection to see if it actually handles it well. - A changelog entry needs a separate line about adjustment of these functions and the reason for it.
- I already mentioned in explicit content but because this is no longer a single status code that guides the operation of these functions it would be beneficial to explicitly log status code as we pick the path.
** https://github.com/vmware/go-vcloud-director/pull/447/files#diff-585772f0a826713495acbb0951db5ff9d9f252426fca85e2e112581e5d90a29dR295
** https://github.com/vmware/go-vcloud-director/pull/447/files#diff-585772f0a826713495acbb0951db5ff9d9f252426fca85e2e112581e5d90a29dR191-R193 (here once you adjust it to handle both codes)
OpenApiTestConnection
The test Test_OpenApiTestConnection
has issue on 10.2 versions:
- 10.2.0 - FAILS:
go test -count 1 -tags ALL -check.vv -check.f OpenApiTestConnection -timeout=155m .
START: api_vcd_test.go:477: TestVCD.SetUpSuite
Running on VCD https://HOST/api (version 10.2.0.17008054 built at 2020-10-08 20:53:08 +0000 UTC)
as user administrator@System (using password)
Skipping all vapp tests because one of the following wasn't given: Network, StorageProfile, Catalog, Catalogitem
PASS: api_vcd_test.go:477: TestVCD.SetUpSuite 19.153s
START: openapi_test.go:265: TestVCD.Test_OpenApiTestConnection
openapi_test.go:304:
check.Assert(err, IsNil)
... value *errors.errorString = &errors.errorString{s:"error creating Edge Gateway: error in HTTP POST request: VCD_50006 - [ 71b4c62b-90f2-4b16-9668-448b7d3358e5 ] Json processing error.\n - Unrecognized field \"hostnameVerificationAlgorithm\" (class com.vmware.vcloud.rest.openapi.model.Connection), not marked as ignorable (5 known properties: \"host\", \"port\", \"proxyConnection\", \"secure\", \"timeout\"])\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 6, column: 37] (through reference chain: com.vmware.vcloud.rest.openapi.model.Connection[\"hostnameVerificationAlgorithm\"])"} ("error creating Edge Gateway: error in HTTP POST request: VCD_50006 - [ 71b4c62b-90f2-4b16-9668-448b7d3358e5 ] Json processing error.\n - Unrecognized field \"hostnameVerificationAlgorithm\" (class com.vmware.vcloud.rest.openapi.model.Connection), not marked as ignorable (5 known properties: \"host\", \"port\", \"proxyConnection\", \"secure\", \"timeout\"])\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 6, column: 37] (through reference chain: com.vmware.vcloud.rest.openapi.model.Connection[\"hostnameVerificationAlgorithm\"])")
FAIL: openapi_test.go:265: TestVCD.Test_OpenApiTestConnection
START: api_vcd_test.go:1549: TestVCD.TearDownSuite
PASS: api_vcd_test.go:1549: TestVCD.TearDownSuite 0.002s
OOPS: 0 passed, 1 FAILED
- 10.2.2 - FAILS
go test -count 1 -tags ALL -check.vv -check.f OpenApiTestConnection -timeout=155m .
START: api_vcd_test.go:477: TestVCD.SetUpSuite
Running on VCD https://HOST/api (version 10.2.2.18634228 built at 2021-09-15 17:30:35 +0000 UTC)
as user administrator@System (using password)
Skipping all vapp tests because one of the following wasn't given: Network, StorageProfile, Catalog, Catalogitem
PASS: api_vcd_test.go:477: TestVCD.SetUpSuite 21.967s
START: openapi_test.go:265: TestVCD.Test_OpenApiTestConnection
openapi_test.go:304:
check.Assert(err, IsNil)
... value *errors.errorString = &errors.errorString{s:"error creating Edge Gateway: error in HTTP POST request: VCD_50006 - [ e08d6df1-4eb0-42ec-b090-cda5ef4dedeb ] Json processing error.\n - Unrecognized field \"hostnameVerificationAlgorithm\" (class com.vmware.vcloud.rest.openapi.model.Connection), not marked as ignorable (5 known properties: \"host\", \"port\", \"proxyConnection\", \"secure\", \"timeout\"])\n at [Source: (org.apache.cxf.metrics.interceptors.CountingInputStream); line: 6, column: 37] (through reference chain: com.vmware.vcloud.rest.openapi.model.Connection[\"hostnameVerificationAlgorithm\"])"} ("error creating Edge Gateway: error in HTTP POST request: VCD_50006 - [ e08d6df1-4eb0-42ec-b090-cda5ef4dedeb ] Json processing error.\n - Unrecognized field \"hostnameVerificationAlgorithm\" (class com.vmware.vcloud.rest.openapi.model.Connection), not marked as ignorable (5 known properties: \"host\", \"port\", \"proxyConnection\", \"secure\", \"timeout\"])\n at [Source: (org.apache.cxf.metrics.interceptors.CountingInputStream); line: 6, column: 37] (through reference chain: com.vmware.vcloud.rest.openapi.model.Connection[\"hostnameVerificationAlgorithm\"])")
FAIL: openapi_test.go:265: TestVCD.Test_OpenApiTestConnection
START: api_vcd_test.go:1549: TestVCD.TearDownSuite
PASS: api_vcd_test.go:1549: TestVCD.TearDownSuite 0.001s
OOPS: 0 passed, 1 FAILED
--- FAIL: Test (22.90s)
- 10.3.2 - OK
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
…nt.TestConnection` Update OpenApiPostItemSync so it supports 200OK codes and now returns error if return code is different from 200 or 201 Signed-off-by: Miguel Sama <[email protected]>
Rename `OpenApiTestConnection` to `TestConnection` Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
@Didainius some comments regarding the changes that I did.
Let me know if you're concerned about anything else! 🚀 |
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.
I would say we need wrapper function too, which would have only minimum values for input like URL and everything else default. I guess in UI you provide URL.
…ApiHighestElevatedVersion` Signed-off-by: Miguel Sama <[email protected]>
…ions` Signed-off-by: Miguel Sama <[email protected]>
…ough v36.2 Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
This is interesting. Let's see what @lvirbalas @Didainius @adambarreiro have to say about it. |
Go ahead if this is easy to make it (no advanced computations for fields) |
how the current function is used in terraform? how does call look like? |
Is not yet being used, but I'll use it when enhancing the Catalog resource, when it comes to create a new catalog subscribing from an external one. |
So then you see how kind wrapper is better :) |
…efaults Signed-off-by: Miguel Sama <[email protected]>
…s` so it test that function and `TestConnection` at the same time Signed-off-by: Miguel Sama <[email protected]>
@vbauzysvmware added the method |
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 fixes. I am approving - just fix the typo in a separate comment.
govcd/openapi_endpoints.go
Outdated
@@ -115,7 +121,7 @@ func (client *Client) checkOpenApiEndpointCompatibility(endpoint string) (string | |||
// supported API versions just like client.checkOpenApiEndpointCompatibility(). | |||
// | |||
// The advantage of this functions is that it provides a controlled API elevation instead of just picking the highest | |||
// which could be risky and untested (especially if new API version is released after release of package consuming this | |||
// which could be risky and untested (especially if new API version hich could be risky and untested (especially if new API version is released after release of package consuming this |
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.
This remaining thing to fix.
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.
Rephrased that so it makes sense now. Thanks for spotting that 🚀
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.
Thank you
Signed-off-by: Miguel Sama <[email protected]>
Signed-off-by: Miguel Sama <[email protected]>
Closing in favor of #501 |
This PR does not have any issue associated.
Description
When creating a catalog and subscribing to an external one, VCD uses the endpoint
/cloudapi/1.0.0/testConnection/
to check before hand if the endpoint where the user is trying to subscribe the external catalog from exists.Detailed description
In order to implement the external catalog subscription in the Terraform provider for VCD when creating a catalog, TestConnection functionality needs to be implemented since before subscribing, VCD does this previous sanity check.
This has been implemented as a
Client
method, since it doesn't belong to any VCD resource and it's a client helping tool.Also, I propose a slight change to
Client.OpenApiPostItem
since to use TestConnection, I had to do a POST request against/cloudapi/1.0.0/testConnection/
. This results in a200OK
, instead of 201 or 202.Client.OpenApiPostItem
wasn't covering this case, so the function worked but it wasn't unmarshalling the response into the needed struct.This last point is open to discussion, as it might be a better way to handle this.
🚀