Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Sep 7, 2023
2 parents d754856 + cf37fd4 commit 92c573e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-documentation-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
extra-config: |
plugin_script_base_path: "/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.number }}"
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: github.event.action != 'closed'
with:
name: jekyll-docs
path: |
build/**
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: source-event
path: ${{ github.event_path }}
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Deploy preview directory
if: env.action == 'deploy'
uses: JamesIves/[email protected].1
uses: JamesIves/[email protected].3
with:
branch: ${{ env.preview_branch }}
folder: jekyll-docs
Expand All @@ -95,7 +95,7 @@ jobs:

- name: Remove preview directory
if: env.action == 'remove'
uses: JamesIves/[email protected].1
uses: JamesIves/[email protected].3
with:
branch: ${{ env.preview_branch }}
folder: ${{ env.emptydir }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
required: false
type: string
target-folder:
require: false
required: false
type: string

permissions:
Expand All @@ -27,7 +27,7 @@ jobs:
extra-config: ${{ inputs.extra-config }}

- name: Deploy 🚀
uses: JamesIves/[email protected].1
uses: JamesIves/[email protected].3
with:
branch: gh-pages
folder: build
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/publish-documentation-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ permissions:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy docs
uses: ./.github/workflows/deploy-docs.yml
with:
target-folder: version/${{ github.ref_name }}
uses: ./.github/workflows/deploy-docs.yml
with:
target-folder: version/${{ github.ref_name }}
7 changes: 3 additions & 4 deletions .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ on:
paths:
- 'docs/**'
- .github/workflows/publish-documentation.yml
- .github/workflows/deploy-docs.yml
- .github/workflows/build-docs/**

permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy docs
uses: ./.github/workflows/deploy-docs.yml
uses: ./.github/workflows/deploy-docs.yml
5 changes: 5 additions & 0 deletions lib/vagrant-libvirt/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def self.action_halt
b2.use Call, IsRunning do |env2, b3|
next unless env2[:result]

if env2[:force_halt]
b3.use HaltDomain
next
end

b3.use StartShutdownTimer
b3.use Call, GracefulHalt, :shutoff, :running do |env3, b4|
if !env3[:result]
Expand Down
5 changes: 4 additions & 1 deletion lib/vagrant-libvirt/action/shutdown_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def call(env)
if env[:machine].state.id == @source_state
env[:ui].info(I18n.t('vagrant_libvirt.shutdown_domain'))
domain.shutdown
domain.wait_for(timeout) { !ready? }
begin
domain.wait_for(timeout) { !ready? }
rescue Fog::Errors::TimeoutError
end
end

env[:result] = env[:machine].state.id == @target_state
Expand Down
6 changes: 6 additions & 0 deletions lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def cleanup(machine, _opts)
error_message: e.message
end
end

# Enable virtiofs synced folders within WSL when in use
# on non-DrvFs file systems
def self.wsl_allow_non_drvfs?
true
end
end
end
end
66 changes: 66 additions & 0 deletions spec/acceptance/shutdown_halt_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# frozen_string_literal: true

require_relative '../spec_helper'

describe 'shutdown and halt', acceptance: true do
include_context 'libvirt_acceptance'

before do
environment.skeleton('default_settings')
end

after do
assert_execute('vagrant', 'destroy', '--force')
end

context 'when system accessible' do
it 'graceful shutdown should succeed' do
status('Test: machine is created successfully')
result = environment.execute('vagrant', 'up')
expect(result).to exit_with(0)

status('Test: Halt')
result = environment.execute('vagrant', 'halt')
expect(result).to exit_with(0)

status('Test: validate output')
expect(result.stdout).to match(/Attempting graceful shutdown of VM/)
expect(result.stdout).to_not match(/Halting domain.../)
end

it 'forced halt should skip graceful and succeed' do
status('Test: machine is created successfully')
result = environment.execute('vagrant', 'up')
expect(result).to exit_with(0)

status('Test: Halt')
result = environment.execute('vagrant', 'halt', '-f')
expect(result).to exit_with(0)

status('Test: validate output')
expect(result.stdout).to_not match(/Attempting graceful shutdown of VM/)
expect(result.stdout).to match(/Halting domain.../)
end
end

context 'when system hung' do
it 'should call halt after failed graceful' do
status('Test: machine is created successfully')
result = environment.execute('vagrant', 'up')
expect(result).to exit_with(0)

status('Test: Trigger crash to prevent graceful halt working')
result = environment.execute('vagrant', 'ssh', '-c', 'nohup sudo sh -c \'echo -n c > /proc/sysrq-trigger\' >/dev/null 2>&1 </dev/null', '--', '-f')
expect(result).to exit_with(0)

status('Test: Halt')
result = environment.execute('vagrant', 'halt')
expect(result).to exit_with(0)

status('Test: validate output')
expect(result.stdout).to match(/Attempting graceful shutdown of VM/)
expect(result.stdout).to match(/Guest communication could not be established/)
expect(result.stdout).to match(/Halting domain.../)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
Vagrant.configure("2") do |config|
config.vm.box = "infernix/tinycore"
config.ssh.shell = "/bin/sh"
config.ssh.insert_key = false # reboots revert box contents
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.graceful_halt_timeout = 5
end

0 comments on commit 92c573e

Please sign in to comment.