diff --git a/test/infrastructure/vcsim/api/v1alpha1/controlplaneendpoint_types.go b/test/infrastructure/vcsim/api/v1alpha1/controlplaneendpoint_types.go index 46fb7f9f90..c120c0f25b 100644 --- a/test/infrastructure/vcsim/api/v1alpha1/controlplaneendpoint_types.go +++ b/test/infrastructure/vcsim/api/v1alpha1/controlplaneendpoint_types.go @@ -36,7 +36,7 @@ type ControlPlaneEndpointStatus struct { Host string `json:"host,omitempty"` // The control plane port. - Port int `json:"port,omitempty"` + Port int32 `json:"port,omitempty"` } // +kubebuilder:resource:path=controlplaneendpoints,scope=Namespaced,categories=cluster-api diff --git a/test/infrastructure/vcsim/api/v1alpha1/envvar_types.go b/test/infrastructure/vcsim/api/v1alpha1/envvar_types.go index 3a83b62d6b..0b1dba52e8 100644 --- a/test/infrastructure/vcsim/api/v1alpha1/envvar_types.go +++ b/test/infrastructure/vcsim/api/v1alpha1/envvar_types.go @@ -41,25 +41,25 @@ type ClusterEnvVarSpec struct { // NOTE: This variable isn't related to the vcsim controller, but we are handling it here // in order to have a single point of control for all the variables related to a Cluster API template. // Default: 1 - ControlPlaneMachines *int `json:"controlPlaneMachines,omitempty"` + ControlPlaneMachines *int32 `json:"controlPlaneMachines,omitempty"` // The number of the worker machines in the Cluster API cluster. // NOTE: This variable isn't related to the vcsim controller, but we are handling it here // in order to have a single point of control for all the variables related to a Cluster API template. // Default: 1 - WorkerMachines *int `json:"workerMachines,omitempty"` + WorkerMachines *int32 `json:"workerMachines,omitempty"` // Datacenter specifies the Datacenter for the Cluster API cluster. // Default: 0 (DC0) - Datacenter *int `json:"datacenter,omitempty"` + Datacenter *int32 `json:"datacenter,omitempty"` // Cluster specifies the VCenter Cluster for the Cluster API cluster. // Default: 0 (C0) - Cluster *int `json:"cluster,omitempty"` + Cluster *int32 `json:"cluster,omitempty"` // Datastore specifies the Datastore for the Cluster API cluster. // Default: 0 (LocalDS_0) - Datastore *int `json:"datastore,omitempty"` + Datastore *int32 `json:"datastore,omitempty"` } // EnvVarStatus defines the observed state of the EnvVar. diff --git a/test/infrastructure/vcsim/api/v1alpha1/vcsim_types.go b/test/infrastructure/vcsim/api/v1alpha1/vcsim_types.go index 6b0ca81701..8879f52c88 100644 --- a/test/infrastructure/vcsim/api/v1alpha1/vcsim_types.go +++ b/test/infrastructure/vcsim/api/v1alpha1/vcsim_types.go @@ -40,17 +40,17 @@ type VCenterSimulatorModel struct { // Datacenter specifies the number of Datacenter entities to create // Name prefix: DC, vcsim flag: -dc // Default: 1 - Datacenter *int `json:"datacenter,omitempty"` + Datacenter *int32 `json:"datacenter,omitempty"` // Cluster specifies the number of ClusterComputeResource entities to create per Datacenter // Name prefix: C, vcsim flag: -cluster // Default: 1 - Cluster *int `json:"cluster,omitempty"` + Cluster *int32 `json:"cluster,omitempty"` // ClusterHost specifies the number of HostSystems entities to create within a Cluster // Name prefix: H, vcsim flag: -host // Default: 3 - ClusterHost *int `json:"clusterHost,omitempty"` + ClusterHost *int32 `json:"clusterHost,omitempty"` // Pool specifies the number of ResourcePool entities to create per Cluster // Note that every cluster has a root ResourcePool named "Resources", as real vCenter does. @@ -63,14 +63,14 @@ type VCenterSimulatorModel struct { // Default: 0 // TODO: model pool selection for each cluster; for now ResourcePool named "Resources" will be always used // but ideally we should use RPx as per documentation above. - Pool *int `json:"pool,omitempty"` + Pool *int32 `json:"pool,omitempty"` // Datastore specifies the number of Datastore entities to create // Each Datastore will have temporary local file storage and will be mounted // on every HostSystem created by the ModelConfig // Name prefix: LocalDS, vcsim flag: -ds // Default: 1 - Datastore *int `json:"datastore,omitempty"` + Datastore *int32 `json:"datastore,omitempty"` // TODO: consider if to add options for creating more folders, networks, custom storage policies } diff --git a/test/infrastructure/vcsim/api/v1alpha1/zz_generated.deepcopy.go b/test/infrastructure/vcsim/api/v1alpha1/zz_generated.deepcopy.go index 5399c77584..c3a50ef41d 100644 --- a/test/infrastructure/vcsim/api/v1alpha1/zz_generated.deepcopy.go +++ b/test/infrastructure/vcsim/api/v1alpha1/zz_generated.deepcopy.go @@ -34,27 +34,27 @@ func (in *ClusterEnvVarSpec) DeepCopyInto(out *ClusterEnvVarSpec) { } if in.ControlPlaneMachines != nil { in, out := &in.ControlPlaneMachines, &out.ControlPlaneMachines - *out = new(int) + *out = new(int32) **out = **in } if in.WorkerMachines != nil { in, out := &in.WorkerMachines, &out.WorkerMachines - *out = new(int) + *out = new(int32) **out = **in } if in.Datacenter != nil { in, out := &in.Datacenter, &out.Datacenter - *out = new(int) + *out = new(int32) **out = **in } if in.Cluster != nil { in, out := &in.Cluster, &out.Cluster - *out = new(int) + *out = new(int32) **out = **in } if in.Datastore != nil { in, out := &in.Datastore, &out.Datastore - *out = new(int) + *out = new(int32) **out = **in } } @@ -324,27 +324,27 @@ func (in *VCenterSimulatorModel) DeepCopyInto(out *VCenterSimulatorModel) { } if in.Datacenter != nil { in, out := &in.Datacenter, &out.Datacenter - *out = new(int) + *out = new(int32) **out = **in } if in.Cluster != nil { in, out := &in.Cluster, &out.Cluster - *out = new(int) + *out = new(int32) **out = **in } if in.ClusterHost != nil { in, out := &in.ClusterHost, &out.ClusterHost - *out = new(int) + *out = new(int32) **out = **in } if in.Pool != nil { in, out := &in.Pool, &out.Pool - *out = new(int) + *out = new(int32) **out = **in } if in.Datastore != nil { in, out := &in.Datastore, &out.Datastore - *out = new(int) + *out = new(int32) **out = **in } } diff --git a/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_controlplaneendpoints.yaml b/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_controlplaneendpoints.yaml index f70f17596a..174d5be0a6 100644 --- a/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_controlplaneendpoints.yaml +++ b/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_controlplaneendpoints.yaml @@ -48,6 +48,7 @@ spec: type: string port: description: The control plane port. + format: int32 type: integer type: object type: object diff --git a/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_envvars.yaml b/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_envvars.yaml index 9256ded9c3..189e8c2f75 100644 --- a/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_envvars.yaml +++ b/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_envvars.yaml @@ -43,6 +43,7 @@ spec: cluster: description: 'Cluster specifies the VCenter Cluster for the Cluster API cluster. Default: 0 (C0)' + format: int32 type: integer controlPlaneMachines: description: 'The number of the control plane machines in the @@ -50,14 +51,17 @@ spec: vcsim controller, but we are handling it here in order to have a single point of control for all the variables related to a Cluster API template. Default: 1' + format: int32 type: integer datacenter: description: 'Datacenter specifies the Datacenter for the Cluster API cluster. Default: 0 (DC0)' + format: int32 type: integer datastore: description: 'Datastore specifies the Datastore for the Cluster API cluster. Default: 0 (LocalDS_0)' + format: int32 type: integer kubernetesVersion: description: 'The Kubernetes version of the Cluster API cluster. @@ -75,6 +79,7 @@ spec: controller, but we are handling it here in order to have a single point of control for all the variables related to a Cluster API template. Default: 1' + format: int32 type: integer required: - name diff --git a/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_vcentersimulators.yaml b/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_vcentersimulators.yaml index 886fef3a46..a15fab9d18 100644 --- a/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_vcentersimulators.yaml +++ b/test/infrastructure/vcsim/config/crd/bases/vcsim.infrastructure.cluster.x-k8s.io_vcentersimulators.yaml @@ -44,21 +44,25 @@ spec: description: 'Cluster specifies the number of ClusterComputeResource entities to create per Datacenter Name prefix: C, vcsim flag: -cluster Default: 1' + format: int32 type: integer clusterHost: description: 'ClusterHost specifies the number of HostSystems entities to create within a Cluster Name prefix: H, vcsim flag: -host Default: 3' + format: int32 type: integer datacenter: description: 'Datacenter specifies the number of Datacenter entities to create Name prefix: DC, vcsim flag: -dc Default: 1' + format: int32 type: integer datastore: description: 'Datastore specifies the number of Datastore entities to create Each Datastore will have temporary local file storage and will be mounted on every HostSystem created by the ModelConfig Name prefix: LocalDS, vcsim flag: -ds Default: 1' + format: int32 type: integer pool: description: 'Pool specifies the number of ResourcePool entities @@ -72,6 +76,7 @@ spec: selection for each cluster; for now ResourcePool named "Resources" will be always used but ideally we should use RPx as per documentation above.' + format: int32 type: integer vsphereVersion: description: 'VSphereVersion specifies the VSphere version to diff --git a/test/infrastructure/vcsim/controllers/controlplaneendpoint_controller.go b/test/infrastructure/vcsim/controllers/controlplaneendpoint_controller.go index 0bdeed3e32..678fbc8abd 100644 --- a/test/infrastructure/vcsim/controllers/controlplaneendpoint_controller.go +++ b/test/infrastructure/vcsim/controllers/controlplaneendpoint_controller.go @@ -108,7 +108,7 @@ func (r *ControlPlaneEndpointReconciler) reconcileNormal(ctx context.Context, co r.InMemoryManager.AddResourceGroup(resourceGroup) controlPlaneEndpoint.Status.Host = r.PodIP // NOTE: we are replacing the listener ip with the pod ip so it will be accessible from other pods as well - controlPlaneEndpoint.Status.Port = listener.Port() + controlPlaneEndpoint.Status.Port = int32(listener.Port()) return nil } diff --git a/test/infrastructure/vcsim/controllers/envvar_controller.go b/test/infrastructure/vcsim/controllers/envvar_controller.go index b0e7d39534..ffe9d9fd19 100644 --- a/test/infrastructure/vcsim/controllers/envvar_controller.go +++ b/test/infrastructure/vcsim/controllers/envvar_controller.go @@ -163,18 +163,19 @@ func (r *EnvVarReconciler) reconcileNormal(ctx context.Context, envVar *vcsimv1. "NAMESPACE": vCenterSimulator.Namespace, "CLUSTER_NAME": envVar.Spec.Cluster.Name, "KUBERNETES_VERSION": ptr.Deref(envVar.Spec.Cluster.KubernetesVersion, "v1.28.0"), - "CONTROL_PLANE_MACHINE_COUNT": strconv.Itoa(ptr.Deref(envVar.Spec.Cluster.ControlPlaneMachines, 1)), - "WORKER_MACHINE_COUNT": strconv.Itoa(ptr.Deref(envVar.Spec.Cluster.WorkerMachines, 1)), + "CONTROL_PLANE_MACHINE_COUNT": strconv.Itoa(int(ptr.Deref(envVar.Spec.Cluster.ControlPlaneMachines, 1))), + "WORKER_MACHINE_COUNT": strconv.Itoa(int(ptr.Deref(envVar.Spec.Cluster.WorkerMachines, 1))), // variables for the fake APIServer endpoint "CONTROL_PLANE_ENDPOINT_IP": controlPlaneEndpoint.Status.Host, - "CONTROL_PLANE_ENDPOINT_PORT": strconv.Itoa(controlPlaneEndpoint.Status.Port), + "CONTROL_PLANE_ENDPOINT_PORT": strconv.Itoa(int(controlPlaneEndpoint.Status.Port)), // variables to set up govc for working with the vcsim instance. "GOVC_URL": fmt.Sprintf("https://%s:%s@%s/sdk", vCenterSimulator.Status.Username, vCenterSimulator.Status.Password, strings.Replace(vCenterSimulator.Status.Host, r.PodIP, "127.0.0.1", 1)), // NOTE: reverting back to local host because the assumption is that the vcsim pod will be port-forwarded on local host "GOVC_INSECURE": "true", } + // Variables below are generated using the same utilities used both also for E2E tests setup. if r.SupervisorMode { // Variables used only in supervisor mode envVar.Status.Variables["VSPHERE_STORAGE_POLICY"] = "vcsim-default" @@ -190,8 +191,8 @@ func (r *EnvVarReconciler) reconcileNormal(ctx context.Context, envVar *vcsimv1. // cluster template variables about the vcsim instance. envVar.Status.Variables["VSPHERE_SERVER"] = fmt.Sprintf("https://%s", vCenterSimulator.Status.Host) envVar.Status.Variables["VSPHERE_TLS_THUMBPRINT"] = vCenterSimulator.Status.Thumbprint - envVar.Status.Variables["VSPHERE_DATACENTER"] = vcsimDatacenterName(ptr.Deref(envVar.Spec.Cluster.Datacenter, 0)) - envVar.Status.Variables["VSPHERE_DATASTORE"] = vcsimDatastoreName(ptr.Deref(envVar.Spec.Cluster.Datastore, 0)) + envVar.Status.Variables["VSPHERE_DATACENTER"] = vcsimDatacenterName(int(ptr.Deref(envVar.Spec.Cluster.Datacenter, 0))) + envVar.Status.Variables["VSPHERE_DATASTORE"] = vcsimDatastoreName(int(ptr.Deref(envVar.Spec.Cluster.Datastore, 0))) envVar.Status.Variables["VSPHERE_FOLDER"] = fmt.Sprintf("/DC%d/vm", ptr.Deref(envVar.Spec.Cluster.Datacenter, 0)) envVar.Status.Variables["VSPHERE_NETWORK"] = fmt.Sprintf("/DC%d/network/VM Network", ptr.Deref(envVar.Spec.Cluster.Datacenter, 0)) envVar.Status.Variables["VSPHERE_RESOURCE_POOL"] = fmt.Sprintf("/DC%d/host/DC%[1]d_C%d/Resources", ptr.Deref(envVar.Spec.Cluster.Datacenter, 0), ptr.Deref(envVar.Spec.Cluster.Cluster, 0)) diff --git a/test/infrastructure/vcsim/controllers/vcsim.go b/test/infrastructure/vcsim/controllers/vcsim.go index 7d0c1aa1bb..eed06db511 100644 --- a/test/infrastructure/vcsim/controllers/vcsim.go +++ b/test/infrastructure/vcsim/controllers/vcsim.go @@ -84,7 +84,7 @@ func createVMTemplate(ctx context.Context, vCenterSimulator *vcsimv1.VCenterSimu datastore := 0 datacenters := 1 if vCenterSimulator.Spec.Model != nil { - datacenters = ptr.Deref(vCenterSimulator.Spec.Model.Datacenter, simulator.VPX().Datacenter) // VPX is the same base model used when creating vcsim + datacenters = int(ptr.Deref(vCenterSimulator.Spec.Model.Datacenter, int32(simulator.VPX().Datacenter))) // VPX is the same base model used when creating vcsim } for dc := 0; dc < datacenters; dc++ { exit := cli.Run([]string{"vm.create", fmt.Sprintf("-ds=%s", vcsimDatastoreName(datastore)), fmt.Sprintf("-cluster=%s", vcsimClusterName(dc, cluster)), fmt.Sprintf("-net=%s", vcsimDefaultNetworkName), "-disk=20G", "-on=false", "-k=true", fmt.Sprintf("-u=%s", govcURL), vcsimDefaultVMTemplateName}) diff --git a/test/infrastructure/vcsim/controllers/vcsim_controller.go b/test/infrastructure/vcsim/controllers/vcsim_controller.go index ada75cd101..60a10fe4f8 100644 --- a/test/infrastructure/vcsim/controllers/vcsim_controller.go +++ b/test/infrastructure/vcsim/controllers/vcsim_controller.go @@ -149,11 +149,11 @@ func (r *VCenterSimulatorReconciler) reconcileNormal(ctx context.Context, vCente model.ServiceContent.About.Version = vcsimMinVersionForCAPV if vCenterSimulator.Spec.Model != nil { model.ServiceContent.About.Version = ptr.Deref(vCenterSimulator.Spec.Model.VSphereVersion, model.ServiceContent.About.Version) - model.Datacenter = ptr.Deref(vCenterSimulator.Spec.Model.Datacenter, model.Datacenter) - model.Cluster = ptr.Deref(vCenterSimulator.Spec.Model.Cluster, model.Cluster) - model.ClusterHost = ptr.Deref(vCenterSimulator.Spec.Model.ClusterHost, model.ClusterHost) - model.Pool = ptr.Deref(vCenterSimulator.Spec.Model.Pool, model.Pool) - model.Datastore = ptr.Deref(vCenterSimulator.Spec.Model.Datastore, model.Datastore) + model.Datacenter = int(ptr.Deref(vCenterSimulator.Spec.Model.Datacenter, int32(model.Datacenter))) + model.Cluster = int(ptr.Deref(vCenterSimulator.Spec.Model.Cluster, int32(model.Cluster))) + model.ClusterHost = int(ptr.Deref(vCenterSimulator.Spec.Model.ClusterHost, int32(model.ClusterHost))) + model.Pool = int(ptr.Deref(vCenterSimulator.Spec.Model.Pool, int32(model.Pool))) + model.Datastore = int(ptr.Deref(vCenterSimulator.Spec.Model.Datastore, int32(model.Datastore))) } if err := model.Create(); err != nil { return errors.Wrapf(err, "failed to create vcsim server model")