Skip to content

Commit

Permalink
vm-operator: migrate to v1alpha2
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Jun 4, 2024
1 parent 6e8e237 commit 6fff075
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ linters-settings:
- pkg: sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1
alias: vmwarev1
# VMware Operator
- pkg: "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
- pkg: "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
alias: vmoprv1
# CABPK
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
Expand Down
16 changes: 10 additions & 6 deletions controllers/vmware/test/controllers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
vmoprconditions "github.com/vmware-tanzu/vm-operator/pkg/conditions"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -463,7 +464,7 @@ var _ = Describe("Reconciliation tests", func() {
Eventually(func() error {
return k8sClient.Get(ctx, rpKey, resourcePolicy)
}, time.Second*30).Should(Succeed())
Expect(len(resourcePolicy.Spec.ClusterModules)).To(BeEquivalentTo(2))
Expect(len(resourcePolicy.Spec.ClusterModuleGroups)).To(BeEquivalentTo(2))

By("Create the CAPI Machine and wait for it to exist")
machineKey, machine := deployCAPIMachine(ns.Name, cluster, k8sClient)
Expand Down Expand Up @@ -636,7 +637,7 @@ var _ = Describe("Reconciliation tests", func() {
}
// These two lines must be initialized as requirements of having valid Status
newVM.Status.Volumes = []vmoprv1.VirtualMachineVolumeStatus{}
newVM.Status.Phase = vmoprv1.Created
vmoprconditions.MarkTrue(newVM, vmoprv1.VirtualMachineConditionCreated)
return k8sClient.Status().Update(ctx, newVM)
}, time.Second*30).Should(Succeed())

Expand All @@ -649,7 +650,7 @@ var _ = Describe("Reconciliation tests", func() {
if err != nil {
return err
}
newVM.Status.PowerState = vmoprv1.VirtualMachinePoweredOn
newVM.Status.PowerState = vmoprv1.VirtualMachinePowerStateOn
return k8sClient.Status().Update(ctx, newVM)
}, time.Second*30).Should(Succeed())

Expand All @@ -662,7 +663,10 @@ var _ = Describe("Reconciliation tests", func() {
if err != nil {
return err
}
newVM.Status.VmIp = "1.2.3.4"
if newVM.Status.Network == nil {
newVM.Status.Network = &vmoprv1.VirtualMachineNetworkStatus{}
}
newVM.Status.Network.PrimaryIP4 = "1.2.3.4"
newVM.Status.BiosUUID = "test-bios-uuid"
return k8sClient.Status().Update(ctx, newVM)
}, time.Second*30).Should(Succeed())
Expand All @@ -675,7 +679,7 @@ var _ = Describe("Reconciliation tests", func() {
// control_plane_endpoint_test.go
if !isLB {
By("Expect the Cluster to have the IP from the VM as an APIEndpoint")
assertEventuallyControlPlaneEndpoint(infraClusterKey, infraCluster, newVM.Status.VmIp)
assertEventuallyControlPlaneEndpoint(infraClusterKey, infraCluster, newVM.Status.Network.PrimaryIP4)
}
},
Entry("With no load balancer", dontUseLoadBalancer),
Expand Down
2 changes: 1 addition & 1 deletion controllers/vspheremachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"time"

"github.com/pkg/errors"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/vmware-tanzu/net-operator-api v0.0.0-20240326163340-1f32d6bf7f9d
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.1.0
github.com/vmware-tanzu/vm-operator v1.8.6
github.com/vmware-tanzu/vm-operator/api v1.8.6
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505
github.com/vmware-tanzu/vm-operator/external/tanzu-topology v0.0.0-20240404200847-de75746a9505
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,14 @@ github.com/vmware-tanzu/net-operator-api v0.0.0-20240326163340-1f32d6bf7f9d h1:c
github.com/vmware-tanzu/net-operator-api v0.0.0-20240326163340-1f32d6bf7f9d/go.mod h1:JbFOh22iDsT5BowJe0GgpMI5e2/S7cWaJlv9LdURVQM=
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.1.0 h1:HdnQb/X9vJ8a5WQ03g/0nDr9igIIK1fF6wO5wOtkJT4=
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.1.0/go.mod h1:Q4JzNkNMvjo7pXtlB5/R3oME4Nhah7fAObWgghVmtxk=
github.com/vmware-tanzu/vm-operator v1.8.6 h1:ZfPQjQWVvwcH5WQ4lCEMBhYHM48cHBhrmyNpEdJeN14=
github.com/vmware-tanzu/vm-operator v1.8.6/go.mod h1:KgriSV1zMLaJf6LVTO4Eu+9yLgBmukjuGEud2rJct7E=
github.com/vmware-tanzu/vm-operator/api v1.8.6 h1:NIndORjcnSmIlQsCMIewpIwg/ocRVDh2lYjOroTVLrU=
github.com/vmware-tanzu/vm-operator/api v1.8.6/go.mod h1:HHA2SNI9B5Yqtyp5t+Gt9WTWBi/fIkM6+MukDDSf11A=
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505 h1:y4wXx1FUFqqSgJ/xUOEM1DLS2Uu0KaeLADWpzpioGTU=
github.com/vmware-tanzu/vm-operator/external/ncp v0.0.0-20240404200847-de75746a9505/go.mod h1:5rqRJ9zGR+KnKbkGx373WgN8xJpvAj99kHnfoDYRO5I=
github.com/vmware-tanzu/vm-operator/external/tanzu-topology v0.0.0-20240404200847-de75746a9505 h1:/6vFL20UMHOeTf/mb+dKf5sFG0FBbyrCBY/71QKAIE0=
github.com/vmware-tanzu/vm-operator/external/tanzu-topology v0.0.0-20240404200847-de75746a9505/go.mod h1:dfYrWS8DMRN+XZfhu8M4LVHmeGvYB29Ipd7j4uIq+mU=
github.com/vmware-tanzu/vm-operator/pkg/constants/testlabels v0.0.0-20240404200847-de75746a9505 h1:LRMZ+zzb944d6r+uYsE+CuJ3zVBE6Hc8vjH7IJX2QY4=
github.com/vmware-tanzu/vm-operator/pkg/constants/testlabels v0.0.0-20240404200847-de75746a9505/go.mod h1:M+6bZCS8vSjCN9OOppnAyYxeBxY1U0wG6+j3CvIrOHY=
github.com/vmware/govmomi v0.37.2 h1:5ANLoaTxWv600ZnoosJ2zXbM3A+EaxqGheEZbRN8YVE=
github.com/vmware/govmomi v0.37.2/go.mod h1:mtGWtM+YhTADHlCgJBiskSRPOZRsN9MSjPzaZLte/oQ=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
Expand Down
2 changes: 1 addition & 1 deletion internal/test/helpers/vmware/unit_test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/fake/fake_controller_manager_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package fake

import (
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/pkg/errors"
netopv1 "github.com/vmware-tanzu/net-operator-api/api/v1alpha1"
nsxopv1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
ncpv1 "github.com/vmware-tanzu/vm-operator/external/ncp/api/v1alpha1"
topologyv1 "github.com/vmware-tanzu/vm-operator/external/tanzu-topology/api/v1alpha1"
"gopkg.in/fsnotify.v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package services
import (
"context"

vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/network/dummy_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package network
import (
"context"

vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
"k8s.io/apimachinery/pkg/runtime"

"sigs.k8s.io/cluster-api-provider-vsphere/pkg/context/vmware"
Expand Down
23 changes: 17 additions & 6 deletions pkg/services/network/netop_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"fmt"

netopv1 "github.com/vmware-tanzu/net-operator-api/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
vmoprv1common "github.com/vmware-tanzu/vm-operator/api/v1alpha2/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/cluster-api/util/conditions"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -122,16 +124,25 @@ func (np *netopNetworkProvider) ConfigureVirtualMachine(ctx context.Context, clu
return err
}

for _, vnif := range vm.Spec.NetworkInterfaces {
if vnif.NetworkType == string(network.Spec.Type) && vnif.NetworkName == network.Name {
if vm.Spec.Network == nil {
vm.Spec.Network = &vmoprv1.VirtualMachineNetworkSpec{}
}
for _, vnif := range vm.Spec.Network.Interfaces {
if vnif.Network.TypeMeta.GroupVersionKind() == netopv1.SchemeGroupVersion.WithKind("Network") && vnif.Network.Name == network.Name {
// Expected network interface already exists.
return nil
}
}

vm.Spec.NetworkInterfaces = append(vm.Spec.NetworkInterfaces, vmoprv1.VirtualMachineNetworkInterface{
NetworkName: network.Name,
NetworkType: string(network.Spec.Type),
vm.Spec.Network.Interfaces = append(vm.Spec.Network.Interfaces, vmoprv1.VirtualMachineNetworkInterfaceSpec{
Name: fmt.Sprintf("eth%d", len(vm.Spec.Network.Interfaces)),
Network: vmoprv1common.PartialObjectRef{
TypeMeta: metav1.TypeMeta{
Kind: "Network",
APIVersion: netopv1.SchemeGroupVersion.String(),
},
Name: network.Name,
},
})

return nil
Expand Down
23 changes: 13 additions & 10 deletions pkg/services/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
. "github.com/onsi/gomega"
netopv1alpha1 "github.com/vmware-tanzu/net-operator-api/api/v1alpha1"
nsxopv1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
ncpv1 "github.com/vmware-tanzu/vm-operator/external/ncp/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -165,7 +165,7 @@ var _ = Describe("Network provider", func() {
})
It("should not add network interface", func() {
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.NetworkInterfaces).To(BeNil())
Expect(vm.Spec.Network).To(BeNil())
})
})

Expand Down Expand Up @@ -196,8 +196,9 @@ var _ = Describe("Network provider", func() {

AfterEach(func() {
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.NetworkInterfaces).To(HaveLen(1))
Expect(vm.Spec.NetworkInterfaces[0].NetworkType).To(Equal("vsphere-distributed"))
Expect(vm.Spec.Network.Interfaces).To(HaveLen(1))
Expect(vm.Spec.Network.Interfaces[0].Network.TypeMeta.Kind).To(Equal("Network"))
// TODO(chrischdi): also assert group version
})

It("should add vds type network interface", func() {
Expand Down Expand Up @@ -233,8 +234,9 @@ var _ = Describe("Network provider", func() {
})
AfterEach(func() {
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.NetworkInterfaces[0].NetworkName).To(Equal(GetNSXTVirtualNetworkName(vSphereCluster.Name)))
Expect(vm.Spec.NetworkInterfaces[0].NetworkType).To(Equal("nsx-t"))
Expect(vm.Spec.Network.Interfaces[0].Network.Name).To(Equal(GetNSXTVirtualNetworkName(vSphereCluster.Name)))
Expect(vm.Spec.Network.Interfaces[0].Network.TypeMeta.Kind).To(Equal("VirtualNetwork"))
// TODO(chrischdi): also assert group version
})
})

Expand All @@ -249,19 +251,20 @@ var _ = Describe("Network provider", func() {
It("should add nsx-t-subnetset type network interface", func() {
err = np.ConfigureVirtualMachine(ctx, clusterCtx, vm)
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.NetworkInterfaces).To(HaveLen(1))
Expect(vm.Spec.Network.Interfaces).To(HaveLen(1))
})

It("nsx-t-subnetset type network interface already exists", func() {
err = np.ConfigureVirtualMachine(ctx, clusterCtx, vm)
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.NetworkInterfaces).To(HaveLen(1))
Expect(vm.Spec.Network.Interfaces).To(HaveLen(1))
})

AfterEach(func() {
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.NetworkInterfaces[0].NetworkName).To(Equal(vSphereCluster.Name))
Expect(vm.Spec.NetworkInterfaces[0].NetworkType).To(Equal("nsx-t-subnetset"))
Expect(vm.Spec.Network.Interfaces[0].Network.Name).To(Equal(vSphereCluster.Name))
Expect(vm.Spec.Network.Interfaces[0].Network.TypeMeta.Kind).To(Equal("SubnetSet"))
// TODO(chrischdi): also assert group version
})
})
})
Expand Down
22 changes: 16 additions & 6 deletions pkg/services/network/nsxt_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"fmt"

"github.com/pkg/errors"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
vmoprv1common "github.com/vmware-tanzu/vm-operator/api/v1alpha2/common"
ncpv1 "github.com/vmware-tanzu/vm-operator/external/ncp/api/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -187,15 +188,24 @@ func (np *nsxtNetworkProvider) GetVMServiceAnnotations(ctx context.Context, clus
// ConfigureVirtualMachine configures a VirtualMachine object based on the networking configuration.
func (np *nsxtNetworkProvider) ConfigureVirtualMachine(_ context.Context, clusterCtx *vmware.ClusterContext, vm *vmoprv1.VirtualMachine) error {
nsxtClusterNetworkName := GetNSXTVirtualNetworkName(clusterCtx.VSphereCluster.Name)
for _, vnif := range vm.Spec.NetworkInterfaces {
if vnif.NetworkType == NSXTTypeNetwork && vnif.NetworkName == nsxtClusterNetworkName {
if vm.Spec.Network == nil {
vm.Spec.Network = &vmoprv1.VirtualMachineNetworkSpec{}
}
for _, vnif := range vm.Spec.Network.Interfaces {
if vnif.Network.TypeMeta.GroupVersionKind() == ncpv1.SchemeGroupVersion.WithKind("VirtualNetwork") && vnif.Network.Name == nsxtClusterNetworkName {
// expected network interface is already found
return nil
}
}
vm.Spec.NetworkInterfaces = append(vm.Spec.NetworkInterfaces, vmoprv1.VirtualMachineNetworkInterface{
NetworkName: nsxtClusterNetworkName,
NetworkType: NSXTTypeNetwork,
vm.Spec.Network.Interfaces = append(vm.Spec.Network.Interfaces, vmoprv1.VirtualMachineNetworkInterfaceSpec{
Name: fmt.Sprintf("eth%d", len(vm.Spec.Network.Interfaces)),
Network: vmoprv1common.PartialObjectRef{
TypeMeta: metav1.TypeMeta{
Kind: "VirtualNetwork",
APIVersion: ncpv1.SchemeGroupVersion.String(),
},
Name: nsxtClusterNetworkName,
},
})
return nil
}
23 changes: 17 additions & 6 deletions pkg/services/network/nsxt_vpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (

"github.com/pkg/errors"
nsxopv1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
vmoprv1common "github.com/vmware-tanzu/vm-operator/api/v1alpha2/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -173,15 +174,25 @@ func (vp *nsxtVPCNetworkProvider) GetVMServiceAnnotations(_ context.Context, _ *
// ConfigureVirtualMachine configures a VirtualMachine object based on the networking configuration.
func (vp *nsxtVPCNetworkProvider) ConfigureVirtualMachine(_ context.Context, clusterCtx *vmware.ClusterContext, vm *vmoprv1.VirtualMachine) error {
networkName := clusterCtx.VSphereCluster.Name
for _, vnif := range vm.Spec.NetworkInterfaces {
if vnif.NetworkType == NSXTVPCSubnetSetNetworkType && vnif.NetworkName == networkName {
if vm.Spec.Network == nil {
vm.Spec.Network = &vmoprv1.VirtualMachineNetworkSpec{}
}
for _, vnif := range vm.Spec.Network.Interfaces {
if vnif.Network.TypeMeta.GroupVersionKind() == nsxopv1.SchemeGroupVersion.WithKind("SubnetSet") && vnif.Network.Name == networkName {
// expected network interface is already found
return nil
}
}
vm.Spec.NetworkInterfaces = append(vm.Spec.NetworkInterfaces, vmoprv1.VirtualMachineNetworkInterface{
NetworkName: networkName,
NetworkType: NSXTVPCSubnetSetNetworkType,

vm.Spec.Network.Interfaces = append(vm.Spec.Network.Interfaces, vmoprv1.VirtualMachineNetworkInterfaceSpec{
Name: fmt.Sprintf("eth%d", len(vm.Spec.Network.Interfaces)),
Network: vmoprv1common.PartialObjectRef{
TypeMeta: metav1.TypeMeta{
Kind: "SubnetSet",
APIVersion: nsxopv1.SchemeGroupVersion.String(),
},
Name: networkName,
},
})
return nil
}
2 changes: 1 addition & 1 deletion pkg/services/vmoperator/control_plane_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"

"github.com/pkg/errors"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/vmoperator/control_plane_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
netopv1 "github.com/vmware-tanzu/net-operator-api/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
ncpv1 "github.com/vmware-tanzu/vm-operator/external/ncp/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down
16 changes: 5 additions & 11 deletions pkg/services/vmoperator/resource_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"

"github.com/pkg/errors"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
vmoprv1 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -78,16 +78,10 @@ func (s *RPService) createVirtualMachineSetResourcePolicy(ctx context.Context, c
ResourcePool: vmoprv1.ResourcePoolSpec{
Name: clusterCtx.Cluster.Name,
},
Folder: vmoprv1.FolderSpec{
Name: clusterCtx.Cluster.Name,
},
ClusterModules: []vmoprv1.ClusterModuleSpec{
{
GroupName: ControlPlaneVMClusterModuleGroupName,
},
{
GroupName: getMachineDeploymentNameForCluster(clusterCtx.Cluster),
},
Folder: clusterCtx.Cluster.Name,
ClusterModuleGroups: []string{
ControlPlaneVMClusterModuleGroupName,
getMachineDeploymentNameForCluster(clusterCtx.Cluster),
},
}
// Ensure that the VirtualMachineSetResourcePolicy is owned by the VSphereCluster
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/vmoperator/resource_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ func TestRPService(t *testing.T) {
resourcePolicy, err := rpService.getVirtualMachineSetResourcePolicy(ctx, clusterCtx)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(resourcePolicy.Spec.ResourcePool.Name).To(Equal(clusterName))
g.Expect(resourcePolicy.Spec.Folder.Name).To(Equal(clusterName))
g.Expect(resourcePolicy.Spec.Folder).To(Equal(clusterName))
})
}
Loading

0 comments on commit 6fff075

Please sign in to comment.