The VM doesn’t stop when shutdown is run inside the guest OS

Scenario

The virtual machine exercise9 does not remain powered off after the user executes the shutdown -h now command within the guest operating system. Instead, it powers back on automatically a few seconds after the shutdown process completes.

You need to modify the Virtual Machine configuration to ensure it remains in a stopped state after shutdown using guest OS.
09 break01

The steps to fix exercise9 are:

Breaking the exercise
lab break exercise

Console

  1. Login to OpenShift console using the assigned user account.

Username
userx
Password
{password}
  1. Go to virtualization → Virtual Machines - select project for the assigned user account

09 break02
  1. Select the exercise9 virtual machine

09 break03
  1. Open the virtual machine Console tab

09 break04
  1. Log in with user lab-user and password redhat1. After that execute the sudo shutdown -h now command

09 break05
  1. Verify the virtual machine stopped

09 break06
  1. After some seconds the virtual machine will be Running again.

09 break07
  1. Open the YAML tab

09 break08
  1. Verify that runStrategy is configured as Always

09 break09
  1. Change it to Manual

09 break10
Run grade to validate the exercise
lab grade exercise9

Command line (CLI)

  1. Login to Openshift server API using the assigned user account with oc command if not logged in.

OpenShift login command
{login_command}
  1. Go to the assigned namespace-userx

oc project namespace-userx
  1. List the virtual machines

oc get vm
  1. Shutdown the virtual machine using OS command

virtctl ssh lab-user@exercise9 \
--command 'sudo shutdown -h now'
  1. Check the virtual machine stopped and started again after a few seconds

oc get vm
  1. Edit the virtual machine and change runStrategy from always to manual

oc edit vm exercise9
  1. Shutdown the virtual machine using OS command again

virtctl ssh lab-user@exercise9 \
--command 'sudo shutdown -h now'
  1. Check the virtual machine still stopped

oc get vm

What you learned

In this exercise, you learned that when the runStrategy is set to Always, a virtual machine cannot be powered off directly from the operating system. To power it off, you need to either remove the runStrategy configuration or set it to Manual.