equinix / terraform-provider-equinix

Terraform Equinix provider
https://deploy.equinix.com/labs/terraform-provider-equinix/
MIT License
47 stars 45 forks source link

feat: convert metal_port to equinix-sdk-go #709

Closed ctreatma closed 2 months ago

ctreatma commented 3 months ago

This replaces packngo with equinix-sdk-go in the metal_port resource and datasource as part of #402. While I'm in these files I also opted to move them into internal/resources/metal/port to align with #106.

displague commented 3 months ago

There were a few tests that failed that seem related to the changes in this PR, seemingly around VLANs not being able to be removed because of active port links.

=== NAME  TestAccMetalPort_L2IndividualNativeVlan
    resource_test.go:271: Step 2/3 error: Error running apply: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
2024/06/25 16:29:20 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/60307dc8-4cf6-43ed-9c18-1453885b5efc?include=instances%2Cmeta_gateway
2024/06/25 16:29:20 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/cbc18c7a-0471-456e-9b7e-79b5f1556b29?include=instances%2Cmeta_gateway
2024/06/25 16:29:20 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/60307dc8-4cf6-43ed-9c18-1453885b5efc
2024/06/25 16:29:20 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/cbc18c7a-0471-456e-9b7e-79b5f1556b29
    panic.go:626: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
--- FAIL: TestAccMetalPort_L2IndividualNativeVlan (169.56s)
=== NAME  TestAccMetalPortUpdate_hybridBonded_timeout
    resource_test.go:468: Step 2/5, expected an error with pattern, no match on: Error running apply: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
2024/06/25 16:29:41 [DEBUG] GET https://api.equinix.com/metal/v1//ports/1b8a98c6-a5e7-4a10-9dec-80bbf2cb9e24?include=native_virtual_network%2Cvirtual_networks
2024/06/25 16:29:42 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/26137bca-de21-4189-891b-fe1a68ec8315?include=instances%2Cmeta_gateway
2024/06/25 16:29:42 [DEBUG] GET https://api.equinix.com/metal/v1//devices/e14bc454-2323-4221-9952-adbc74b1909d?include=project
2024/06/25 16:29:42 [DEBUG] GET https://api.equinix.com/metal/v1//devices/18a5804a-4092-49f9-8e9c-0d05245d8517?include=project
2024/06/25 16:29:42 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/26137bca-de21-4189-891b-fe1a68ec8315
2024/06/25 16:29:42 [DEBUG] GET https://api.equinix.com/metal/v1//ports/b26c7481-205a-4324-b3c3-ac3baf469345/vlan-assignments/batches/4eca37a4-6a23-4f0b-9b6f-b304d0c26f99
    panic.go:626: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
--- FAIL: TestAccMetalPortUpdate_hybridBonded_timeout (191.27s)
 === NAME  TestAccMetalPort_L2Bonded
    resource_test.go:304: Step 4/5 error: After applying this test step, the non-refresh plan was not empty.
        stdout:

        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # equinix_metal_port.bond0 will be updated in-place
          ~ resource "equinix_metal_port" "bond0" {
                id                = "04d7e48a-719b-4bfc-91ef-58a0a834575a"
              - layer2            = true -> null
                name              = "bond0"
                # (7 unchanged attributes hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
2024/06/25 16:29:55 [DEBUG] DELETE https://api.equinix.com/metal/v1//devices/f036932d-1f2e-4c91-a28f-2a7fd68c1f08?force_delete=false
2024/06/25 16:29:56 [DEBUG] GET https://api.equinix.com/metal/v1//devices/e356ff68-6012-404a-a9df-82482b0aa19f?include=project
2024/06/25 16:29:57 [DEBUG] DELETE https://api.equinix.com/metal/v1//projects/d9fbd4ae-530e-4696-92f4-60ad27d45941
2024/06/25 16:29:57 [DEBUG] GET https://api.equinix.com/metal/v1//ports/b26c7481-205a-4324-b3c3-ac3baf469345/vlan-assignments/batches/4eca37a4-6a23-4f0b-9b6f-b304d0c26f99
--- FAIL: TestAccMetalPort_L2Bonded (206.86s)
=== NAME  TestAccMetalPort_hybridBondedVxlan
    resource_test.go:242: Step 2/3 error: Error running apply: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
2024/06/25 16:30:05 [DEBUG] GET https://api.equinix.com/metal/v1//devices/2bd0b86a-f5b6-4e7c-b399-f6d19470b23e?include=project
2024/06/25 16:30:05 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/d5894c5f-3079-4a80-bf52-254f45bae88e?include=instances%2Cmeta_gateway
2024/06/25 16:30:05 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/7cfa7c38-ca36-4a93-9ca0-30f33dec9b65?include=instances%2Cmeta_gateway
2024/06/25 16:30:05 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/d5894c5f-3079-4a80-bf52-254f45bae88e
2024/06/25 16:30:05 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/7cfa7c38-ca36-4a93-9ca0-30f33dec9b65
    panic.go:626: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
--- FAIL: TestAccMetalPort_hybridBondedVxlan (215.04s)
=== NAME  TestAccMetalPortCreate_hybridBonded_timeout
    resource_test.go:427: Step 5/5 error: Error running destroy: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
2024/06/25 16:30:40 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/f986ad39-9f22-43f7-9e11-fb62b3d3a95d?include=instances%2Cmeta_gateway
2024/06/25 16:30:40 [DEBUG] GET https://api.equinix.com/metal/v1//ports/464a0808-d9ae-4e7a-a193-a8a45392b38d?include=native_virtual_network%2Cvirtual_networks
2024/06/25 16:30:40 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/f986ad39-9f22-43f7-9e11-fb62b3d3a95d
    panic.go:626: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
--- FAIL: TestAccMetalPortCreate_hybridBonded_timeout (249.68s)
=== NAME  TestAccMetalPort_hybridBonded
    resource_test.go:304: Step 3/5 error: Error running apply: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
2024/06/25 16:33:02 [DEBUG] GET https://api.equinix.com/metal/v1//devices/e356ff68-6012-404a-a9df-82482b0aa19f?include=project
2024/06/25 16:33:02 [DEBUG] GET https://api.equinix.com/metal/v1/virtual-networks/ab45d0f3-d739-43c3-a342-b24c07668228?include=instances%2Cmeta_gateway
2024/06/25 16:33:03 [DEBUG] DELETE https://api.equinix.com/metal/v1/virtual-networks/ab45d0f3-d739-43c3-a342-b24c07668228
    panic.go:626: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: Error deleting Vlan

        API Error HTTP 422 Cannot delete Virtual Network when port is assigned
--- FAIL: TestAccMetalPort_hybridBonded (245.36s)
displague commented 3 months ago

TestAccMetalPortCreate_hybridBonded_timeout was also present in #713, but not the others

ctreatma commented 3 months ago

There were a few tests that failed that seem related to the changes in this PR, seemingly around VLANs not being able to be removed because of active port links.

This PR was, until recently, a WIP, but I left it out of draft out of laziness (have to click a whole button to run CI for a draft PR branch) and neglected to update the PR title. In any case, it is no longer a WIP and the tests should be passing as of now.

codecov-commenter commented 3 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 2.75862% with 141 lines in your changes missing coverage. Please review.

Project coverage is 34.39%. Comparing base (503d9e1) to head (3ecc54f). Report is 84 commits behind head on main.

Files Patch % Lines
internal/resources/metal/port/helpers.go 0.00% 89 Missing :warning:
internal/resources/metal/port/resource.go 1.88% 52 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #709 +/- ## ========================================== - Coverage 37.91% 34.39% -3.52% ========================================== Files 120 151 +31 Lines 19476 20640 +1164 ========================================== - Hits 7384 7100 -284 - Misses 11884 13378 +1494 + Partials 208 162 -46 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.