diff --git a/CHANGELOG.md b/CHANGELOG.md index 91126aa2..6c3e190e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ _Please add entries here for your pull requests that have not yet been released. - Fixed potential infinite loop that could occur for a command if one of the execution steps fails and gets stuck. [PR 217](https://github.com/shakacode/control-plane-flow/pull/217) by [Zakir Dzhamaliddinov](https://github.com/zzaakiirr). +- Fixed issue where app cannot be deleted because one of the workloads has a volumeset in-use. [PR 245](https://github.com/shakacode/control-plane-flow/pull/245) by [Zakir Dzhamaliddinov](https://github.com/zzaakiirr). + ## [4.0.0] - 2024-08-21 ### Fixed diff --git a/lib/command/delete.rb b/lib/command/delete.rb index 94c7ccac..19b785e2 100644 --- a/lib/command/delete.rb +++ b/lib/command/delete.rb @@ -106,9 +106,9 @@ def delete_workload(workload) 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 + # If the volumeset is attached to workloads, we need to delete the workloads first + workloads = volumeset.dig("status", "workloadLinks")&.map { |workload_link| workload_link.split("/").last } + workloads&.each { |workload| cp.delete_workload(workload) } cp.delete_volumeset(volumeset["name"]) end