Skip to content

feat(block): add support for identity for snapshot and volume#3656

Open
remyleone wants to merge 1 commit intoscaleway:mainfrom
remyleone:identity_block
Open

feat(block): add support for identity for snapshot and volume#3656
remyleone wants to merge 1 commit intoscaleway:mainfrom
remyleone:identity_block

Conversation

@remyleone
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 11, 2026 12:32
@remyleone remyleone requested a review from a team as a code owner February 11, 2026 12:32
@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 2.43%. Comparing base (c46a38a) to head (a92f3ff).
⚠️ Report is 50 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/services/block/snapshot.go 0.00% 10 Missing ⚠️
internal/services/block/volume.go 0.00% 10 Missing ⚠️
internal/services/block/snapshot_data_source.go 0.00% 7 Missing ⚠️
internal/services/block/volume_data_source.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #3656      +/-   ##
========================================
+ Coverage   2.34%   2.43%   +0.09%     
========================================
  Files        453     469      +16     
  Lines      49798   54631    +4833     
========================================
+ Hits        1167    1330     +163     
- Misses     48540   53205    +4665     
- Partials      91      96       +5     

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Terraform ResourceIdentity support for Scaleway Block Storage volumes and snapshots, aligning these resources with the provider’s identity-based import/state conventions.

Changes:

  • Add Identity: identity.DefaultZonal() to block volume and snapshot resources and populate identity via identity.SetZonalIdentity.
  • Refactor block volume/snapshot data sources to read via waitForBlockVolume / waitForBlockSnapshot and reuse shared state-setting helpers.
  • Update TestSDKProvider_ResourceIdentityNotEmpty to remove scaleway_block_snapshot / scaleway_block_volume from the exception list.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
provider/sdkv2_test.go Removes block snapshot/volume from the “no identity” exceptions list.
internal/services/block/volume.go Adds zonal identity support and extracts setVolumeState helper.
internal/services/block/snapshot.go Adds zonal identity support and extracts setSnapshotState helper.
internal/services/block/volume_data_source.go Refactors data source read path to use waiter + shared state setter.
internal/services/block/snapshot_data_source.go Refactors data source read path to use waiter + shared state setter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +75 to +77
// Wait for the volume and use it to set the state
volume, err := waitForBlockVolume(ctx, api, zone, volumeID.(string), d.Timeout(schema.TimeoutRead))
if err != nil {
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

waitForBlockVolume is called with volumeID.(string), but volume_id is stored in state as a zoned ID (e.g. fr-par-1/<uuid>). On subsequent reads (or when the user provides a localized ID), this will pass the localized form to the Block API, which expects the raw UUID, and it also ignores the zone embedded in the ID. Parse the zoned ID (e.g. via zonal.ParseID / locality.ExpandID) and use the extracted id (and zone if present) when calling waitForBlockVolume.

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +81
d.SetId("")

return nil
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

For a data source, swallowing a 404 by clearing d.SetId("") and returning nil will typically lead to confusing downstream behavior (empty/unknown data) instead of a clear failure. The rest of the codebase’s data sources return a "... not found" diagnostic when the remote object doesn’t exist; consider returning a diag.Errorf here (including the zoned ID) rather than silently succeeding.

Suggested change
d.SetId("")
return nil
return diag.Errorf("block volume %s not found", zoneID)

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +78
// Wait for the snapshot and use it to set the state
snapshot, err := waitForBlockSnapshot(ctx, api, zone, snapshotID.(string), d.Timeout(schema.TimeoutRead))
if err != nil {
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

waitForBlockSnapshot is called with snapshotID.(string), but snapshot_id is stored in state as a zoned ID (e.g. fr-par-1/<uuid>). On subsequent reads (or when the user provides a localized ID), this will pass the localized form to the Block API, which expects the raw UUID, and it also ignores the zone embedded in the ID. Parse the zoned ID (e.g. via zonal.ParseID / locality.ExpandID) and use the extracted id (and zone if present) when calling waitForBlockSnapshot.

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +82
d.SetId("")

return nil
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

For a data source, swallowing a 404 by clearing d.SetId("") and returning nil will typically lead to confusing downstream behavior (empty/unknown data) instead of a clear failure. The rest of the codebase’s data sources return a "... not found" diagnostic when the remote object doesn’t exist; consider returning a diag.Errorf here (including the zoned ID) rather than silently succeeding.

Suggested change
d.SetId("")
return nil
return diag.Errorf("snapshot %s not found", zoneID)

Copilot uses AI. Check for mistakes.
@remyleone remyleone deleted the branch scaleway:main February 27, 2026 10:20
@remyleone remyleone closed this Feb 27, 2026
@yfodil yfodil reopened this Feb 27, 2026
@yfodil yfodil changed the base branch from master to main February 27, 2026 10:29
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