feat: improve clone status (#928)

* feat: improve clone status

Signed-off-by: pohanhuang <pohan.huang@suse.com>

* fix: pr comments

Signed-off-by: pohanhuang <pohan.huang@suse.com>

---------

Signed-off-by: pohanhuang <pohan.huang@suse.com>
This commit is contained in:
Po Han Huang 2026-06-17 11:10:43 +08:00 committed by GitHub
parent 5985913f5e
commit f115261889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -123,7 +123,12 @@ const IgnoreMessages = ['pod has unbound immediate PersistentVolumeClaims'];
export default class VirtVm extends HarvesterResource { export default class VirtVm extends HarvesterResource {
get availableActions() { get availableActions() {
const out = super._availableActions; let out = super._availableActions;
if (this.isCloneBackendStorageCloning || this.isCloneBackendStorageFailed) {
out = out.filter(({ action }) => action !== 'goToClone');
}
const clone = out.find((action) => action.action === 'goToClone'); const clone = out.find((action) => action.action === 'goToClone');
if (clone) { if (clone) {
@ -770,6 +775,18 @@ export default class VirtVm extends HarvesterResource {
return this.volumes.filter((volume) => volume?.isLonghornV2); return this.volumes.filter((volume) => volume?.isLonghornV2);
} }
get cloneBackendStorageStatus() {
return this.metadata?.annotations?.[HCI_ANNOTATIONS.CLONE_BACKEND_STORAGE_STATUS]?.toLowerCase() || '';
}
get isCloneBackendStorageCloning() {
return this.cloneBackendStorageStatus === 'cloning';
}
get isCloneBackendStorageFailed() {
return this.cloneBackendStorageStatus === 'failed';
}
get encryptedVolumeType() { get encryptedVolumeType() {
if (!this.volumes || this.volumes.length === 0) { if (!this.volumes || this.volumes.length === 0) {
return 'none'; return 'none';
@ -825,13 +842,21 @@ export default class VirtVm extends HarvesterResource {
!this.isVMExpectedRunning && !this.isVMExpectedRunning &&
this.isVMCreated && this.isVMCreated &&
this.vmi?.status?.phase === VMIPhase.Pending this.vmi?.status?.phase === VMIPhase.Pending
) || (this.metadata?.annotations?.[HCI_ANNOTATIONS.CLONE_BACKEND_STORAGE_STATUS] === 'cloning')) { ) || this.isCloneBackendStorageCloning) {
return { status: VMIPhase.Pending }; return { status: VMIPhase.Pending };
} }
return null; return null;
} }
get isCloneFailed() {
if (this.isCloneBackendStorageFailed) {
return { status: VMIPhase.Failed };
}
return null;
}
get isStopping() { get isStopping() {
if (this && if (this &&
!this.isVMExpectedRunning && !this.isVMExpectedRunning &&
@ -988,6 +1013,7 @@ export default class VirtVm extends HarvesterResource {
this.isUnschedulable?.status || this.isUnschedulable?.status ||
this.isPaused?.status || this.isPaused?.status ||
this.isVMError?.status || this.isVMError?.status ||
this.isCloneFailed?.status ||
this.isPending?.status || this.isPending?.status ||
this.isStopping?.status || this.isStopping?.status ||
this.isOff?.status || this.isOff?.status ||
@ -995,7 +1021,7 @@ export default class VirtVm extends HarvesterResource {
this.isRunning?.status || this.isRunning?.status ||
this.isNotReady?.status || this.isNotReady?.status ||
this.isStarting?.status || this.isStarting?.status ||
this.isWaitingForVMI?.state || this.isWaitingForVMI?.status ||
this.otherState?.status; this.otherState?.status;
return state; return state;