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

[Resource] Deprecate Snapshot For Instance Snapshot #5675

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

ismirlia
Copy link
Collaborator

@ismirlia ismirlia commented Sep 23, 2024

Output from acceptance testing:

=== RUN   TestAccIBMPIInstanceSnapshotbasic
--- PASS: TestAccIBMPIInstanceSnapshotbasic (870.97s)
PASS

=== RUN   TestAccIBMPIInstanceSnapshotUserTags
--- PASS: TestAccIBMPIInstanceSnapshotUserTags (758.19s)
PASS

=== RUN   TestAccIBMPIInstanceSnapshotbasicV0
--- PASS: TestAccIBMPIInstanceSnapshotbasicV0 (990.81s)
PASS

=== RUN   TestAccIBMPIInstanceSnapshotUserTagsV0
--- PASS: TestAccIBMPIInstanceSnapshotUserTagsV0 (1033.34s)
PASS

@ismirlia
Copy link
Collaborator Author

@hkantare @yussufsh Please review as part of power Q3 release.

website/docs/r/pi_instance_snapshot.html.markdown Outdated Show resolved Hide resolved
ibm/provider/provider.go Outdated Show resolved Hide resolved
website/docs/r/pi_instance_snapshot.html.markdown Outdated Show resolved Hide resolved
website/docs/r/pi_instance_snapshot.html.markdown Outdated Show resolved Hide resolved
@ismirlia
Copy link
Collaborator Author

ismirlia commented Oct 1, 2024

--- PASS: TestAccIBMPIInstanceSnapshotbasic (1253.30s)
PASS

@ismirlia ismirlia requested a review from yussufsh October 1, 2024 16:48
@ismirlia ismirlia force-pushed the snapshots-deprecation branch from 79886b1 to 68a3f90 Compare October 2, 2024 04:52
Alexander-Kita
Alexander-Kita previously approved these changes Oct 2, 2024
@ismirlia
Copy link
Collaborator Author

ismirlia commented Nov 5, 2024

@yussufsh Was there any other comment on this? Is this mergeable? (I squashed the commits recently)

@ismirlia ismirlia force-pushed the snapshots-deprecation branch from 5268091 to ab16f36 Compare November 5, 2024 22:16
@ismirlia
Copy link
Collaborator Author

ismirlia commented Dec 4, 2024

@yussufsh can you merge this?

@ismirlia
Copy link
Collaborator Author

ismirlia commented Jan 6, 2025

Can we please merge this @yussufsh and @hkantare ?

@hkantare
Copy link
Collaborator

hkantare commented Jan 8, 2025

@yussufsh can you approve this PR

client := instance.NewIBMPISnapshotClient(ctx, sess, cloudInstanceID)
snapshot, err := client.Get(snapshotID)
if err != nil {
// snapshot does not exist
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to add a TODO comment?
Check if the error code is 404.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not following the issue in this line. Do you want me to check the error code of the get and only set the id to empty if the we get a 404 vs another unrelated reason the get failed? This step of getting the snapshot seems strange already because I'm not seeing other resources get the item they want to delete before calling delete. Before this PR, the last edit to this was here: https://github.com/IBM-Cloud/terraform-provider-ibm/pull/3429/files#diff-317acb20df0113077a2bc534ea43860b874afacdb0685550b7a64907721bec76 where it was assumed previously if we couldn't get it we should error out because it should still exist at that point to terraform before we delete it.

I don't think I mentioned this earlier. The main goal of this PR was to create a new resource called ibm_pi_instance_snapshot to replace the existing ibm_pi_snapshot because it called the instance snapshot api and not the snapshot api. I didn't touch any of the code or documentation in the snapshot ibm_pi_snapshot resource unless it was to add something new we needed (like user tags). I'm more than happy to make any tweaks to how this works, but I did not write this originally so I don't know why it was written this way. 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I recall it correctly the delete api did not have a 404 return code hence we were relying on get api before deleting. If delete can return 404 we can remove the get call.
I'm not sure how that comment ended up there but this needs cleaning. That is why mentioned here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I see, I'll double check it.

  /pcloud/v1/cloud-instances/{cloud_instance_id}/snapshots/{snapshot_id}:
    delete:
      operationId: pcloud.cloudinstances.snapshots.delete
      responses:
        "202":
          description: Accepted
          schema:
            $ref: '#/definitions/Object'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/Error'
        "401":
          description: Unauthorized
          schema:
            $ref: '#/definitions/Error'
        "403":
          description: Forbidden
          schema:
            $ref: '#/definitions/Error'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/Error'
        "410":
          description: Gone
          schema:
            $ref: '#/definitions/Error'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/Error'

It looks like we have a 404 now, so I'll remove the check.

- `pi_instance_name` - (Required, String) The name of the instance you want to take a snapshot of.
- `pi_snapshot_name` - (Required, String) The unique name of the snapshot.
- `pi_user_tags` - (Optional, List) The user tags attached to this resource.
- `pi_volume_ids` - (Optional, String) A list of volume IDs of the instance that will be part of the snapshot. If none are provided, then all the volumes of the instance will be part of the snapshot.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not this be List of strings?
Also saw another instance below

`volume_snapshots` - (String) A map of volume snapshots included in the PVM instance snapshot.

How can a map be string type?

I am going to merge this PR, please correct in future PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yussufsh yussufsh merged commit 93d748a into IBM-Cloud:master Jan 9, 2025
1 check passed
@yussufsh yussufsh deleted the snapshots-deprecation branch January 9, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/Power Systems Issues related to Power Systems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants