From 682c24cf41c80c447db1d6f21238b15c86c21b7c Mon Sep 17 00:00:00 2001 From: vr4manta Date: Wed, 4 Sep 2024 13:28:41 -0400 Subject: [PATCH] Add vSphere multi disk support --- features.md | 1 + features/features.go | 7 +++ machine/v1beta1/types_vsphereprovider.go | 16 +++++++ machine/v1beta1/zz_generated.deepcopy.go | 32 +++++++++++++ .../zz_generated.swagger_doc_generated.go | 11 +++++ .../generated_openapi/zz_generated.openapi.go | 45 ++++++++++++++++++- openapi/openapi.json | 26 +++++++++++ .../featureGate-Hypershift-Default.yaml | 3 ++ ...reGate-Hypershift-DevPreviewNoUpgrade.yaml | 3 ++ ...eGate-Hypershift-TechPreviewNoUpgrade.yaml | 3 ++ .../featureGate-SelfManagedHA-Default.yaml | 3 ++ ...ate-SelfManagedHA-DevPreviewNoUpgrade.yaml | 3 ++ ...te-SelfManagedHA-TechPreviewNoUpgrade.yaml | 3 ++ 13 files changed, 155 insertions(+), 1 deletion(-) diff --git a/features.md b/features.md index e668fc88b36..0d84c955fe4 100644 --- a/features.md +++ b/features.md @@ -46,6 +46,7 @@ | UpgradeStatus| | | Enabled | Enabled | Enabled | Enabled | | UserNamespacesPodSecurityStandards| | | Enabled | Enabled | Enabled | Enabled | | UserNamespacesSupport| | | Enabled | Enabled | Enabled | Enabled | +| VSphereMultiDisk| | | Enabled | Enabled | Enabled | Enabled | | VSphereMultiNetworks| | | Enabled | Enabled | Enabled | Enabled | | VSphereMultiVCenters| | | Enabled | Enabled | Enabled | Enabled | | VolumeGroupSnapshot| | | Enabled | Enabled | Enabled | Enabled | diff --git a/features/features.go b/features/features.go index 7f496239543..2219393cd9b 100644 --- a/features/features.go +++ b/features/features.go @@ -175,6 +175,13 @@ var ( enableIn(configv1.Default, configv1.DevPreviewNoUpgrade, configv1.TechPreviewNoUpgrade). mustRegister() + FeatureGateVSphereMultiDisk = newFeatureGate("VSphereMultiDisk"). + reportProblemsToJiraComponent("splat"). + contactPerson("vr4manta"). + productScope(ocpSpecific). + enableIn(configv1.DevPreviewNoUpgrade, configv1.TechPreviewNoUpgrade). + mustRegister() + FeatureGateVSphereMultiVCenters = newFeatureGate("VSphereMultiVCenters"). reportProblemsToJiraComponent("splat"). contactPerson("vr4manta"). diff --git a/machine/v1beta1/types_vsphereprovider.go b/machine/v1beta1/types_vsphereprovider.go index b7269319829..165b145c0ec 100644 --- a/machine/v1beta1/types_vsphereprovider.go +++ b/machine/v1beta1/types_vsphereprovider.go @@ -70,6 +70,13 @@ type VSphereMachineProviderSpec struct { // When using LinkedClone, if no snapshots exist for the source template, falls back to FullClone. // +optional CloneMode CloneMode `json:"cloneMode,omitempty"` + // Disks is a list of non OS disks to be attached to the VM. + // +openshift:enable:FeatureGate=VSphereMultiDisk + // +openshift:validation:FeatureGateAwareMaxItems:featureGate="",maxItems=0 + // +openshift:validation:FeatureGateAwareMaxItems:featureGate=VSphereMultiDisk,maxItems=15 + // +kubebuilder:validation:XValidation:rule="self == oldSelf | size(self) == size(oldSelf)",message="additional disks cannot be added or removed once set" + // +optional + Disks []*VSphereDisk `json:"disks,omitempty"` } // CloneMode is the type of clone operation used to clone a VM from a template. @@ -172,6 +179,15 @@ type NetworkDeviceSpec struct { AddressesFromPools []AddressesFromPool `json:"addressesFromPools,omitempty"` } +// VSphereDisk describes additional disks for vSphere. +type VSphereDisk struct { + // The device name exposed. Used to identify the disk. + // +optional + DeviceName *string `json:"deviceName,omitempty"` + // SizeGB is the size of the disk (in GB). + SizeGB int64 `json:"sizeGb"` +} + // WorkspaceConfig defines a workspace configuration for the vSphere cloud // provider. type Workspace struct { diff --git a/machine/v1beta1/zz_generated.deepcopy.go b/machine/v1beta1/zz_generated.deepcopy.go index d37ac11e6af..4e099846bc1 100644 --- a/machine/v1beta1/zz_generated.deepcopy.go +++ b/machine/v1beta1/zz_generated.deepcopy.go @@ -1774,6 +1774,27 @@ func (in *VMDiskSecurityProfile) DeepCopy() *VMDiskSecurityProfile { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSphereDisk) DeepCopyInto(out *VSphereDisk) { + *out = *in + if in.DeviceName != nil { + in, out := &in.DeviceName, &out.DeviceName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSphereDisk. +func (in *VSphereDisk) DeepCopy() *VSphereDisk { + if in == nil { + return nil + } + out := new(VSphereDisk) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VSphereMachineProviderSpec) DeepCopyInto(out *VSphereMachineProviderSpec) { *out = *in @@ -1800,6 +1821,17 @@ func (in *VSphereMachineProviderSpec) DeepCopyInto(out *VSphereMachineProviderSp *out = make([]string, len(*in)) copy(*out, *in) } + if in.Disks != nil { + in, out := &in.Disks, &out.Disks + *out = make([]*VSphereDisk, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(VSphereDisk) + (*in).DeepCopyInto(*out) + } + } + } return } diff --git a/machine/v1beta1/zz_generated.swagger_doc_generated.go b/machine/v1beta1/zz_generated.swagger_doc_generated.go index 5bba232bf7f..be623ce555d 100644 --- a/machine/v1beta1/zz_generated.swagger_doc_generated.go +++ b/machine/v1beta1/zz_generated.swagger_doc_generated.go @@ -783,6 +783,16 @@ func (NetworkSpec) SwaggerDoc() map[string]string { return map_NetworkSpec } +var map_VSphereDisk = map[string]string{ + "": "VSphereDisk describes additional disks for vSphere.", + "deviceName": "The device name exposed. Used to identify the disk.", + "sizeGb": "SizeGB is the size of the disk (in GB).", +} + +func (VSphereDisk) SwaggerDoc() map[string]string { + return map_VSphereDisk +} + var map_VSphereMachineProviderSpec = map[string]string{ "": "VSphereMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field for an VSphere virtual machine. It is used by the vSphere machine actuator to create a single Machine. Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).", "userDataSecret": "UserDataSecret contains a local reference to a secret that contains the UserData to apply to the instance", @@ -797,6 +807,7 @@ var map_VSphereMachineProviderSpec = map[string]string{ "tagIDs": "tagIDs is an optional set of tags to add to an instance. Specified tagIDs must use URN-notation instead of display names. A maximum of 10 tag IDs may be specified.", "snapshot": "Snapshot is the name of the snapshot from which the VM was cloned", "cloneMode": "CloneMode specifies the type of clone operation. The LinkedClone mode is only support for templates that have at least one snapshot. If the template has no snapshots, then CloneMode defaults to FullClone. When LinkedClone mode is enabled the DiskGiB field is ignored as it is not possible to expand disks of linked clones. Defaults to FullClone. When using LinkedClone, if no snapshots exist for the source template, falls back to FullClone.", + "disks": "Disks is a list of non OS disks to be attached to the VM.", } func (VSphereMachineProviderSpec) SwaggerDoc() map[string]string { diff --git a/openapi/generated_openapi/zz_generated.openapi.go b/openapi/generated_openapi/zz_generated.openapi.go index 323603eac3f..b3618ba2cda 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -749,6 +749,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/openshift/api/machine/v1beta1.UEFISettings": schema_openshift_api_machine_v1beta1_UEFISettings(ref), "github.com/openshift/api/machine/v1beta1.UnhealthyCondition": schema_openshift_api_machine_v1beta1_UnhealthyCondition(ref), "github.com/openshift/api/machine/v1beta1.VMDiskSecurityProfile": schema_openshift_api_machine_v1beta1_VMDiskSecurityProfile(ref), + "github.com/openshift/api/machine/v1beta1.VSphereDisk": schema_openshift_api_machine_v1beta1_VSphereDisk(ref), "github.com/openshift/api/machine/v1beta1.VSphereMachineProviderSpec": schema_openshift_api_machine_v1beta1_VSphereMachineProviderSpec(ref), "github.com/openshift/api/machine/v1beta1.VSphereMachineProviderStatus": schema_openshift_api_machine_v1beta1_VSphereMachineProviderStatus(ref), "github.com/openshift/api/machine/v1beta1.Workspace": schema_openshift_api_machine_v1beta1_Workspace(ref), @@ -38545,6 +38546,35 @@ func schema_openshift_api_machine_v1beta1_VMDiskSecurityProfile(ref common.Refer } } +func schema_openshift_api_machine_v1beta1_VSphereDisk(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "VSphereDisk describes additional disks for vSphere.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "deviceName": { + SchemaProps: spec.SchemaProps{ + Description: "The device name exposed. Used to identify the disk.", + Type: []string{"string"}, + Format: "", + }, + }, + "sizeGb": { + SchemaProps: spec.SchemaProps{ + Description: "SizeGB is the size of the disk (in GB).", + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + Required: []string{"sizeGb"}, + }, + }, + } +} + func schema_openshift_api_machine_v1beta1_VSphereMachineProviderSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -38663,12 +38693,25 @@ func schema_openshift_api_machine_v1beta1_VSphereMachineProviderSpec(ref common. Format: "", }, }, + "disks": { + SchemaProps: spec.SchemaProps{ + Description: "Disks is a list of non OS disks to be attached to the VM.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/openshift/api/machine/v1beta1.VSphereDisk"), + }, + }, + }, + }, + }, }, Required: []string{"template", "network"}, }, }, Dependencies: []string{ - "github.com/openshift/api/machine/v1beta1.NetworkSpec", "github.com/openshift/api/machine/v1beta1.Workspace", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/openshift/api/machine/v1beta1.NetworkSpec", "github.com/openshift/api/machine/v1beta1.VSphereDisk", "github.com/openshift/api/machine/v1beta1.Workspace", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } diff --git a/openapi/openapi.json b/openapi/openapi.json index feaeaa6f4de..0625280e968 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -22266,6 +22266,25 @@ } } }, + "com.github.openshift.api.machine.v1beta1.VSphereDisk": { + "description": "VSphereDisk describes additional disks for vSphere.", + "type": "object", + "required": [ + "sizeGb" + ], + "properties": { + "deviceName": { + "description": "The device name exposed. Used to identify the disk.", + "type": "string" + }, + "sizeGb": { + "description": "SizeGB is the size of the disk (in GB).", + "type": "integer", + "format": "int64", + "default": 0 + } + } + }, "com.github.openshift.api.machine.v1beta1.VSphereMachineProviderSpec": { "description": "VSphereMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field for an VSphere virtual machine. It is used by the vSphere machine actuator to create a single Machine. Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).", "type": "object", @@ -22291,6 +22310,13 @@ "type": "integer", "format": "int32" }, + "disks": { + "description": "Disks is a list of non OS disks to be attached to the VM.", + "type": "array", + "items": { + "$ref": "#/definitions/com.github.openshift.api.machine.v1beta1.VSphereDisk" + } + }, "kind": { "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", "type": "string" diff --git a/payload-manifests/featuregates/featureGate-Hypershift-Default.yaml b/payload-manifests/featuregates/featureGate-Hypershift-Default.yaml index d0ca8f129b7..e82c1f196b3 100644 --- a/payload-manifests/featuregates/featureGate-Hypershift-Default.yaml +++ b/payload-manifests/featuregates/featureGate-Hypershift-Default.yaml @@ -151,6 +151,9 @@ { "name": "UserNamespacesSupport" }, + { + "name": "VSphereMultiDisk" + }, { "name": "VSphereMultiNetworks" }, diff --git a/payload-manifests/featuregates/featureGate-Hypershift-DevPreviewNoUpgrade.yaml b/payload-manifests/featuregates/featureGate-Hypershift-DevPreviewNoUpgrade.yaml index fc472569ae6..da23b6f1f7a 100644 --- a/payload-manifests/featuregates/featureGate-Hypershift-DevPreviewNoUpgrade.yaml +++ b/payload-manifests/featuregates/featureGate-Hypershift-DevPreviewNoUpgrade.yaml @@ -233,6 +233,9 @@ { "name": "VSphereDriverConfiguration" }, + { + "name": "VSphereMultiDisk" + }, { "name": "VSphereMultiNetworks" }, diff --git a/payload-manifests/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml b/payload-manifests/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml index 56bbf24a3a3..0fbcf784c7d 100644 --- a/payload-manifests/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml +++ b/payload-manifests/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml @@ -233,6 +233,9 @@ { "name": "VSphereDriverConfiguration" }, + { + "name": "VSphereMultiDisk" + }, { "name": "VSphereMultiNetworks" }, diff --git a/payload-manifests/featuregates/featureGate-SelfManagedHA-Default.yaml b/payload-manifests/featuregates/featureGate-SelfManagedHA-Default.yaml index 42ce1fd09bb..e46d00213ce 100644 --- a/payload-manifests/featuregates/featureGate-SelfManagedHA-Default.yaml +++ b/payload-manifests/featuregates/featureGate-SelfManagedHA-Default.yaml @@ -154,6 +154,9 @@ { "name": "UserNamespacesSupport" }, + { + "name": "VSphereMultiDisk" + }, { "name": "VSphereMultiNetworks" }, diff --git a/payload-manifests/featuregates/featureGate-SelfManagedHA-DevPreviewNoUpgrade.yaml b/payload-manifests/featuregates/featureGate-SelfManagedHA-DevPreviewNoUpgrade.yaml index 233d63bbfea..27bfece4ae2 100644 --- a/payload-manifests/featuregates/featureGate-SelfManagedHA-DevPreviewNoUpgrade.yaml +++ b/payload-manifests/featuregates/featureGate-SelfManagedHA-DevPreviewNoUpgrade.yaml @@ -233,6 +233,9 @@ { "name": "VSphereDriverConfiguration" }, + { + "name": "VSphereMultiDisk" + }, { "name": "VSphereMultiNetworks" }, diff --git a/payload-manifests/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml b/payload-manifests/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml index 8cfa5d89fe7..3586815413f 100644 --- a/payload-manifests/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml +++ b/payload-manifests/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml @@ -233,6 +233,9 @@ { "name": "VSphereDriverConfiguration" }, + { + "name": "VSphereMultiDisk" + }, { "name": "VSphereMultiNetworks" },