Viewing OKD Virtualization logs

You can view logs for OKD Virtualization components and virtual machines by using the web console or the oc CLI. You can retrieve virtual machine logs from the virt-launcher pod. To control log verbosity, edit the HyperConverged custom resource.

Viewing OKD Virtualization logs with the CLI

Configure log verbosity for OKD Virtualization components by editing the HyperConverged custom resource (CR). Then, view logs for the component pods by using the oc CLI tool.

Procedure

  1. To set log verbosity for specific components, open the HyperConverged CR in your default text editor by running the following command:

    1. $ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
  2. Set the log level for one or more components by editing the spec.logVerbosityConfig stanza. For example:

    1. apiVersion: hco.kubevirt.io/v1beta1
    2. kind: HyperConverged
    3. metadata:
    4. name: kubevirt-hyperconverged
    5. spec:
    6. logVerbosityConfig:
    7. kubevirt:
    8. virtAPI: 5 (1)
    9. virtController: 4
    10. virtHandler: 3
    11. virtLauncher: 2
    12. virtOperator: 6
    1The log verbosity value must be an integer in the range 1–9, where a higher number indicates a more detailed log. In this example, the virtAPI component logs are exposed if their priority level is 5 or higher.
  3. Apply your changes by saving and exiting the editor.

  4. View a list of pods in the OKD Virtualization namespace by running the following command:

    1. $ oc get pods -n openshift-cnv

    Example output

    1. NAME READY STATUS RESTARTS AGE
    2. disks-images-provider-7gqbc 1/1 Running 0 32m
    3. disks-images-provider-vg4kx 1/1 Running 0 32m
    4. virt-api-57fcc4497b-7qfmc 1/1 Running 0 31m
    5. virt-api-57fcc4497b-tx9nc 1/1 Running 0 31m
    6. virt-controller-76c784655f-7fp6m 1/1 Running 0 30m
    7. virt-controller-76c784655f-f4pbd 1/1 Running 0 30m
    8. virt-handler-2m86x 1/1 Running 0 30m
    9. virt-handler-9qs6z 1/1 Running 0 30m
    10. virt-operator-7ccfdbf65f-q5snk 1/1 Running 0 32m
    11. virt-operator-7ccfdbf65f-vllz8 1/1 Running 0 32m
  5. To view logs for a component pod, run the following command:

    1. $ oc logs -n openshift-cnv <pod_name>

    For example:

    1. $ oc logs -n openshift-cnv virt-handler-2m86x

    If a pod fails to start, you can use the —previous option to view logs from the last attempt.

    To monitor log output in real time, use the -f option.

    Example output

    1. {"component":"virt-handler","level":"info","msg":"set verbosity to 2","pos":"virt-handler.go:453","timestamp":"2022-04-17T08:58:37.373695Z"}
    2. {"component":"virt-handler","level":"info","msg":"set verbosity to 2","pos":"virt-handler.go:453","timestamp":"2022-04-17T08:58:37.373726Z"}
    3. {"component":"virt-handler","level":"info","msg":"setting rate limiter to 5 QPS and 10 Burst","pos":"virt-handler.go:462","timestamp":"2022-04-17T08:58:37.373782Z"}
    4. {"component":"virt-handler","level":"info","msg":"CPU features of a minimum baseline CPU model: map[apic:true clflush:true cmov:true cx16:true cx8:true de:true fpu:true fxsr:true lahf_lm:true lm:true mca:true mce:true mmx:true msr:true mtrr:true nx:true pae:true pat:true pge:true pni:true pse:true pse36:true sep:true sse:true sse2:true sse4.1:true ssse3:true syscall:true tsc:true]","pos":"cpu_plugin.go:96","timestamp":"2022-04-17T08:58:37.390221Z"}
    5. {"component":"virt-handler","level":"warning","msg":"host model mode is expected to contain only one model","pos":"cpu_plugin.go:103","timestamp":"2022-04-17T08:58:37.390263Z"}
    6. {"component":"virt-handler","level":"info","msg":"node-labeller is running","pos":"node_labeller.go:94","timestamp":"2022-04-17T08:58:37.391011Z"}

Viewing virtual machine logs in the web console

Get virtual machine logs from the associated virtual machine launcher pod.

Procedure

  1. In the OKD console, click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. Click the Details tab.

  4. Click the virt-launcher-<name> pod in the Pod section to open the Pod details page.

  5. Click the Logs tab to view the pod logs.

Common error messages

The following error messages might appear in OKD Virtualization logs:

ErrImagePull or ImagePullBackOff

Indicates an incorrect deployment configuration or problems with the images that are referenced.