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

API of iothub/mgmt upgraded to 2021-03-31 #13324

Merged
merged 7 commits into from
Sep 23, 2021

Conversation

ramondeklein
Copy link
Contributor

This PR upgrades the IOT-hub management API to 2021-03-03-preview to allow the creation of DeviceConnectionStateEvents routes (#12477 and #12985). No new features have been added that might have be added in this API, but the creation of DeviceConnectionStateEvents routes now works fine.

Some remarks about this PR:

  • The module github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2020-03-01/devices has been upgraded to github.com/Azure/azure-sdk-for-go/services/preview/iothub/mgmt/2021-03-03-preview/devices (therefore a lot of changes in the vendor folder).
  • The API now uses prefixes for some enumerations, so this has been updated in other parts of the source where these enumerations were referenced.
  • The IotHubResourceClient.CreateEventHubConsumerGroup() now requires a devices.EventHubConsumerGroupBodyDescription structure containing a Name property. However, this isn't documented at all (link) and it property is optional, so we won't use it.
  • internal/services/iothub/iothub_route_resource.go contained the hard-coded string "DeviceConnectionStateEvents", which can now be replaced with the proper enumeration devices.RoutingSourceDeviceConnectionStateEvents.

@stephybun
Copy link
Member

stephybun commented Sep 13, 2021

Thanks for this PR @ramondeklein, but it looks like there are some test failures, specifically the ones for the iothub consumer group resource

Passing tests
TF_ACC=1 go test -v ./internal/services/iothub -run=TestAccIotHub -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
...
--- PASS: TestAccIotHubDpsSharedAccessPolicy_writeWithoutRead (125.00s)
--- PASS: TestAccIotHubDpsSharedAccessPolicy_enrollmentWriteWithoutOthers (196.44s)
--- PASS: TestAccIotHubDpsSharedAccessPolicy_enrollmentReadWithoutRegistration (196.87s)
--- PASS: TestAccIotHubSharedAccessPolicy_writeWithoutRead (10.80s)
--- PASS: TestAccIotHub_requiresImport (314.03s)
--- PASS: TestAccIotHubEndpointStorageContainer_basic (358.16s)
--- PASS: TestAccIotHub_fileUpload (293.16s)
--- PASS: TestAccIotHubEndpointServiceBusQueue_basic (437.04s)
--- PASS: TestAccIotHubEndpointStorageContainer_requiresImport (466.50s)
--- PASS: TestAccIotHubEndpointEventHub_requiresImport (497.58s)
--- PASS: TestAccIotHubEndpointEventHub_basic (497.77s)
--- PASS: TestAccIotHubEnrichment_requiresImport (502.51s)
--- PASS: TestAccIotHubEnrichment_basic (515.06s)
--- PASS: TestAccIotHubEndpointServiceBusQueue_requiresImport (515.61s)
--- PASS: TestAccIotHub_withDifferentEndpointResourceGroup (530.10s)
--- PASS: TestAccIotHubEndpointServiceBusTopic_requiresImport (606.55s)
--- PASS: TestAccIotHubEndpointServiceBusTopic_basic (615.80s)
--- PASS: TestAccIotHubSharedAccessPolicy_requiresImport (436.43s)
--- PASS: TestAccIotHubSharedAccessPolicy_basic (399.67s)
--- PASS: TestAccIotHub_removeEndpointsAndRoutes (532.27s)
--- PASS: TestAccIotHub_enrichments (427.99s)
--- PASS: TestAccIotHub_standard (313.69s)
--- PASS: TestAccIotHubDpsSharedAccessPolicy_basic (249.20s)
--- PASS: TestAccIotHub_fallbackRoute (286.26s)
--- PASS: TestAccIotHub_customRoutes (432.39s)
--- PASS: TestAccIotHubDPSCertificate_update (278.86s)
--- PASS: TestAccIotHubDPS_requiresImport (202.78s)
--- PASS: TestAccIotHubDPS_update (268.99s)
--- PASS: TestAccIotHubDPS_linkedHubs (294.51s)
--- PASS: TestAccIotHubDPS_basic (188.67s)
--- PASS: TestAccIotHubRoute_requiresImport (411.55s)        
--- PASS: TestAccIotHubDPSCertificate_basic (196.33s)
--- PASS: TestAccIotHubRoute_basic (468.72s)
--- PASS: TestAccIotHubDPSCertificate_requiresImport (213.23s)
--- PASS: TestAccIotHubRoute_update (581.20s)
--- PASS: TestAccIotHub_minTLSVersion (294.29s)
--- PASS: TestAccIotHub_publicAccess (559.72s)        
--- PASS: TestAccIotHub_basic (307.55s)
--- PASS: TestAccIotHub_ipFilterRules (395.29s)
--- PASS: TestAccIotHubFallbackRoute_basic (433.90s)
--- PASS: TestAccIotHubFallbackRoute_update (524.92s)
--- PASS: TestAccIotHubEnrichment_update (515.49s)
Failing tests
    testcase.go:88: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Consumer Group "test" (Endpoint "events" / IoTHub "acctestIoTHub-210913143951124118" / Resource Group "acctestRG-210913143951124118"): devices.IotHubResourceClient#CreateEventHubConsumerGroup: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: "{\"code\":400007,\"httpStatusCode\":\"BadRequest\",\"message\":\"Consumer group name in the request body should not be null or empty. If you contact a support representative please include this correlation identifier: c7c30e44-fe6c-4dcb-af9f-178bcd262b5b, timestamp: 2021-09-13 12:42:58Z, errorcode: IH400007.\"}" error: json: cannot unmarshal number into Go struct field serviceErrorInternal.code of type string
        
          with azurerm_iothub_consumer_group.test,
          on terraform_plugin_test.tf line 26, in resource "azurerm_iothub_consumer_group" "test":
          26: resource "azurerm_iothub_consumer_group" "test" {
        
=== CONT  TestAccIotHubConsumerGroup_requiresImport
    testcase.go:88: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Consumer Group "test" (Endpoint "events" / IoTHub "acctestIoTHub-210913143951129432" / Resource Group "acctestRG-210913143951129432"): devices.IotHubResourceClient#CreateEventHubConsumerGroup: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: "{\"code\":400007,\"httpStatusCode\":\"BadRequest\",\"message\":\"Consumer group name in the request body should not be null or empty. If you contact a support representative please include this correlation identifier: c1427376-1912-4ddd-b737-fbd2399977dc, timestamp: 2021-09-13 12:43:00Z, errorcode: IH400007.\"}" error: json: cannot unmarshal number into Go struct field serviceErrorInternal.code of type string
        
          with azurerm_iothub_consumer_group.test,
          on terraform_plugin_test.tf line 26, in resource "azurerm_iothub_consumer_group" "test":
          26: resource "azurerm_iothub_consumer_group" "test" {
        
=== CONT  TestAccIotHubConsumerGroup_operationsMonitoringEvents
    testcase.go:88: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Consumer Group "test" (Endpoint "operationsMonitoringEvents" / IoTHub "acctestIoTHub-210913143951126426" / Resource Group "acctestRG-210913143951126426"): devices.IotHubResourceClient#CreateEventHubConsumerGroup: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: "{\"code\":400007,\"httpStatusCode\":\"BadRequest\",\"message\":\"Consumer group name in the request body should not be null or empty. If you contact a support representative please include this correlation identifier: 70085663-2db1-4e64-bd83-bb572a3310fc, timestamp: 2021-09-13 12:43:29Z, errorcode: IH400007.\"}" error: json: cannot unmarshal number into Go struct field serviceErrorInternal.code of type string
        
          with azurerm_iothub_consumer_group.test,
          on terraform_plugin_test.tf line 26, in resource "azurerm_iothub_consumer_group" "test":
          26: resource "azurerm_iothub_consumer_group" "test" {
        
=== CONT  TestAccIotHubConsumerGroup_withSharedAccessPolicy
    testcase.go:88: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Consumer Group "test" (Endpoint "events" / IoTHub "acctestIoTHub-210913143951128215" / Resource Group "acctestRG-210913143951128215"): devices.IotHubResourceClient#CreateEventHubConsumerGroup: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: "{\"code\":400007,\"httpStatusCode\":\"BadRequest\",\"message\":\"Consumer group name in the request body should not be null or empty. If you contact a support representative please include this correlation identifier: 0ab963f3-00c4-4073-833a-95181d601b59, timestamp: 2021-09-13 12:42:59Z, errorcode: IH400007.\"}" error: json: cannot unmarshal number into Go struct field serviceErrorInternal.code of type string
        
          with azurerm_iothub_consumer_group.test,
          on terraform_plugin_test.tf line 27, in resource "azurerm_iothub_consumer_group" "test":
          27: resource "azurerm_iothub_consumer_group" "test" {
        
--- FAIL: TestAccIotHubConsumerGroup_events (285.75s)
--- FAIL: TestAccIotHubConsumerGroup_requiresImport (285.75s)
--- FAIL: TestAccIotHubConsumerGroup_operationsMonitoringEvents (312.73s)
--- FAIL: TestAccIotHubConsumerGroup_withSharedAccessPolicy (348.65s)

@ramondeklein
Copy link
Contributor Author

@stephybun This will have probably to do with the change in the name property. I'll take a look later this week and will push a fix when all test-cases work fine again. Thanks for pointing out...

@ramondeklein
Copy link
Contributor Author

@katbyte I have updated this pull-request, so it now also sends the name. But there seems to be an issue in the 2021-03-03-preview API that prevents this call from succeeding. I have filed an issue with the Microsoft Azure SDK for Go team (Azure/azure-sdk-for-go#15545) with details what's wrong. This needs to be fixed, before we can upgrade to this new API. I'll will monitor the SDK issue and comment when it has been fixed an this PR can continue.

@katbyte katbyte added this to the Blocked milestone Sep 13, 2021
@ramondeklein
Copy link
Contributor Author

SDK will be fixed in the next release and we will need to upgrade to 2021-03-31 by then (source).

@ramondeklein ramondeklein changed the title API of iothub/mgmt upgraded to 2021-03-03-preview API of iothub/mgmt upgraded to 2021-03-31 Sep 23, 2021
@ramondeklein
Copy link
Contributor Author

@katbyte The API has now been upgraded to the non-preview 2021-03-31 version to fix the SDK issue (Azure/azure-sdk-for-go#15545). Everything compiles and all unit tests are passing.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @ramondeklein - LGTM 🏗️

@katbyte katbyte merged commit ce7eed4 into hashicorp:main Sep 23, 2021
@katbyte katbyte modified the milestones: Blocked, v2.78.0 Sep 23, 2021
katbyte added a commit that referenced this pull request Sep 23, 2021
@github-actions
Copy link

This functionality has been released in v2.78.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants