14.2. OpenShift Virtualization ログの表示

Web コンソールまたは oc CLI を使用して、OpenShift Virtualization コンポーネントおよび仮想マシンのログを表示できます。virt-launcher Pod から仮想マシンのログを取得できます。ログの詳細度を制御するには、HyperConverged カスタムリソースを編集します。

14.2.1. CLI を使用した OpenShift Virtualization ログの表示

HyperConverged カスタムリソース (CR) を編集して、OpenShift Virtualization コンポーネントのログ詳細度を設定します。次に、oc CLI ツールを使用して、コンポーネント Pod のログを表示します。

手順

  1. 特定のコンポーネントのログの詳細度を設定するには、次のコマンドを実行して、デフォルトのテキストエディターで HyperConverged CR を開きます。

    $ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
  2. spec.logVerbosityConfig スタンザを編集して、1 つ以上のコンポーネントのログレベルを設定します。以下に例を示します。

    apiVersion: hco.kubevirt.io/v1beta1
    kind: HyperConverged
    metadata:
      name: kubevirt-hyperconverged
    spec:
      logVerbosityConfig:
        kubevirt:
          virtAPI: 5 1
          virtController: 4
          virtHandler: 3
          virtLauncher: 2
          virtOperator: 6
    1
    ログの詳細度の値は 1 ~ 9 の範囲の整数である必要があり、数値が大きいほど詳細なログであることを示します。この例では、virtAPI コンポーネントのログは、優先度が 5 以上の場合に公開されます。
  3. エディターを保存して終了し、変更を適用します。
  4. 以下のコマンドを実行して、OpenShift Virtualization の namespace 内の Pod のリストを表示します。

    $ oc get pods -n openshift-cnv

    例14.1 出力例

    NAME                               READY   STATUS    RESTARTS   AGE
    disks-images-provider-7gqbc        1/1     Running   0          32m
    disks-images-provider-vg4kx        1/1     Running   0          32m
    virt-api-57fcc4497b-7qfmc          1/1     Running   0          31m
    virt-api-57fcc4497b-tx9nc          1/1     Running   0          31m
    virt-controller-76c784655f-7fp6m   1/1     Running   0          30m
    virt-controller-76c784655f-f4pbd   1/1     Running   0          30m
    virt-handler-2m86x                 1/1     Running   0          30m
    virt-handler-9qs6z                 1/1     Running   0          30m
    virt-operator-7ccfdbf65f-q5snk     1/1     Running   0          32m
    virt-operator-7ccfdbf65f-vllz8     1/1     Running   0          32m
  5. コンポーネント Pod のログを表示するには、次のコマンドを実行します。

    $ oc logs -n openshift-cnv <pod_name>

    以下に例を示します。

    $ oc logs -n openshift-cnv virt-handler-2m86x
    注記

    Pod の起動に失敗した場合は、--previous オプションを使用して、最後の試行からのログを表示できます。

    ログ出力をリアルタイムで監視するには、-f オプションを使用します。

    例14.2 出力例

    {"component":"virt-handler","level":"info","msg":"set verbosity to 2","pos":"virt-handler.go:453","timestamp":"2022-04-17T08:58:37.373695Z"}
    {"component":"virt-handler","level":"info","msg":"set verbosity to 2","pos":"virt-handler.go:453","timestamp":"2022-04-17T08:58:37.373726Z"}
    {"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"}
    {"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"}
    {"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"}
    {"component":"virt-handler","level":"info","msg":"node-labeller is running","pos":"node_labeller.go:94","timestamp":"2022-04-17T08:58:37.391011Z"}

14.2.2. Web コンソールでの仮想マシンログの表示

関連付けられた仮想マシンランチャー Pod から仮想マシンログを取得します。

手順

  1. OpenShift Container Platform コンソールで、サイドメニューから VirtualizationVirtualMachines をクリックします。
  2. 仮想マシンを選択して、VirtualMachine details ページを開きます。
  3. Details タブをクリックします。
  4. Pod セクションの virt-launcher-<name> Pod をクリックして、Pod details ページを開きます。
  5. Logs タブをクリックして、Pod のログを表示します。

14.2.3. 一般的なエラーメッセージ

以下のエラーメッセージが OpenShift Virtualization ログに表示される場合があります。

ErrImagePull または ImagePullBackOff
デプロイメント設定が正しくないか、参照されているイメージに問題があることを示します。