From d2e80cbc329671bd314df2561b153c293adc4b14 Mon Sep 17 00:00:00 2001 From: Samuel Stuchly Date: Thu, 28 Oct 2021 17:08:32 +0200 Subject: [PATCH 1/2] update types_gcprovider.go --- machine/v1beta1/types_gcpprovider.go | 37 ++++++++++++++++++- machine/v1beta1/zz_generated.deepcopy.go | 21 +++++++++++ .../zz_generated.swagger_doc_generated.go | 15 +++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/machine/v1beta1/types_gcpprovider.go b/machine/v1beta1/types_gcpprovider.go index d1e5b7fbf2a..76ac3232ff6 100644 --- a/machine/v1beta1/types_gcpprovider.go +++ b/machine/v1beta1/types_gcpprovider.go @@ -5,6 +5,16 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// GCPHostMaintenanceType is a type representing acceptable values for OnHostMaintenance field in GCPMachineProviderSpec +type GCPHostMaintenanceType string + +const ( + // MigrateHostMaintenanceType [default] - causes Compute Engine to live migrate an instance when there is a maintenance event. + MigrateHostMaintenanceType GCPHostMaintenanceType = "Migrate" + // TerminateHostMaintenanceType - stops an instance instead of migrating it. + TerminateHostMaintenanceType GCPHostMaintenanceType = "Terminate" +) + // GCPMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field // for an GCP virtual machine. It is used by the GCP 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). @@ -54,9 +64,24 @@ type GCPMachineProviderSpec struct { // ProjectID is the project in which the GCP machine provider will create the VM. // +optional ProjectID string `json:"projectID,omitempty"` - // Preemptible indicates if created instance is preemptible + // GPUs is a list of GPUs to be attached to the VM. + // +optional + GPUs []GCPGPUConfig `json:"gpus,omitempty"` + // Preemptible indicates if created instance is preemptible. // +optional Preemptible bool `json:"preemptible,omitempty"` + // OnHostMaintenance determines the behavior when a maintenance event occurs that might cause the instance to reboot. + // This is required to be set to "Terminate" if you want to provision machine with attached GPUs. + // Otherwise, allowed values are "Migrate" and "Terminate". + // If omitted, the platform chooses a default, which is subject to change over time, currently that default is "Migrate". + // +kubebuilder:validation:Enum=Migrate;Terminate; + // +optional + OnHostMaintenance GCPHostMaintenanceType `json:"onHostMaintenance,omitempty"` + // AutomaticRestart determines the behavior when an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event (default true). + // Cannot be true with preemptible instances. + // If omitted, the platform chooses a default, which is subject to change over time, currently that default is true. + // +optional + AutomaticRestart bool `json:"automaticRestart,omitempty"` } // GCPDisk describes disks for GCP. @@ -134,6 +159,16 @@ type GCPKMSKeyReference struct { Location string `json:"location"` } +// GCPGPUConfig describes type and count of GPUs attached to the instance on GCP. +type GCPGPUConfig struct { + // Count is the number of GPUs to be attached to an instance. + Count int32 `json:"count"` + // Type is the type of GPU to be attached to an instance. + // Supported GPU types are: nvidia-tesla-k80, nvidia-tesla-p100, nvidia-tesla-v100, nvidia-tesla-p4, nvidia-tesla-t4 + // +kubebuilder:validation:Pattern=`^nvidia-tesla-(k80|p100|v100|p4|t4)$` + Type string `json:"type"` +} + // GCPMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field. // It contains GCP-specific status information. // Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer). diff --git a/machine/v1beta1/zz_generated.deepcopy.go b/machine/v1beta1/zz_generated.deepcopy.go index fb98815aa79..5bf2a5f036f 100644 --- a/machine/v1beta1/zz_generated.deepcopy.go +++ b/machine/v1beta1/zz_generated.deepcopy.go @@ -530,6 +530,22 @@ func (in *GCPEncryptionKeyReference) DeepCopy() *GCPEncryptionKeyReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GCPGPUConfig) DeepCopyInto(out *GCPGPUConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPGPUConfig. +func (in *GCPGPUConfig) DeepCopy() *GCPGPUConfig { + if in == nil { + return nil + } + out := new(GCPGPUConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GCPKMSKeyReference) DeepCopyInto(out *GCPKMSKeyReference) { *out = *in @@ -636,6 +652,11 @@ func (in *GCPMachineProviderSpec) DeepCopyInto(out *GCPMachineProviderSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.GPUs != nil { + in, out := &in.GPUs, &out.GPUs + *out = make([]GCPGPUConfig, len(*in)) + copy(*out, *in) + } return } diff --git a/machine/v1beta1/zz_generated.swagger_doc_generated.go b/machine/v1beta1/zz_generated.swagger_doc_generated.go index 6b569f4aaa3..8d300cffee4 100644 --- a/machine/v1beta1/zz_generated.swagger_doc_generated.go +++ b/machine/v1beta1/zz_generated.swagger_doc_generated.go @@ -294,6 +294,16 @@ func (GCPEncryptionKeyReference) SwaggerDoc() map[string]string { return map_GCPEncryptionKeyReference } +var map_GCPGPUConfig = map[string]string{ + "": "GCPGPUConfig describes type and count of GPUs attached to the instance on GCP.", + "count": "Count is the number of GPUs to be attached to an instance.", + "type": "Type is the type of GPU to be attached to an instance. Supported GPU types are: nvidia-tesla-k80, nvidia-tesla-p100, nvidia-tesla-v100, nvidia-tesla-p4, nvidia-tesla-t4", +} + +func (GCPGPUConfig) SwaggerDoc() map[string]string { + return map_GCPGPUConfig +} + var map_GCPKMSKeyReference = map[string]string{ "": "GCPKMSKeyReference gathers required fields for looking up a GCP KMS Key", "name": "Name is the name of the customer managed encryption key to be used for the disk encryption.", @@ -337,7 +347,10 @@ var map_GCPMachineProviderSpec = map[string]string{ "region": "Region is the region in which the GCP machine provider will create the VM.", "zone": "Zone is the zone in which the GCP machine provider will create the VM.", "projectID": "ProjectID is the project in which the GCP machine provider will create the VM.", - "preemptible": "Preemptible indicates if created instance is preemptible", + "gpus": "GPUs is a list of GPUs to be attached to the VM.", + "preemptible": "Preemptible indicates if created instance is preemptible.", + "onHostMaintenance": "OnHostMaintenance determines the behavior when a maintenance event occurs that might cause the instance to reboot. This is required to be set to \"Terminate\" if you want to provision machine with attached GPUs. Otherwise, allowed values are \"Migrate\" and \"Terminate\". If omitted, the platform chooses a default, which is subject to change over time, currently that default is \"Migrate\".", + "automaticRestart": "AutomaticRestart determines the behavior when an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event (default true). Cannot be true with preemptible instances. If omitted, the platform chooses a default, which is subject to change over time, currently that default is true.", } func (GCPMachineProviderSpec) SwaggerDoc() map[string]string { From 00335336b2f8569b3eb1223cf5effbedc6015b18 Mon Sep 17 00:00:00 2001 From: Samuel Stuchly Date: Thu, 18 Nov 2021 15:49:39 +0100 Subject: [PATCH 2/2] change AutomaticRestart from bool to RestartPolicy --- machine/v1beta1/types_gcpprovider.go | 23 +++++++++++++++---- .../zz_generated.swagger_doc_generated.go | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/machine/v1beta1/types_gcpprovider.go b/machine/v1beta1/types_gcpprovider.go index 76ac3232ff6..4970bd7e22c 100644 --- a/machine/v1beta1/types_gcpprovider.go +++ b/machine/v1beta1/types_gcpprovider.go @@ -15,6 +15,16 @@ const ( TerminateHostMaintenanceType GCPHostMaintenanceType = "Terminate" ) +// GCPHostMaintenanceType is a type representing acceptable values for RestartPolicy field in GCPMachineProviderSpec +type GCPRestartPolicyType string + +const ( + // Restart an instance if an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event. + RestartPolicyAlways GCPRestartPolicyType = "Always" + // Do not restart an instance if an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event. + RestartPolicyNever GCPRestartPolicyType = "Never" +) + // GCPMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field // for an GCP virtual machine. It is used by the GCP 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). @@ -77,11 +87,14 @@ type GCPMachineProviderSpec struct { // +kubebuilder:validation:Enum=Migrate;Terminate; // +optional OnHostMaintenance GCPHostMaintenanceType `json:"onHostMaintenance,omitempty"` - // AutomaticRestart determines the behavior when an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event (default true). - // Cannot be true with preemptible instances. - // If omitted, the platform chooses a default, which is subject to change over time, currently that default is true. - // +optional - AutomaticRestart bool `json:"automaticRestart,omitempty"` + // RestartPolicy determines the behavior when an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event (default "Always"). + // Cannot be "Always" with preemptible instances. + // Otherwise, allowed values are "Always" and "Never". + // If omitted, the platform chooses a default, which is subject to change over time, currently that default is "Always". + // RestartPolicy represents AutomaticRestart in GCP compute api + // +kubebuilder:validation:Enum=Always;Never; + // +optional + RestartPolicy GCPRestartPolicyType `json:"restartPolicy,omitempty"` } // GCPDisk describes disks for GCP. diff --git a/machine/v1beta1/zz_generated.swagger_doc_generated.go b/machine/v1beta1/zz_generated.swagger_doc_generated.go index 8d300cffee4..7e7d7ca714b 100644 --- a/machine/v1beta1/zz_generated.swagger_doc_generated.go +++ b/machine/v1beta1/zz_generated.swagger_doc_generated.go @@ -350,7 +350,7 @@ var map_GCPMachineProviderSpec = map[string]string{ "gpus": "GPUs is a list of GPUs to be attached to the VM.", "preemptible": "Preemptible indicates if created instance is preemptible.", "onHostMaintenance": "OnHostMaintenance determines the behavior when a maintenance event occurs that might cause the instance to reboot. This is required to be set to \"Terminate\" if you want to provision machine with attached GPUs. Otherwise, allowed values are \"Migrate\" and \"Terminate\". If omitted, the platform chooses a default, which is subject to change over time, currently that default is \"Migrate\".", - "automaticRestart": "AutomaticRestart determines the behavior when an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event (default true). Cannot be true with preemptible instances. If omitted, the platform chooses a default, which is subject to change over time, currently that default is true.", + "restartPolicy": "RestartPolicy determines the behavior when an instance crashes or the underlying infrastructure provider stops the instance as part of a maintenance event (default \"Always\"). Cannot be \"Always\" with preemptible instances. Otherwise, allowed values are \"Always\" and \"Never\". If omitted, the platform chooses a default, which is subject to change over time, currently that default is \"Always\". RestartPolicy represents AutomaticRestart in GCP compute api", } func (GCPMachineProviderSpec) SwaggerDoc() map[string]string {