-
Notifications
You must be signed in to change notification settings - Fork 3
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
Delete workloads before volumesets on GVC deletion #245
Delete workloads before volumesets on GVC deletion #245
Conversation
WalkthroughThe changes involve updates to the Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
spec/command/delete_spec.rb (1)
80-84
: LGTM! Proper verification of deletion order.The expectations correctly verify that workloads are deleted before volumesets, which addresses the core issue. However, consider adding a specific test case that verifies the failure scenario when attempting to delete volumesets before workloads.
Consider adding a test like this:
it "fails when trying to delete volumesets before workloads" do # Mock the API to simulate attempting volumeset deletion first allow(API::Volumeset).to receive(:delete).and_raise("Volumeset in use by workload") result = run_cpflow_command("delete", "-a", app, "--volumeset", "postgres-volume", "--yes") expect(result[:status]).not_to eq(0) expect(result[:stderr]).to include("Cannot delete volumeset 'postgres-volume' as it is in use by workload") endlib/command/delete.rb (2)
126-128
: Ensure@workloads
is initialized before use indelete_workloads
The method
delete_workloads
relies on@workloads
being initialized incheck_workloads
. To avoid potential errors, ensure thatdelete_workloads
is only called aftercheck_workloads
, or initialize@workloads
to an empty array by default.
Line range hint
134-140
: Remove redundant workload deletion indelete_volumesets
Since workloads are now deleted before volumesets in
delete_gvc_items
, the code indelete_volumesets
that deletes workloads if they are attached to volumesets is redundant. Removing this code avoids unnecessary deletion attempts.Apply this diff to remove the redundant code:
def delete_volumesets @volumesets.each do |volumeset| step("Deleting volumeset '#{volumeset['name']}' from app '#{config.app}'") do - # If the volumeset is attached to a workload, we need to delete the workload first - workload = volumeset.dig("status", "usedByWorkload")&.split("/")&.last - cp.delete_workload(workload) if workload cp.delete_volumeset(volumeset["name"]) end end end
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
CHANGELOG.md
(1 hunks)lib/command/delete.rb
(2 hunks)spec/command/delete_spec.rb
(4 hunks)
🔇 Additional comments (6)
spec/command/delete_spec.rb (3)
35-38
: LGTM! Comprehensive message verification.
The expectations properly verify that appropriate messages are displayed when no resources (workloads, volumesets, images) exist in the app.
48-51
: LGTM! Consistent message verification in confirmation context.
The expectations maintain consistency with other scenarios while verifying the confirmation flow.
61-64
: LGTM! Consistent message verification in skip confirmation context.
The expectations maintain consistency across all deletion scenarios while verifying the skip confirmation flow.
CHANGELOG.md (1)
23-24
: LGTM! The changelog entry is well-formatted and descriptive.
The entry clearly documents the fix for the GVC deletion issue when workloads have volumesets in use, following the established changelog format and properly crediting the contributor.
lib/command/delete.rb (2)
54-61
: Refactored delete_whole_app
method enhances clarity and maintainability
The introduction of check_gvc_items
and delete_gvc_items
methods in delete_whole_app
improves code organization by separating concerns. This refactoring enhances readability and makes the deletion process more modular.
63-68
: Good use of check_gvc_items
to consolidate checks
The check_gvc_items
method effectively groups the pre-deletion checks for workloads, volumesets, and images, promoting code reuse and maintainability.
There is no But there is Current implementation of Should we take advantage of this command i/o multiple API DELETE requests? @dzirtusss @rafaelgomesxyz @dzirtusss WDYT? |
@zzaakiirr I'm confused. I had already fixed this issue: It checks if a volumeset is attached to a workload and deletes it first. Why is it not working? |
@zzaakiirr @dzirtusss By the way, I'd prefer if we rely more on the API than the CLI, because we can run into versioning issues with the CLI, while that's not the case for the API. |
Sorry, I missed that. Maybe API response changed? I don't seee If so, we can fix only this part: OR we can leave current implementation and remove workload deletion logic from @rafaelgomesxyz WDYT? |
@zzaakiirr It's more efficient to only delete workloads that are using a volumeset, so I'd do it that way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just fix the method we had before instead of deleting all workloads, which takes more time and is less efficient.
I do wonder why the specs weren't failing though, if the API changed. Or maybe they were and we didn't catch it?
b40a289
to
ec0c7a4
Compare
Done
The test that should have detected error is marked with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left just a couple minor suggestions, if you could do those before merging.
What does this PR do?
This PR fixes issue where GVC deletion fails because one of the workloads has volumeset in-use - added deletion of workloads before deletion of volumesets
Steps to reproduce issue
cpflow delete -a <GVC_NAME>
Expected behaviour
All volumesets, workloads, identities and images and GVC are deleted
Actual behaviour
Error
This volume set is in use by a workload and cannot be deleted
appearsWhy does this error appears?
See #245 (comment)
Summary by CodeRabbit
Bug Fixes
Documentation
Summary by CodeRabbit
Bug Fixes
run
command related to environment variables in runner workloads.Documentation