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

refactor: finish moving device resource off of packngo #501

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

ctreatma
Copy link
Contributor

We previously migrated the Equinix Metal device data source and the read pathways for the resource from packngo to metal-go (and then to equinix-sdk-go). This finishes the migration of the device resource by replacing packngo with equinix-sdk-go in the create, update, and delete pathways for that resource.

@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

Attention: 757 lines in your changes are missing coverage. Please review.

Comparison is base (26b2f3d) 60.11% compared to head (cebf38a) 59.06%.
Report is 129 commits behind head on main.

❗ Current head cebf38a differs from pull request most recent head 5bab641. Consider uploading reports for the commit 5bab641 to get more accurate results

Files Patch % Lines
internal/errors/errors.go 7.05% 145 Missing ⚠️
equinix/fabric_mapping_helper.go 0.00% 69 Missing ⚠️
equinix/resource_metal_device.go 73.91% 44 Missing and 16 partials ⚠️
equinix/resource_fabric_connection.go 0.00% 53 Missing ⚠️
equinix/resource_fabric_cloud_router.go 0.00% 43 Missing ⚠️
equinix/resource_network_device.go 2.50% 39 Missing ⚠️
equinix/resource_fabric_service_profile.go 0.00% 26 Missing ⚠️
internal/resources/metal/metal_ssh_key/resource.go 73.62% 19 Missing and 5 partials ⚠️
equinix/resource_fabric_routing_protocol.go 0.00% 23 Missing ⚠️
equinix/resource_metal_virtual_circuit.go 50.00% 13 Missing and 2 partials ⚠️
... and 43 more

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #501      +/-   ##
==========================================
- Coverage   60.11%   59.06%   -1.06%     
==========================================
  Files          99       96       -3     
  Lines       20045    19855     -190     
==========================================
- Hits        12051    11727     -324     
- Misses       7691     7832     +141     
+ Partials      303      296       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from 23f7340 to f0d1583 Compare December 22, 2023 15:57
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from f0d1583 to 4d1e997 Compare December 22, 2023 16:02
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from 4d1e997 to bf81d6d Compare December 22, 2023 16:58
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from bf81d6d to dcacfe4 Compare December 22, 2023 18:45
@ctreatma ctreatma marked this pull request as draft December 22, 2023 21:15
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from dcacfe4 to 08ce405 Compare January 2, 2024 17:42
@ctreatma ctreatma marked this pull request as ready for review January 2, 2024 18:23
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from 08ce405 to 57a7d81 Compare January 2, 2024 19:34
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from 57a7d81 to e689b16 Compare January 2, 2024 20:23
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from e689b16 to 5865bab Compare January 2, 2024 21:18
@ctreatma ctreatma requested a deployment to internal January 2, 2024 22:19 — with GitHub Actions Abandoned
@ctreatma ctreatma requested a deployment to internal January 3, 2024 16:38 — with GitHub Actions Abandoned
@ctreatma ctreatma requested a deployment to internal January 3, 2024 18:13 — with GitHub Actions Abandoned
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from 5865bab to febbae9 Compare January 9, 2024 16:42
@ctreatma ctreatma requested a deployment to internal January 9, 2024 17:26 — with GitHub Actions Abandoned
displague
displague previously approved these changes Jan 9, 2024
Copy link
Member

@displague displague left a comment

Choose a reason for hiding this comment

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

lgtm

equinix/resource_metal_device_acc_test.go Outdated Show resolved Hide resolved
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from febbae9 to c0357d4 Compare January 12, 2024 18:18
@ctreatma ctreatma requested a deployment to internal January 12, 2024 19:06 — with GitHub Actions Abandoned
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from c0357d4 to cebf38a Compare January 12, 2024 19:44
@ctreatma ctreatma force-pushed the device-to-equinix-sdk-go branch from cebf38a to 5bab641 Compare January 12, 2024 20:09
meta.(*config.Config).AddModuleToMetalGoUserAgent(d)
client := meta.(*config.Config).Metalgo

ur := metalv1.DeviceUpdateInput{}

if d.HasChange("locked") {
Copy link
Contributor Author

@ctreatma ctreatma Jan 16, 2024

Choose a reason for hiding this comment

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

So...after digging into what it means for a device to be locked and confirming that we don't have to use a separate update request to change the lock status, it turns out that locked is a computed attribute for a metal_device resource, so it's not actually possible to hit this code path anyway.

So: do we want to stick with the existing behavior that locked can't be changed or do we want to support locking/unlocking devices in terraform?

For reference, this is the information we got about what locking does:

It seems that locking a device prevents you from:

  • Delete/deprovision the device
  • Reinstall the device
  • Prevents an instance with a termination time set to be reclaimed, even if the termination time was reached (for spot instances, we will reclaim it anyway)
  • Perform a Firmware update on the device (this feature is not GA yet)

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it's a core state for our devices to support and so terraform should be able to do it.

Copy link
Member

Choose a reason for hiding this comment

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

The list of lock affecting features is helpful context. Without that we may expect behaviors that are not present today: https://feedback.equinixdigital.com/instances/p/expand-lock-feature-for-metal-servers.

It's worth considering the ways Terraform and a Portal user would interact through EM API device locking (not to be confused with Terraform state locking).

If Terraform takes an "optional" (default=false) behavior, rather than computed, then plan/apply from Terraform would inform users that an externally applied lock is going to be reset upon change.

When Terraform config requests lock, then any API changes that are incompatible with lock would fail until the Terraform config is modified to lock=false (or the lock line is removed).

I'm not seeing any problems in taking this approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, sounds like we're all agreed; I'm going to update the resource so that locked can be set and update the docs accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I enabled locking/unlocking a device resource; this PR has been updated but here's a direct link to the commit that has those changes: 836f1f0

I opted to make locked optional and computed, rather than optional with a default. IMO changing it from computed to default has a bigger impact on existing users, because if we switch to a default of false then any terraform user who currently has a locked device is at risk for accidentally unlocking the device as a result of a non-major-version provider upgrade.

@displague
Copy link
Member

displague commented Jan 18, 2024

The only E2E failure that doesn't look like flake, but also looks to be unrelated:

=== NAME  TestAccMetalSpotMarketRequestCreate_WithTimeout
    resource_metal_spot_market_request_acc_test.go:245: Step 1/1, expected an error with pattern, no match on: Error running apply: exit status 1
        
        Error: POST https://api.equinix.com/metal/v1/projects/0667bb71-9428-4919-8c1d-58fc0fb95613/spot-market-requests?include=devices%2Cproject%2Cplan: 422 2.21 exceeds the maximum bid price of 2.20 
        
          with equinix_metal_spot_market_request.request,
          on terraform_plugin_test.tf line 122, in resource "equinix_metal_spot_market_request" "request":
         122: resource "equinix_metal_spot_market_request" "request" {

@ctreatma ctreatma merged commit 3c9d029 into main Jan 18, 2024
4 of 5 checks passed
@ctreatma ctreatma deleted the device-to-equinix-sdk-go branch January 18, 2024 16:33
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.

4 participants