Bug 1834717

Summary: VM with runStrategy attribute (instead of 'running' attribute) has Status 'Stopping' in the UI
Product: OpenShift Container Platform Reporter: Yaacov Zamir <yzamir>
Component: Console Kubevirt PluginAssignee: Filip Krepinsky <fkrepins>
Status: CLOSED WONTFIX QA Contact: Ruth Netser <rnetser>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.4CC: aos-bugs, fkrepins, ibezukh, ncredi, rnetser, tjelinek, yzamir
Target Milestone: ---   
Target Release: 4.4.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
Cause: VM with runStrategy Manual is not stating if it should be running or stopped by it's runStrategy Consequence: The UI wrongly assumes a VM with runStrategy Manual should be running. Workaround (if any): When using VM in UI environment, use the running attribute, or set runStrategy to one of Always, RerunOnFailure, Halted but not Manual Result:
Story Points: ---
Clone Of: 1834671 Environment:
Last Closed: 2020-05-27 15:55:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1834671    
Bug Blocks:    
Attachments:
Description Flags
Stopped VM with runStrategy: Manual none

Description Yaacov Zamir 2020-05-12 09:40:11 UTC
+++ This bug was initially created as a clone of Bug #1834671 +++

Description of problem:
A running VM with runStrategy attribute (instead of 'running' attribute) has a running VMI but the VM status in the UI is 'Stopping'

Version-Release number of selected component (if applicable):
OCP 4.4, CNV 2.3


How reproducible:
100%

Steps to Reproduce:
1. Create a VM with runStrategy: Always (as an example, can be Manual/Halted and a started VM)
2. Check the VM status in the UI


Actual results:
While the VMI has 'phase: Running', in the UI - the VM status is 'Stopping'; see attached screenshot.


Expected results:
Correct VM status should be displayed (running).


Additional info:

========= VM yaml ===========
---
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  labels:
    kubevirt.io/vm: vm-cirros
  name: vm-cirros
spec:
  runStrategy: Always
  template:
    metadata:
      labels:
        kubevirt.io/vm: vm-cirros
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: containerdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
        machine:
          type: ""
        resources:
          requests:
            memory: 64M
      terminationGracePeriodSeconds: 0
      volumes:
      - containerDisk:
          image: kubevirt/cirros-container-disk-demo:latest
        name: containerdisk
      - cloudInitNoCloud:
          userData: |
            #!/bin/sh

            echo 'printed from cloud-init userdata'
        name: cloudinitdisk


=== VM spec ===
$ oc get vm vm-cirros -oyaml

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  annotations:
    kubevirt.io/latest-observed-api-version: v1alpha3
    kubevirt.io/storage-observed-api-version: v1alpha3
  creationTimestamp: "2020-05-06T11:27:36Z"
  generation: 49
  labels:
    kubevirt.io/vm: vm-cirros
  name: vm-cirros
  namespace: default
  resourceVersion: "6312417"
  selfLink: /apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/vm-cirros
  uid: 1b72b78b-4e22-4268-9715-96f0fa84268c
spec:
  runStrategy: Always
  template:
    metadata:
      creationTimestamp: null
      labels:
        kubevirt.io/vm: vm-cirros
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: containerdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
        machine:
          type: q35
        resources:
          requests:
            memory: 64M
      terminationGracePeriodSeconds: 0
      volumes:
      - containerDisk:
          image: kubevirt/cirros-container-disk-demo:latest
        name: containerdisk
      - cloudInitNoCloud:
          userData: |
            #!/bin/sh

            echo 'printed from cloud-init userdata'
        name: cloudinitdisk
status:
  created: true
  ready: true


=== VMI spec ===
$ oc get vmi vm-cirros -oyaml

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachineInstance
metadata:
  annotations:
    kubevirt.io/latest-observed-api-version: v1alpha3
    kubevirt.io/storage-observed-api-version: v1alpha3
  creationTimestamp: "2020-05-12T07:08:14Z"
  finalizers:
  - foregroundDeleteVirtualMachine
  generateName: vm-cirros
  generation: 8
  labels:
    kubevirt.io/nodeName: host-172-16-0-22
    kubevirt.io/vm: vm-cirros
  name: vm-cirros
  namespace: default
  ownerReferences:
  - apiVersion: kubevirt.io/v1alpha3
    blockOwnerDeletion: true
    controller: true
    kind: VirtualMachine
    name: vm-cirros
    uid: 1b72b78b-4e22-4268-9715-96f0fa84268c
  resourceVersion: "6312414"
  selfLink: /apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachineinstances/vm-cirros
  uid: 068eb3f7-c75b-454d-bb86-d35efaeb7531
spec:
  domain:
    devices:
      disks:
      - disk:
          bus: virtio
        name: containerdisk
      - disk:
          bus: virtio
        name: cloudinitdisk
      interfaces:
      - bridge: {}
        name: default
    features:
      acpi:
        enabled: true
    firmware:
      uuid: 0d2a2043-41c0-59c3-9b17-025022203668
    machine:
      type: q35
    resources:
      requests:
        cpu: 100m
        memory: 64M
  networks:
  - name: default
    pod: {}
  terminationGracePeriodSeconds: 0
  volumes:
  - containerDisk:
      image: kubevirt/cirros-container-disk-demo:latest
      imagePullPolicy: Always
    name: containerdisk
  - cloudInitNoCloud:
      userData: |
        #!/bin/sh

        echo 'printed from cloud-init userdata'
    name: cloudinitdisk
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: null
    message: cannot migrate VMI which does not use masquerade to connect to the pod
      network
    reason: InterfaceNotLiveMigratable
    status: "False"
    type: LiveMigratable
  - lastProbeTime: null
    lastTransitionTime: "2020-05-12T07:08:21Z"
    status: "True"
    type: Ready
  guestOSInfo: {}
  interfaces:
  - ipAddress: 10.131.1.79
    mac: 0a:58:0a:83:01:4f
    name: default
  migrationMethod: BlockMigration
  nodeName: host-172-16-0-22
  phase: Running
  qosClass: Burstable

(attached vm and vmi spec when running:true)

--- Additional comment from Ruth Netser on 2020-05-12 07:43:10 UTC ---

Separated the UI issue from https://bugzilla.redhat.com/show_bug.cgi?id=1832179

--- Additional comment from Yaacov Zamir on 2020-05-12 09:39:25 UTC ---

will copy a new bz and target to 4.4 because it happen also in 4.4

notes:
https://github.com/openshift/console/blob/master/frontend/packages/kubevirt-plugin/src/selectors/vm/selectors.ts#L73

Comment 1 Yaacov Zamir 2020-05-12 09:40:42 UTC
target to 4.4 because it happen also in 4.4

Comment 2 Yaacov Zamir 2020-05-12 13:51:49 UTC
submited upstream:
https://github.com/openshift/console/pull/5409

Comment 5 Ruth Netser 2020-05-26 09:32:51 UTC
Tested with 4.4.0-0.nightly-2020-05-25-115719:
Re-opening:
When a VM has runStrategy: Manual and the VM is stopped, status in the UI is "VM error" (see attached screenshot)

Comment 6 Ruth Netser 2020-05-26 09:33:31 UTC
Created attachment 1692192 [details]
Stopped VM with runStrategy: Manual

Comment 7 Ruth Netser 2020-05-26 10:55:11 UTC
To add mote info:
A stopped VM with runStrategy: Manual cannot be started from the UI.
The VM status is either 'Unknown' or 'VM error'

Comment 8 Yaacov Zamir 2020-05-27 11:08:19 UTC
@Filip hi, this is the 4.4 BZ of https://bugzilla.redhat.com/show_bug.cgi?id=1834671

Comment 10 Yaacov Zamir 2020-05-27 15:55:07 UTC
Cause: 
When VM runStrategy unStrategy is set to Manual, it is not a valid information source for VM state, VM can be running or stopped.

Consequence: 
When VM runStrategy unStrategy is set to Manual, the UI wrongly assumes a VM with runStrategy Manual should be running.

Solving this issue in the UI requires changing the logic of VM status calculation, this part of the code was changed between 4.4 and 4.5 and is hard to backport safely.
Closing as wont fix because backporting the fix safely is very hard.

@Tomas FYI