From 76eee4044963bf2c5769488a4e266f600884d987 Mon Sep 17 00:00:00 2001 From: adikul30 Date: Tue, 9 Apr 2024 13:58:12 -0700 Subject: [PATCH] Update vm-operator spec to v1alpha2 --- go.mod | 2 +- go.sum | 4 +- pkg/csi/service/wcp/controller_helper.go | 2 +- pkg/csi/service/wcpguest/controller.go | 25 +++--- pkg/kubernetes/kubernetes.go | 2 +- .../cnsfileaccessconfig_controller.go | 3 +- .../controller/cnsfileaccessconfig/util.go | 3 +- .../cnsnodevmattachment_controller.go | 2 +- .../csinodetopology_controller.go | 2 +- .../csinodetopology_controller_test.go | 2 +- pkg/syncer/cnsoperator/util/util.go | 27 +++++-- tests/e2e/vmservice_utils.go | 41 +++++++--- tests/e2e/vmservice_vm.go | 81 +++++++++++-------- 13 files changed, 125 insertions(+), 71 deletions(-) diff --git a/go.mod b/go.mod index d58e3b838e..aedfbfa094 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/pkg/sftp v1.13.6 github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.9.0 - github.com/vmware-tanzu/vm-operator/api v1.8.2 + github.com/vmware-tanzu/vm-operator/api v1.8.5 github.com/vmware/govmomi v0.36.1 go.uber.org/zap v1.26.0 golang.org/x/crypto v0.18.0 diff --git a/go.sum b/go.sum index 00945f8f8d..4c737f0a75 100644 --- a/go.sum +++ b/go.sum @@ -1296,8 +1296,8 @@ github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYp github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.2 h1:Cn05BRLm+iRP/DZxyVSsfVyrzgjDbwHwkVt38qvXnNI= github.com/vishvananda/netns v0.0.2/go.mod h1:yitZXdAVI+yPFSb4QUe+VW3vOVl4PZPNcBgbPxAtJxw= -github.com/vmware-tanzu/vm-operator/api v1.8.2 h1:7cZHVusqAmAMFWvsiU7X5xontxdjasknI/sVfe0p0Z4= -github.com/vmware-tanzu/vm-operator/api v1.8.2/go.mod h1:vauVboD3sQxP+pb28TnI9wfrj+0nH2zSEc9Q7AzWJ54= +github.com/vmware-tanzu/vm-operator/api v1.8.5 h1:E8rpRdV8+cNp/eNZ/QUHvlrbpPh8uk6bKqwEEmGWe64= +github.com/vmware-tanzu/vm-operator/api v1.8.5/go.mod h1:SXaSFtnw2502Tzy0bfQVHrvbFDijR96r1ihUYQWPOK8= github.com/vmware/govmomi v0.36.1 h1:+E/nlfteQ8JvC0xhuKAfpnMsuIeGeGj7rJwqENUcWm8= github.com/vmware/govmomi v0.36.1/go.mod h1:mtGWtM+YhTADHlCgJBiskSRPOZRsN9MSjPzaZLte/oQ= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/pkg/csi/service/wcp/controller_helper.go b/pkg/csi/service/wcp/controller_helper.go index b69209537a..cdfd9c6e8d 100644 --- a/pkg/csi/service/wcp/controller_helper.go +++ b/pkg/csi/service/wcp/controller_helper.go @@ -24,7 +24,7 @@ import ( "strings" "github.com/container-storage-interface/spec/lib/go/csi" - vmoperatorv1alpha1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatorv1alpha1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/property" "github.com/vmware/govmomi/vim25/mo" diff --git a/pkg/csi/service/wcpguest/controller.go b/pkg/csi/service/wcpguest/controller.go index e8280c8da0..1c4aacfeda 100644 --- a/pkg/csi/service/wcpguest/controller.go +++ b/pkg/csi/service/wcpguest/controller.go @@ -30,7 +30,7 @@ import ( "github.com/fsnotify/fsnotify" snapshotterClientSet "github.com/kubernetes-csi/external-snapshotter/client/v6/clientset/versioned" "github.com/prometheus/client_golang/prometheus/promhttp" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" @@ -630,11 +630,12 @@ func controllerPublishForBlockVolume(ctx context.Context, req *csi.ControllerPub // volume in the spec and patching virtualMachine instance. vmvolumes := vmoperatortypes.VirtualMachineVolume{ Name: req.VolumeId, - PersistentVolumeClaim: &vmoperatortypes.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: corev1.PersistentVolumeClaimVolumeSource{ - ClaimName: req.VolumeId, - }, - }, + VirtualMachineVolumeSource: vmoperatortypes.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmoperatortypes.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: req.VolumeId, + }, + }}, } virtualMachine.Spec.Volumes = append(virtualMachine.Spec.Volumes, vmvolumes) @@ -653,11 +654,11 @@ func controllerPublishForBlockVolume(ctx context.Context, req *csi.ControllerPub } for _, volume := range virtualMachine.Status.Volumes { - if volume.Name == req.VolumeId && volume.Attached && volume.DiskUuid != "" { - diskUUID = volume.DiskUuid + if volume.Name == req.VolumeId && volume.Attached && volume.DiskUUID != "" { + diskUUID = volume.DiskUUID isVolumeAttached = true log.Infof("Volume %q is already attached in the virtualMachine.Spec.Volumes. Disk UUID: %q", - volume.Name, volume.DiskUuid) + volume.Name, volume.DiskUUID) break } } @@ -695,10 +696,10 @@ func controllerPublishForBlockVolume(ctx context.Context, req *csi.ControllerPub virtualMachine.Name, req.VolumeId) for _, volume := range vm.Status.Volumes { if volume.Name == req.VolumeId { - if volume.Attached && volume.DiskUuid != "" && volume.Error == "" { - diskUUID = volume.DiskUuid + if volume.Attached && volume.DiskUUID != "" && volume.Error == "" { + diskUUID = volume.DiskUUID log.Infof("observed disk UUID %q is set for the volume %q on virtualmachine %q", - volume.DiskUuid, volume.Name, vm.Name) + volume.DiskUUID, volume.Name, vm.Name) } else { if volume.Error != "" { msg := fmt.Sprintf("observed Error: %q is set on the volume %q on virtualmachine %q", diff --git a/pkg/kubernetes/kubernetes.go b/pkg/kubernetes/kubernetes.go index d5019e19a7..d8d3cbfb4d 100644 --- a/pkg/kubernetes/kubernetes.go +++ b/pkg/kubernetes/kubernetes.go @@ -25,7 +25,7 @@ import ( "strconv" "time" - vmoperatorv1alpha1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatorv1alpha1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2" v1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" diff --git a/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/cnsfileaccessconfig_controller.go b/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/cnsfileaccessconfig_controller.go index 280db886f5..8beccb717f 100644 --- a/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/cnsfileaccessconfig_controller.go +++ b/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/cnsfileaccessconfig_controller.go @@ -23,7 +23,7 @@ import ( "sync" "time" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" cnstypes "github.com/vmware/govmomi/cns/types" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -41,6 +41,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/source" vsanfstypes "github.com/vmware/govmomi/vsan/vsanfs/types" + cnsoperatorapis "sigs.k8s.io/vsphere-csi-driver/v3/pkg/apis/cnsoperator" cnsfileaccessconfigv1alpha1 "sigs.k8s.io/vsphere-csi-driver/v3/pkg/apis/cnsoperator/cnsfileaccessconfig/v1alpha1" volumes "sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/cns-lib/volume" diff --git a/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/util.go b/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/util.go index 643d3bb857..d48e325ad1 100644 --- a/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/util.go +++ b/pkg/syncer/cnsoperator/controller/cnsfileaccessconfig/util.go @@ -23,11 +23,12 @@ import ( "reflect" "strconv" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apitypes "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + cnsfileaccessconfigv1alpha1 "sigs.k8s.io/vsphere-csi-driver/v3/pkg/apis/cnsoperator/cnsfileaccessconfig/v1alpha1" "sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service/logger" ) diff --git a/pkg/syncer/cnsoperator/controller/cnsnodevmattachment/cnsnodevmattachment_controller.go b/pkg/syncer/cnsoperator/controller/cnsnodevmattachment/cnsnodevmattachment_controller.go index 08c66a97f8..d3bfec2f90 100644 --- a/pkg/syncer/cnsoperator/controller/cnsnodevmattachment/cnsnodevmattachment_controller.go +++ b/pkg/syncer/cnsoperator/controller/cnsnodevmattachment/cnsnodevmattachment_controller.go @@ -26,7 +26,7 @@ import ( "sync" "time" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" cnstypes "github.com/vmware/govmomi/cns/types" "github.com/vmware/govmomi/object" vimtypes "github.com/vmware/govmomi/vim25/types" diff --git a/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller.go b/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller.go index 189091e6cc..abdce6efbd 100644 --- a/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller.go +++ b/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller.go @@ -23,7 +23,7 @@ import ( "sync" "time" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" cnstypes "github.com/vmware/govmomi/cns/types" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller_test.go b/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller_test.go index 62f0a36a1b..f41fa88869 100644 --- a/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller_test.go +++ b/pkg/syncer/cnsoperator/controller/csinodetopology/csinodetopology_controller_test.go @@ -23,7 +23,7 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/assert" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/syncer/cnsoperator/util/util.go b/pkg/syncer/cnsoperator/util/util.go index 117f175b3b..8c4f106c74 100644 --- a/pkg/syncer/cnsoperator/util/util.go +++ b/pkg/syncer/cnsoperator/util/util.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmoperatortypes "github.com/vmware-tanzu/vm-operator/api/v1alpha2" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -98,11 +98,23 @@ func GetTKGVMIP(ctx context.Context, vmOperatorClient client.Client, dc dynamic. } var networkName string - for _, networkInterface := range virtualMachineInstance.Spec.NetworkInterfaces { + + // NSX + // network: + // interfaces: + // - name: eth0 + // network: + // apiVersion: vmware.com/v1alpha1 + // kind: VirtualNetwork + // name: <> + // virtualnetwork object: network.interfaces.network.name <> in the above spec + // networkinterfaces object: vm-medium-1-ltw8-vnet + + for _, networkInterface := range virtualMachineInstance.Spec.Network.Interfaces { // The assumption is that a TKG VM will have only a single network interface. // This logic needs to be revisited when multiple network interface support // is added. - networkName = networkInterface.NetworkName + networkName = networkInterface.Network.Name } log.Debugf("VirtualMachine %s/%s is configured with network %s", vmNamespace, vmName, networkName) @@ -121,9 +133,14 @@ func GetTKGVMIP(ctx context.Context, vmOperatorClient client.Client, dc dynamic. return "", fmt.Errorf("failed to get SNAT IP annotation from VirtualMachine %s/%s", vmNamespace, vmName) } } else { - ip = virtualMachineInstance.Status.VmIp + networkStatus := virtualMachineInstance.Status.Network + if networkStatus == nil { + return "", fmt.Errorf("vm.Status.Network is not populated for %s/%s", vmNamespace, vmName) + } + + ip = networkStatus.PrimaryIP4 if ip == "" { - return "", fmt.Errorf("vm.Status.VmIp is not populated for %s/%s", vmNamespace, vmName) + return "", fmt.Errorf("vm.Status.Network.PrimaryIP4 is not populated for %s/%s", vmNamespace, vmName) } } log.Infof("Found external IP Address %s for VirtualMachine %s/%s", ip, vmNamespace, vmName) diff --git a/tests/e2e/vmservice_utils.go b/tests/e2e/vmservice_utils.go index 8427b9b6ca..e69ba5ce65 100644 --- a/tests/e2e/vmservice_utils.go +++ b/tests/e2e/vmservice_utils.go @@ -32,9 +32,10 @@ import ( "github.com/onsi/gomega" "github.com/pkg/sftp" + "github.com/vmware-tanzu/vm-operator/api/v1alpha2/common" "golang.org/x/crypto/ssh" - vmopv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmopv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,6 +44,7 @@ import ( "k8s.io/kubernetes/test/e2e/framework" fssh "k8s.io/kubernetes/test/e2e/framework/ssh" ctlrclient "sigs.k8s.io/controller-runtime/pkg/client" + cnsnodevmattachmentv1alpha1 "sigs.k8s.io/vsphere-csi-driver/v3/pkg/apis/cnsoperator/cnsnodevmattachment/v1alpha1" ) @@ -256,7 +258,7 @@ func waitNGetVmiForImageName(ctx context.Context, c ctlrclient.Client, namespace err := c.List(ctx, vmImagesList) gomega.Expect(err).NotTo(gomega.HaveOccurred()) for _, instance := range vmImagesList.Items { - if instance.Status.ImageName == imageName { + if instance.Status.Name == imageName { framework.Logf("Found vmi %v for image name %v", instance.Name, imageName) vmi = instance.Name return true, nil @@ -278,20 +280,27 @@ func createVmServiceVmWithPvcs(ctx context.Context, c ctlrclient.Client, namespa for _, pvc := range pvcs { vols = append(vols, vmopv1.VirtualMachineVolume{ Name: pvc.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + }, }, }) } vm := vmopv1.VirtualMachine{ ObjectMeta: metav1.ObjectMeta{Name: vmName, Namespace: namespace}, Spec: vmopv1.VirtualMachineSpec{ - PowerState: vmopv1.VirtualMachinePoweredOn, + PowerState: vmopv1.VirtualMachinePowerStateOn, ImageName: vmi, ClassName: vmClass, StorageClass: storageClassName, Volumes: vols, - VmMetadata: &vmopv1.VirtualMachineMetadata{Transport: "CloudInit", SecretName: secretName}, + Bootstrap: &vmopv1.VirtualMachineBootstrapSpec{CloudInit: &vmopv1.VirtualMachineBootstrapCloudInitSpec{ + RawCloudConfig: &common.SecretKeySelector{ + Name: secretName, + Key: "user-data", + }, + }}, }, } err := c.Create(ctx, &vm) @@ -341,10 +350,11 @@ func waitNgetVmsvcVmIp(ctx context.Context, c ctlrclient.Client, namespace strin } return false, nil } - if vm.Status.VmIp == "" { + networkStatus := vm.Status.Network + if networkStatus == nil || networkStatus.PrimaryIP4 == "" { return false, nil } - ip = vm.Status.VmIp + ip = networkStatus.PrimaryIP4 return true, nil }) framework.Logf("Found IP '%s' for VM '%s'", ip, name) @@ -746,8 +756,10 @@ func createVmServiceVmWithPvcsWithZone(ctx context.Context, c ctlrclient.Client, for _, pvc := range pvcs { vols = append(vols, vmopv1.VirtualMachineVolume{ Name: pvc.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + }, }, }) } @@ -756,12 +768,17 @@ func createVmServiceVmWithPvcsWithZone(ctx context.Context, c ctlrclient.Client, vm := vmopv1.VirtualMachine{ ObjectMeta: metav1.ObjectMeta{Name: vmName, Namespace: namespace, Labels: labels}, Spec: vmopv1.VirtualMachineSpec{ - PowerState: vmopv1.VirtualMachinePoweredOn, + PowerState: vmopv1.VirtualMachinePowerStateOn, ImageName: vmi, ClassName: vmClass, StorageClass: storageClassName, Volumes: vols, - VmMetadata: &vmopv1.VirtualMachineMetadata{Transport: "CloudInit", SecretName: secretName}, + Bootstrap: &vmopv1.VirtualMachineBootstrapSpec{CloudInit: &vmopv1.VirtualMachineBootstrapCloudInitSpec{ + RawCloudConfig: &common.SecretKeySelector{ + Name: secretName, + Key: "user-data", + }, + }}, }, } err := c.Create(ctx, &vm) diff --git a/tests/e2e/vmservice_vm.go b/tests/e2e/vmservice_vm.go index 8e7fdc9c53..ba7e420183 100644 --- a/tests/e2e/vmservice_vm.go +++ b/tests/e2e/vmservice_vm.go @@ -29,7 +29,7 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" - vmopv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1" + vmopv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -268,7 +268,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) for i, vol := range vm.Status.Volumes { - volFolder := formatNVerifyPvcIsAccessible(vol.DiskUuid, i+1, vmIp) + volFolder := formatNVerifyPvcIsAccessible(vol.DiskUUID, i+1, vmIp) verifyDataIntegrityOnVmDisk(vmIp, volFolder) } }) @@ -368,7 +368,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify PVC is accessible to the VM2") vm2, err = getVmsvcVM(ctx, vmopC, vm2.Namespace, vm2.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - volFolder := formatNVerifyPvcIsAccessible(vm2.Status.Volumes[0].DiskUuid, 1, vmIp2) + volFolder := formatNVerifyPvcIsAccessible(vm2.Status.Volumes[0].DiskUUID, 1, vmIp2) ginkgo.By("write some data to a file in pvc2 from vm2") rand.New(rand.NewSource(time.Now().Unix())) @@ -422,7 +422,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("verify data in pvc2 from vm1") framework.Logf("Mounting the volume") - volFolder = mountFormattedVol2Vm(vm1.Status.Volumes[0].DiskUuid, 1, vmIp1) + volFolder = mountFormattedVol2Vm(vm1.Status.Volumes[0].DiskUUID, 1, vmIp1) vmFileData := fmt.Sprintf("/tmp/vmdata_%v_%v", time.Now().Unix(), rand.Intn(1000)) _ = execSshOnVmThroughGatewayVm(vmIp1, []string{"md5sum " + volFolder + "/f1"}) framework.Logf("Fetching file from the VM") @@ -566,16 +566,19 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify PVCs are accessible to respective VMs") vm1, err = getVmsvcVM(ctx, vmopC, vm1.Namespace, vm1.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm1.Status.Volumes[0].DiskUuid, 1, vmIp1) + _ = formatNVerifyPvcIsAccessible(vm1.Status.Volumes[0].DiskUUID, 1, vmIp1) vm2, err = getVmsvcVM(ctx, vmopC, vm2.Namespace, vm2.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm2.Status.Volumes[0].DiskUuid, 1, vmIp2) + _ = formatNVerifyPvcIsAccessible(vm2.Status.Volumes[0].DiskUUID, 1, vmIp2) ginkgo.By("edit vm1 spec and try to attach pvc2 to vm1, which should fail") vm1.Spec.Volumes = append(vm1.Spec.Volumes, vmopv1.VirtualMachineVolume{Name: pvc2.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc2.Name}, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc2.Name}, + }, }}) + err = vmopC.Update(ctx, vm1) gomega.Expect(err).NotTo(gomega.HaveOccurred()) err = wait4PvcAttachmentFailure(ctx, vmopC, vm1, pvc2) @@ -591,7 +594,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { gomega.Expect(err).NotTo(gomega.HaveOccurred()) ginkgo.By("Power off vm2") - vm2 = setVmPowerState(ctx, vmopC, vm2, vmopv1.VirtualMachinePoweredOff) + vm2 = setVmPowerState(ctx, vmopC, vm2, vmopv1.VirtualMachinePowerStateOff) vm2, err = wait4Vm2ReachPowerStateInSpec(ctx, vmopC, vm2) gomega.Expect(err).NotTo(gomega.HaveOccurred()) @@ -599,8 +602,10 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { vm1, err = getVmsvcVM(ctx, vmopC, vm1.Namespace, vm1.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) vm1.Spec.Volumes = append(vm1.Spec.Volumes, vmopv1.VirtualMachineVolume{Name: pvc2.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc2.Name}, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc2.Name}, + }, }}) err = vmopC.Update(ctx, vm1) gomega.Expect(err).NotTo(gomega.HaveOccurred()) @@ -621,8 +626,10 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { vm2, err = getVmsvcVM(ctx, vmopC, vm2.Namespace, vm2.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) vm2.Spec.Volumes = append(vm2.Spec.Volumes, vmopv1.VirtualMachineVolume{Name: pvc1.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc1.Name}, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc1.Name}, + }, }}) err = vmopC.Update(ctx, vm2) gomega.Expect(err).NotTo(gomega.HaveOccurred()) @@ -640,7 +647,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { gomega.Expect(err).NotTo(gomega.HaveOccurred()) ginkgo.By("Power on vm2") - vm2 = setVmPowerState(ctx, vmopC, vm2, vmopv1.VirtualMachinePoweredOn) + vm2 = setVmPowerState(ctx, vmopC, vm2, vmopv1.VirtualMachinePowerStateOn) vm2, err = wait4Vm2ReachPowerStateInSpec(ctx, vmopC, vm2) gomega.Expect(err).NotTo(gomega.HaveOccurred()) _, err = waitNgetVmsvcVmIp(ctx, vmopC, namespace, vm2.Name) @@ -755,7 +762,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) for i, vol := range vm.Status.Volumes { - _ = formatNVerifyPvcIsAccessible(vol.DiskUuid, i+1, vmIp) + _ = formatNVerifyPvcIsAccessible(vol.DiskUUID, i+1, vmIp) } }) @@ -866,7 +873,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("verify that vm1 does not come up") vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - gomega.Expect(vm.Status.PowerState).To(gomega.Equal(vmopv1.VirtualMachinePoweredOff)) + gomega.Expect(vm.Status.PowerState).To(gomega.Equal(vmopv1.VirtualMachinePowerStateOff)) ginkgo.By("remove pvc1 from vm1 spec") vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info @@ -884,8 +891,10 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { gomega.Expect(err).NotTo(gomega.HaveOccurred()) vm.Spec.Volumes = []vmopv1.VirtualMachineVolume{{ Name: pvc.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + }, }}} err = vmopC.Update(ctx, vm) gomega.Expect(err).NotTo(gomega.HaveOccurred()) @@ -980,9 +989,13 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) vm.Spec.Volumes = []vmopv1.VirtualMachineVolume{{Name: pvc.Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, - }}} + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name}, + }, + }, + }} + err = vmopC.Update(ctx, vm) gomega.Expect(err).NotTo(gomega.HaveOccurred()) err = wait4PvcAttachmentFailure(ctx, vmopC, vm, pvc) @@ -998,7 +1011,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify PVCs are accessible to the VM") vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm.Status.Volumes[0].DiskUuid, 1, vmIp) + _ = formatNVerifyPvcIsAccessible(vm.Status.Volumes[0].DiskUUID, 1, vmIp) }) /* @@ -1134,7 +1147,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify pvc3 is accessible to VM3") vm3, err = getVmsvcVM(ctx, vmopC, vm3.Namespace, vm3.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm3.Status.Volumes[0].DiskUuid, 1, vmIp3) + _ = formatNVerifyPvcIsAccessible(vm3.Status.Volumes[0].DiskUUID, 1, vmIp3) ginkgo.By(fmt.Sprintf("Stopping %v on the vCenter host", vsanhealthServiceName)) isVsanHealthServiceStopped = true @@ -1158,10 +1171,14 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Attach pvc2 to vm2") vm2, err = getVmsvcVM(ctx, vmopC, vm2.Namespace, vm2.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - vm2.Spec.Volumes = append(vm2.Spec.Volumes, vmopv1.VirtualMachineVolume{Name: pvcs[1].Name, - PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ - PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvcs[1].Name}, - }}) + vm2.Spec.Volumes = append(vm2.Spec.Volumes, vmopv1.VirtualMachineVolume{ + Name: pvcs[1].Name, + VirtualMachineVolumeSource: vmopv1.VirtualMachineVolumeSource{ + PersistentVolumeClaim: &vmopv1.PersistentVolumeClaimVolumeSource{ + PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{ClaimName: pvcs[1].Name}, + }, + }, + }) err = vmopC.Update(ctx, vm2) gomega.Expect(err).NotTo(gomega.HaveOccurred()) @@ -1182,7 +1199,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { err = wait4PvcAttachmentFailure(ctx, vmopC, vm1, pvcs[0]) framework.Logf("Error found: %s", err.Error()) gomega.Expect(err).To(gomega.HaveOccurred()) - gomega.Expect(vm1.Status.PowerState).To(gomega.Equal(vmopv1.VirtualMachinePoweredOff)) + gomega.Expect(vm1.Status.PowerState).To(gomega.Equal(vmopv1.VirtualMachinePowerStateOff)) ginkgo.By("Verifying pvc2 attachment to vm2 failed") err = wait4PvcAttachmentFailure(ctx, vmopC, vm2, pvcs[1]) @@ -1210,7 +1227,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify pvc1 is accessible to VM1") vm1, err = getVmsvcVM(ctx, vmopC, vm1.Namespace, vm1.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm1.Status.Volumes[0].DiskUuid, 1, vmIp1) + _ = formatNVerifyPvcIsAccessible(vm1.Status.Volumes[0].DiskUUID, 1, vmIp1) ginkgo.By("Verify pvc2 is attached to VM2") vm2, err = getVmsvcVM(ctx, vmopC, vm1.Namespace, vm2.Name) // refresh vm info @@ -1220,7 +1237,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify pvc2 is accessible to VM2") vm2, err = getVmsvcVM(ctx, vmopC, vm2.Namespace, vm2.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm2.Status.Volumes[0].DiskUuid, 1, vmIp2) + _ = formatNVerifyPvcIsAccessible(vm2.Status.Volumes[0].DiskUUID, 1, vmIp2) ginkgo.By("Verify pvc3 is detached from VM3") wait4Pvc2Detach(ctx, vmopC, vm3, pvcs[2]) @@ -1305,7 +1322,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { time.Sleep(time.Minute) vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - gomega.Expect(vm.Status.PowerState).NotTo(gomega.Equal(vmopv1.VirtualMachinePoweredOn)) + gomega.Expect(vm.Status.PowerState).NotTo(gomega.Equal(vmopv1.VirtualMachinePowerStateOn)) ginkgo.By(fmt.Sprintf("Starting %v on the vCenter host", spsServiceName)) startVCServiceWait4VPs(ctx, vcAddress, spsServiceName, &isSPSserviceStopped) @@ -1332,7 +1349,7 @@ var _ bool = ginkgo.Describe("[vmsvc] vm service with csi vol tests", func() { ginkgo.By("Verify pvc1 is accessible to VM1") vm, err = getVmsvcVM(ctx, vmopC, vm.Namespace, vm.Name) // refresh vm info gomega.Expect(err).NotTo(gomega.HaveOccurred()) - _ = formatNVerifyPvcIsAccessible(vm.Status.Volumes[0].DiskUuid, 1, vmIp) + _ = formatNVerifyPvcIsAccessible(vm.Status.Volumes[0].DiskUUID, 1, vmIp) }) })