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

fix: destroy attached volumes after a server destroy #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/vagrant-scaleway/action/destroy_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ def initialize(app, _env)

def call(env)
server = env[:scaleway_compute].servers.get(env[:machine].id)
volumes = env[:scaleway_compute].servers.get(env[:machine].id).volumes

# Destroy the server and remove the tracking ID
env[:ui].info(I18n.t('vagrant_scaleway.destroying'))

begin
server.destroy
env[:ui].info(I18n.t('vagrant_scaleway.destroying_volume'))
volumes.each_value(&:destroy)
rescue Fog::Scaleway::Compute::InvalidRequestError => e
if e.message =~ /server should be stopped/
server.terminate(false)
Expand Down
2 changes: 2 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ en:
Stopping the server...
destroying: |-
Destroying the server...
destroying_volume: |-
Destroying orphan attached volume...
waiting_for_ready: |-
Waiting for server to become "ready"...
waiting_for_ssh: |-
Expand Down