Skip to content

Commit

Permalink
More reliable node:purge-pvcs
Browse files Browse the repository at this point in the history
  • Loading branch information
dbackeus committed Nov 7, 2024
1 parent 59426b3 commit d6129a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions k
Original file line number Diff line number Diff line change
Expand Up @@ -2352,8 +2352,12 @@ def node_purge_pvcs

puts "Deleting #{namespace}/#{pv_name}..."

kubectl("delete pvc #{name} -n #{namespace}") or abort("Error: failed to delete PVC #{name}")
kubectl("delete pv #{pv_name}") or abort("Error: failed to delete PV #{pv_name}")
# Deleting PVC's is weird in that it's not possible to remove the PVC finalizer until it's
# in terminating state. So we have to first trigger the delete to enter terminating state,
# then patch the PVC to remove the finalizer for deletion to complete.
kubectl("delete pvc #{name} -n #{namespace} --wait=false") or abort("Error: failed to delete PVC #{name}")
kubectl("patch pvc #{name} -n #{namespace} -p '{\"metadata\":{\"finalizers\":null}}'")
kubectl("delete pv #{pv_name} --ignore-not-found") or abort("Error: failed to delete PV #{pv_name}")
end

puts
Expand Down

0 comments on commit d6129a8

Please sign in to comment.