Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const getVMStatusGroups: StatusGroupMapper = (
VMStatusSimpleLabel.Migrating,
VMStatusSimpleLabel.Stopping,
StatusSimpleLabel.Pending,
VMStatusSimpleLabel.Deleting,
],
count: 0,
filterType: 'vm-status',
Expand Down
21 changes: 2 additions & 19 deletions frontend/packages/kubevirt-plugin/src/components/vms/vm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import {
dimensifyHeader,
dimensifyRow,
getCreationTimestamp,
getDeletetionTimestamp,
getName,
getNamespace,
getOwnerReferences,
getUID,
getLabels,
} from '@console/shared';
import { compareOwnerReference } from '@console/shared/src/utils/owner-references';
import {
NamespaceModel,
PodModel,
Expand Down Expand Up @@ -46,7 +43,7 @@ import {
VirtualMachineModel,
} from '../../models';
import { VMIKind, VMKind } from '../../types';
import { buildOwnerReferenceForModel, getBasicID, getLoadedData } from '../../utils';
import { getBasicID, getLoadedData } from '../../utils';
import { getVMStatus } from '../../statuses/vm/vm-status';
import { getVmiIpAddresses, getVMINodeName } from '../../selectors/vmi';
import { isVMImport, isVM, isVMI } from '../../selectors/check-type';
Expand Down Expand Up @@ -359,21 +356,7 @@ const VirtualMachinesPage: React.FC<VirtualMachinesPageProps> = (props) => {
...objectBundle,
};
})
.filter(({ vm, vmi, vmImport, metadata }) => {
if (vmImport && metadata.vmImportStatus?.isCompleted()) {
return false;
}

if (vm || !getDeletetionTimestamp(vmi)) {
return true;
}
const vmOwnerReference = buildOwnerReferenceForModel(VirtualMachineModel, getName(vmi));

// show finalizing VMIs only if they are not owned by VM
return !(getOwnerReferences(vmi) || []).some((o) =>
compareOwnerReference(o, vmOwnerReference),
);
});
.filter(({ vmImport, metadata }) => !(vmImport && metadata.vmImportStatus?.isCompleted()));
};

const createAccessReview = skipAccessReview ? null : { model: VirtualMachineModel, namespace };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum VMStatusSimpleLabel {
Stopping = 'Stopping',
Running = 'Running',
Off = 'Off',
Deleting = 'Deleting',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has to be mentioned in getVMStatusGroups

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

export const VM_STATUS_SIMPLE_LABELS = [
Expand Down Expand Up @@ -43,6 +44,9 @@ export class VMStatus extends StatusEnum<VMStatusSimpleLabel | StatusSimpleLabel
static readonly STOPPING = new VMStatus('VMStatus_STOPPING', VMStatusSimpleLabel.Stopping, {
isInProgress: true,
});
static readonly DELETING = new VMStatus('VMStatus_DELETING', VMStatusSimpleLabel.Deleting, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has to be also mentioned in topology/components/nodes/VmNode.tsx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

isInProgress: true,
});
static readonly VM_ERROR = new VMStatus('VMStatus_VM_ERROR', 'VM error', { isError: true });
static readonly VMI_ERROR = new VMStatus('VMStatus_VMI_ERROR', 'VMI error', { isError: true });
static readonly LAUNCHER_POD_ERROR = new VMStatus(
Expand Down
13 changes: 12 additions & 1 deletion frontend/packages/kubevirt-plugin/src/statuses/vm/vm-status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as _ from 'lodash';
import { K8sResourceKind, PersistentVolumeClaimKind, PodKind } from '@console/internal/module/k8s';
import { createBasicLookup } from '@console/shared/src/utils/utils';
import { getName, getNamespace, getOwnerReferences } from '@console/shared/src/selectors/common'; // do not import just from shared - causes cycles
import {
getName,
getNamespace,
getOwnerReferences,
getDeletetionTimestamp,
} from '@console/shared/src/selectors/common'; // do not import just from shared - causes cycles
import { compareOwnerReference } from '@console/shared/src/utils/owner-references';
import {
buildOwnerReference,
Expand Down Expand Up @@ -215,6 +220,11 @@ const isVMError = (vm: VMKind): VMStatusBundle => {
return null;
};

const isDeleting = (vm: VMKind, vmi: VMIKind): VMStatusBundle =>
(vm && !!getDeletetionTimestamp(vm)) || (!vm && vmi && !!getDeletetionTimestamp(vmi))
? { status: VMStatus.DELETING }
: null;

const isBeingStopped = (vm: VMKind): VMStatusBundle => {
if (vm && !isVMExpectedRunning(vm) && isVMCreated(vm)) {
return {
Expand Down Expand Up @@ -310,6 +320,7 @@ export const getVMStatus = ({
isBeingMigrated(vm, vmi, migrations) ||
isBeingImported(vm, pods, pvcs, dataVolumes) ||
isVMError(vm) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should move it behind isVMError

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the bug, users see "vmi-error" while they need to see "deleting"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a vmi error but possible vm error - which should have a prefference IMO, as it could say a reason why something cannot be deleted even though it has deleteionTimestamp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, moved

isDeleting(vm, vmi) ||
isBeingStopped(vm) ||
isOff(vm) ||
isError(vm, vmi, launcherPod) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const ObservedVmNode: React.FC<VmNodeProps> = ({
case VMStatus.STARTING:
statusClass = 'kubevirt-m-not-ready';
break;
case VMStatus.DELETING:
case VMStatus.STOPPING:
statusClass = 'kubevirt-m-terminating';
break;
Expand Down