vmware-tanzu / vm-operator

Self-service manage your virtual infrastructure...
Other
106 stars 48 forks source link

🌱 Check image ready condition before mounting ISO #755

Closed dilyar85 closed 1 month ago

dilyar85 commented 1 month ago

What does this PR do, and why is it needed?

This PR updates the CD-ROM reconciliation to verify image's ready condition before retrieving ISO backing files. This prevents mounting unready ISO files to VMs. Also moving this logic into a separate function for better code readability.

Which issue(s) is/are addressed by this PR?

Fixes N/A.

Are there any special notes for your reviewer:

$ go tool cover -func=/tmp/coverage.out | grep pkg/providers/vsphere/virtualmachine/cdrom.go
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:33:           UpdateCdromDeviceChanges            100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:118:          UpdateConfigSpecCdromDeviceConnection       100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:169:          getBackingFileNameByImageRef            100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:219:          processImage                    100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:272:          getCdromByBackingFileName           100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:295:          createNewCdrom                  100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:322:          ensureAllCdromsHaveControllers          100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:357:          addNewAHCIController                100.0%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine/cdrom.go:409:          updateCurCdromsConnectionState          100.0%
# When image condition is not ready
E1017 18:20:14.617078       1 controller.go:316] "Reconciler error" err="updating state failed with update CD-ROM device changes error: error getting backing file name by image ref {VirtualMachineImage vmi-ee3680132b89bcc26}: image condition is not ready: &Condition{Type:Ready,Status:False,ObservedGeneration:0,LastTransitionTime:2024-10-17 16:35:10 +0000 UTC,Reason:True,Message:,}"...

# When image type is not ISO
E1017 18:24:16.557709       1 controller.go:316] "Reconciler error" err="updating state failed with update CD-ROM device changes error: error getting backing file name by image ref {VirtualMachineImage vmi-ee3680132b89bcc26}: image type \"OVF\" is not ISO" ...

Please add a release note if necessary:

Check image ready condition and type before mounting ISO.
github-actions[bot] commented 1 month ago

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 82% βž–
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 85% βž–
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 97% βœ”
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/configmap 86% βž–
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/crd 93% βœ”
github.com/vmware-tanzu/vm-operator/controllers/infra/configmap 71% ❌
github.com/vmware-tanzu/vm-operator/controllers/infra/node 77% ❌
github.com/vmware-tanzu/vm-operator/controllers/infra/secret 77% ❌
github.com/vmware-tanzu/vm-operator/controllers/infra/validatingwebhookconfiguration 85% βž–
github.com/vmware-tanzu/vm-operator/controllers/infra/zone 76% ❌
github.com/vmware-tanzu/vm-operator/controllers/storageclass 94% βœ”
github.com/vmware-tanzu/vm-operator/controllers/storagepolicyquota 97% βœ”
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73% ❌
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/storagepolicyusage 99% βœ”
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/virtualmachine 86% βž–
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volume 87% βž–
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 75% ❌
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 81% βž–
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinereplicaset 67% ❌
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 83% βž–
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 92% βœ”
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 80% βž–
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 72% ❌
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/conditions 88% βž–
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/patch 78% ❌
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha2 73% ❌
github.com/vmware-tanzu/vm-operator/pkg/bitmask 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/builder 95% βœ”
github.com/vmware-tanzu/vm-operator/pkg/conditions 88% βž–
github.com/vmware-tanzu/vm-operator/pkg/config 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/config/capabilities 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/config/env 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/context/generic 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/context/operation 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/patch 78% ❌
github.com/vmware-tanzu/vm-operator/pkg/prober 91% βœ”
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 90% βœ”
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 77% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere 75% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/client 80% βž–
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/clustermodules 71% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/config 89% βœ”
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/contentlibrary 74% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/credentials 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/network 80% βž–
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/placement 79% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/session 71% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/storage 44% ❌
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/sysprep 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vcenter 82% βž–
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine 84% βž–
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vmlifecycle 67% ❌
github.com/vmware-tanzu/vm-operator/pkg/record 78% ❌
github.com/vmware-tanzu/vm-operator/pkg/topology 91% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util 87% βž–
github.com/vmware-tanzu/vm-operator/pkg/util/annotations 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 89% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 91% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/image 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/kube 88% βž–
github.com/vmware-tanzu/vm-operator/pkg/util/kube/cource 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/kube/internal 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/kube/spq 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/paused 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/ptr 100% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/resize 97% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1 92% βœ”
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/client 64% ❌
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 79% ❌
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/watcher 86% βž–
github.com/vmware-tanzu/vm-operator/pkg/vmconfig 95% βœ”
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/crypto 98% βœ”
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 100% βœ”
github.com/vmware-tanzu/vm-operator/services/vm-watcher 91% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/common 100% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/unifiedstoragequota/validation 92% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 87% βž–
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/validation 95% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/mutation 62% ❌
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/validation 89% βž–
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/validation 92% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinereplicaset/validation 90% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/mutation 67% ❌
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/validation 92% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/validation 89% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92% βœ”
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha2/validation 92% βœ”
Summary 83% (10389 / 12504) βž–

Minimum allowed line rate is 79%