Add lock checks in delete functions of disk and config resources#2237
Open
zliang-akamai wants to merge 5 commits intolinode:devfrom
Open
Add lock checks in delete functions of disk and config resources#2237zliang-akamai wants to merge 5 commits intolinode:devfrom
zliang-akamai wants to merge 5 commits intolinode:devfrom
Conversation
… in an undesired state (shutdown) during deletion attempts
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds lock validation to prevent deletion of disks and configs when their parent Linode instance has a cannot_delete_with_subresources lock. The changes ensure that locked Linodes remain in their current state and prevent unintended shutdowns during deletion attempts.
Changes:
- Added lock checks in disk and config deletion workflows to validate against
cannot_delete_with_subresourceslock type - Introduced a helper function to check if a Linode has the
cannot_delete_with_subresourceslock - Added clear error messages when deletion is blocked due to resource locks
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| linode/instancedisk/framework_resource.go | Added lock validation before disk deletion to prevent deletion when parent Linode is locked |
| linode/instanceconfig/resource.go | Added lock validation before config deletion to prevent deletion when parent Linode is locked |
| linode/helper/instance.go | Introduced helper function to check for cannot_delete_with_subresources lock on Linode instances |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Add checks for disks and config to prevent a locked Linode from being in an undesired state (shutdown) during deletion attempts
✔️ How to Test
Replace all
tofucommands withterraformif you are using Terraform rather than OpenTofuApplying Config with Instance, Disk, Config, and Lock
With the following TF config:
Remove the Lock from TF State and Config
This is necessary to test how TF reacts when attempting to delete a Linode config/disk locked by an external lock not managed by the TF.
Removing Lock from State
Removing Lock in TF Config
Check plan to ensure plan is empty
Attempt Deletion
Verify an error similar to this appears:
Also check cloud manager and verify the Linode is still in running state and wasn't powered off or shutting down