diff --git a/.github/workflows/build-documentation-preview.yml b/.github/workflows/build-documentation-preview.yml index e3fe13c4b..563b903f8 100644 --- a/.github/workflows/build-documentation-preview.yml +++ b/.github/workflows/build-documentation-preview.yml @@ -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 }} diff --git a/.github/workflows/deploy-docs-preview.yml b/.github/workflows/deploy-docs-preview.yml index bdbc8e9da..90dd2d4f4 100644 --- a/.github/workflows/deploy-docs-preview.yml +++ b/.github/workflows/deploy-docs-preview.yml @@ -69,7 +69,7 @@ jobs: - name: Deploy preview directory if: env.action == 'deploy' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.4.3 with: branch: ${{ env.preview_branch }} folder: jekyll-docs @@ -95,7 +95,7 @@ jobs: - name: Remove preview directory if: env.action == 'remove' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.4.3 with: branch: ${{ env.preview_branch }} folder: ${{ env.emptydir }} diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 24020e5ed..0935d6fdb 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -6,7 +6,7 @@ on: required: false type: string target-folder: - require: false + required: false type: string permissions: @@ -27,7 +27,7 @@ jobs: extra-config: ${{ inputs.extra-config }} - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.4.3 with: branch: gh-pages folder: build diff --git a/.github/workflows/publish-documentation-release.yml b/.github/workflows/publish-documentation-release.yml index 4d65a21de..5cd84cd57 100644 --- a/.github/workflows/publish-documentation-release.yml +++ b/.github/workflows/publish-documentation-release.yml @@ -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 }} diff --git a/.github/workflows/publish-documentation.yml b/.github/workflows/publish-documentation.yml index c21d697ad..b259f18ed 100644 --- a/.github/workflows/publish-documentation.yml +++ b/.github/workflows/publish-documentation.yml @@ -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 diff --git a/lib/vagrant-libvirt/action.rb b/lib/vagrant-libvirt/action.rb index 5666c34cb..f527f8188 100644 --- a/lib/vagrant-libvirt/action.rb +++ b/lib/vagrant-libvirt/action.rb @@ -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] diff --git a/lib/vagrant-libvirt/action/shutdown_domain.rb b/lib/vagrant-libvirt/action/shutdown_domain.rb index 05d377507..d15c76048 100644 --- a/lib/vagrant-libvirt/action/shutdown_domain.rb +++ b/lib/vagrant-libvirt/action/shutdown_domain.rb @@ -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 diff --git a/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb b/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb index c57a6ac57..764808318 100644 --- a/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +++ b/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb @@ -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 diff --git a/spec/acceptance/shutdown_halt_spec.rb b/spec/acceptance/shutdown_halt_spec.rb new file mode 100644 index 000000000..374cd81a7 --- /dev/null +++ b/spec/acceptance/shutdown_halt_spec.rb @@ -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