From 3ee24358d161211c45732c9466c5b03b25ab69fd Mon Sep 17 00:00:00 2001 From: David Date: Thu, 7 Dec 2023 12:08:29 -0500 Subject: [PATCH] add boot images update opt-in & mcp degrade type --- machineconfiguration/v1/types.go | 3 + .../generated_openapi/zz_generated.openapi.go | 72 ++++++++++++++++++- openapi/openapi.json | 37 ++++++++++ ...machine-config-operator_01_config.crd.yaml | 51 +++++++++++++ operator/v1/types_machineconfiguration.go | 43 +++++++++++ operator/v1/zz_generated.deepcopy.go | 43 +++++++++++ .../v1/zz_generated.swagger_doc_generated.go | 27 +++++++ 7 files changed, 275 insertions(+), 1 deletion(-) diff --git a/machineconfiguration/v1/types.go b/machineconfiguration/v1/types.go index 3b00b134d45..aac019d6880 100644 --- a/machineconfiguration/v1/types.go +++ b/machineconfiguration/v1/types.go @@ -507,6 +507,9 @@ const ( // MachineConfigPoolRenderDegraded means the rendered configuration for the pool cannot be generated because of an error MachineConfigPoolRenderDegraded MachineConfigPoolConditionType = "RenderDegraded" + // MachineConfigPoolMachineSetDegraded means the machineset reconciliation for the pool could not be completed because of an error + MachineConfigPoolMachineSetDegraded MachineConfigPoolConditionType = "MachineSetDegraded" + // MachineConfigPoolDegraded is the overall status of the pool based, today, on whether we fail with NodeDegraded or RenderDegraded MachineConfigPoolDegraded MachineConfigPoolConditionType = "Degraded" diff --git a/openapi/generated_openapi/zz_generated.openapi.go b/openapi/generated_openapi/zz_generated.openapi.go index 393df573e70..71da8434490 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -940,6 +940,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/openshift/api/operator/v1.MachineConfigurationList": schema_openshift_api_operator_v1_MachineConfigurationList(ref), "github.com/openshift/api/operator/v1.MachineConfigurationSpec": schema_openshift_api_operator_v1_MachineConfigurationSpec(ref), "github.com/openshift/api/operator/v1.MachineConfigurationStatus": schema_openshift_api_operator_v1_MachineConfigurationStatus(ref), + "github.com/openshift/api/operator/v1.ManagedBootImageConfig": schema_openshift_api_operator_v1_ManagedBootImageConfig(ref), + "github.com/openshift/api/operator/v1.ManagedBootImageConfigCustomization": schema_openshift_api_operator_v1_ManagedBootImageConfigCustomization(ref), "github.com/openshift/api/operator/v1.MyOperatorResource": schema_openshift_api_operator_v1_MyOperatorResource(ref), "github.com/openshift/api/operator/v1.MyOperatorResourceSpec": schema_openshift_api_operator_v1_MyOperatorResourceSpec(ref), "github.com/openshift/api/operator/v1.MyOperatorResourceStatus": schema_openshift_api_operator_v1_MyOperatorResourceStatus(ref), @@ -47701,12 +47703,19 @@ func schema_openshift_api_operator_v1_MachineConfigurationSpec(ref common.Refere Format: "int32", }, }, + "managedBootImageConfig": { + SchemaProps: spec.SchemaProps{ + Description: "managedBootImageConfig contains configuration data for the bootimages management feature", + Default: map[string]interface{}{}, + Ref: ref("github.com/openshift/api/operator/v1.ManagedBootImageConfig"), + }, + }, }, Required: []string{"managementState", "forceRedeploymentReason"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + "github.com/openshift/api/operator/v1.ManagedBootImageConfig", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, } } @@ -47803,6 +47812,67 @@ func schema_openshift_api_operator_v1_MachineConfigurationStatus(ref common.Refe } } +func schema_openshift_api_operator_v1_ManagedBootImageConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ManagedBootImageConfig contains configuration data for the bootimages management feature", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "mode": { + SchemaProps: spec.SchemaProps{ + Description: "mode determines which of the union members should be populated.", + Type: []string{"string"}, + Format: "", + }, + }, + "customConfig": { + SchemaProps: spec.SchemaProps{ + Description: "customConfig provides granular control of the ManagedBootImages feature to the user. Only permitted when mode is set to \"CustomConfig\".", + Ref: ref("github.com/openshift/api/operator/v1.ManagedBootImageConfigCustomization"), + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-unions": []interface{}{ + map[string]interface{}{ + "discriminator": "mode", + "fields-to-discriminateBy": map[string]interface{}{ + "customConfig": "CustomConfig", + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/openshift/api/operator/v1.ManagedBootImageConfigCustomization"}, + } +} + +func schema_openshift_api_operator_v1_ManagedBootImageConfigCustomization(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ManagedBootImageConfigCustomization provides granular control of the ManagedBootImages feature. This object is only permitted when mode is set to \"CustomConfig\".", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "machineSetSelector": { + SchemaProps: spec.SchemaProps{ + Description: "machineSetSelector specifies a label selector for MachinesSets that will be managed by this feature. An empty MachineSetSelector will enroll all MachineSets.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"}, + } +} + func schema_openshift_api_operator_v1_MyOperatorResource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/openapi/openapi.json b/openapi/openapi.json index d0649fb2e49..ce2b90c26b7 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -27931,6 +27931,11 @@ "description": "logLevel is an intent based logging for an overall component. It does not give fine grained control, but it is a simple way to manage coarse grained logging choices that operators have to interpret for their operands.\n\nValid values are: \"Normal\", \"Debug\", \"Trace\", \"TraceAll\". Defaults to \"Normal\".", "type": "string" }, + "managedBootImageConfig": { + "description": "managedBootImageConfig contains configuration data for the bootimages management feature", + "default": {}, + "$ref": "#/definitions/com.github.openshift.api.operator.v1.ManagedBootImageConfig" + }, "managementState": { "description": "managementState indicates whether and how the operator should manage the component", "type": "string", @@ -28013,6 +28018,38 @@ } } }, + "com.github.openshift.api.operator.v1.ManagedBootImageConfig": { + "description": "ManagedBootImageConfig contains configuration data for the bootimages management feature", + "type": "object", + "properties": { + "customConfig": { + "description": "customConfig provides granular control of the ManagedBootImages feature to the user. Only permitted when mode is set to \"CustomConfig\".", + "$ref": "#/definitions/com.github.openshift.api.operator.v1.ManagedBootImageConfigCustomization" + }, + "mode": { + "description": "mode determines which of the union members should be populated.", + "type": "string" + } + }, + "x-kubernetes-unions": [ + { + "discriminator": "mode", + "fields-to-discriminateBy": { + "customConfig": "CustomConfig" + } + } + ] + }, + "com.github.openshift.api.operator.v1.ManagedBootImageConfigCustomization": { + "description": "ManagedBootImageConfigCustomization provides granular control of the ManagedBootImages feature. This object is only permitted when mode is set to \"CustomConfig\".", + "type": "object", + "properties": { + "machineSetSelector": { + "description": "machineSetSelector specifies a label selector for MachinesSets that will be managed by this feature. An empty MachineSetSelector will enroll all MachineSets.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + } + } + }, "com.github.openshift.api.operator.v1.MyOperatorResource": { "description": "MyOperatorResource is an example operator configuration type\n\nCompatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.", "type": "object", diff --git a/operator/v1/0000_80_machine-config-operator_01_config.crd.yaml b/operator/v1/0000_80_machine-config-operator_01_config.crd.yaml index 61ef7740e7a..ee283be28e9 100644 --- a/operator/v1/0000_80_machine-config-operator_01_config.crd.yaml +++ b/operator/v1/0000_80_machine-config-operator_01_config.crd.yaml @@ -52,6 +52,57 @@ spec: - Debug - Trace - TraceAll + managedBootImageConfig: + description: managedBootImageConfig contains configuration data for the bootimages management feature + type: object + required: + - mode + properties: + customConfig: + description: customConfig provides granular control of the ManagedBootImages feature to the user. Only permitted when mode is set to "CustomConfig". + type: object + properties: + machineSetSelector: + description: machineSetSelector specifies a label selector for MachinesSets that will be managed by this feature. An empty MachineSetSelector will enroll all MachineSets. + type: object + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + type: array + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + type: object + required: + - key + - operator + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + type: array + items: + type: string + matchLabels: + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + additionalProperties: + type: string + x-kubernetes-map-type: atomic + mode: + description: mode determines which of the union members should be populated. + type: string + enum: + - Enabled + - Disabled + - CustomConfig + x-kubernetes-validations: + - rule: 'has(self.mode) && self.mode == ''CustomConfig'' ? has(self.customConfig) : !has(self.customConfig)' + message: customConfig is required when type is CustomConfig, and forbidden otherwise managementState: description: managementState indicates whether and how the operator should manage the component type: string diff --git a/operator/v1/types_machineconfiguration.go b/operator/v1/types_machineconfiguration.go index 8651e89a725..f2aea928ca1 100644 --- a/operator/v1/types_machineconfiguration.go +++ b/operator/v1/types_machineconfiguration.go @@ -32,6 +32,10 @@ type MachineConfigurationSpec struct { StaticPodOperatorSpec `json:",inline"` // TODO(jkyros): This is where we put our knobs and dials + + // managedBootImageConfig contains configuration data for the bootimages management feature + // +optional + ManagedBootImageConfig ManagedBootImageConfig `json:"managedBootImageConfig,omitempty"` } type MachineConfigurationStatus struct { @@ -56,3 +60,42 @@ type MachineConfigurationList struct { // Items contains the items Items []MachineConfiguration `json:"items"` } + +// ManagedBootImageConfig contains configuration data for the bootimages management feature +// +kubebuilder:validation:XValidation:rule="has(self.mode) && self.mode == 'CustomConfig' ? has(self.customConfig) : !has(self.customConfig)",message="customConfig is required when type is CustomConfig, and forbidden otherwise" +// +union +type ManagedBootImageConfig struct { + // mode determines which of the union members should be populated. + // +unionDiscriminator + // +kubebuilder:validation:Required + Mode ManagedBootImageConfigMode `json:"mode,omitempty"` + + // customConfig provides granular control of the ManagedBootImages feature to the user. + // Only permitted when mode is set to "CustomConfig". + // +optional + CustomConfig *ManagedBootImageConfigCustomization `json:"customConfig,omitempty"` +} + +// ManagedBootImageMode is a union discriminator for ManagedBootImageConfig. +// +kubebuilder:validation:Enum:="Enabled";"Disabled";"CustomConfig" +type ManagedBootImageConfigMode string + +const ( + // Enabled represents an operator that will manage all machinesets. + Enabled ManagedBootImageConfigMode = "Enabled" + + // Disabled represents an operator that will not manage any machinesets. + Disabled ManagedBootImageConfigMode = "Disabled" + + // CustomConfig represents an operator that will manage machinesets specified by a ManagedBootImageConfigCustomization object. + CustomConfig ManagedBootImageConfigMode = "CustomConfig" +) + +// ManagedBootImageConfigCustomization provides granular control of the ManagedBootImages feature. +// This object is only permitted when mode is set to "CustomConfig". +type ManagedBootImageConfigCustomization struct { + // machineSetSelector specifies a label selector for MachinesSets that will be managed by this feature. + // An empty MachineSetSelector will enroll all MachineSets. + // +optional + MachineSetSelector *metav1.LabelSelector `json:"machineSetSelector,omitempty"` +} diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go index 290dd2f3a67..349a65e6f1f 100644 --- a/operator/v1/zz_generated.deepcopy.go +++ b/operator/v1/zz_generated.deepcopy.go @@ -2976,6 +2976,7 @@ func (in *MachineConfigurationList) DeepCopyObject() runtime.Object { func (in *MachineConfigurationSpec) DeepCopyInto(out *MachineConfigurationSpec) { *out = *in in.StaticPodOperatorSpec.DeepCopyInto(&out.StaticPodOperatorSpec) + in.ManagedBootImageConfig.DeepCopyInto(&out.ManagedBootImageConfig) return } @@ -3006,6 +3007,48 @@ func (in *MachineConfigurationStatus) DeepCopy() *MachineConfigurationStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManagedBootImageConfig) DeepCopyInto(out *ManagedBootImageConfig) { + *out = *in + if in.CustomConfig != nil { + in, out := &in.CustomConfig, &out.CustomConfig + *out = new(ManagedBootImageConfigCustomization) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedBootImageConfig. +func (in *ManagedBootImageConfig) DeepCopy() *ManagedBootImageConfig { + if in == nil { + return nil + } + out := new(ManagedBootImageConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManagedBootImageConfigCustomization) DeepCopyInto(out *ManagedBootImageConfigCustomization) { + *out = *in + if in.MachineSetSelector != nil { + in, out := &in.MachineSetSelector, &out.MachineSetSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedBootImageConfigCustomization. +func (in *ManagedBootImageConfigCustomization) DeepCopy() *ManagedBootImageConfigCustomization { + if in == nil { + return nil + } + out := new(ManagedBootImageConfigCustomization) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MyOperatorResource) DeepCopyInto(out *MyOperatorResource) { *out = *in diff --git a/operator/v1/zz_generated.swagger_doc_generated.go b/operator/v1/zz_generated.swagger_doc_generated.go index 544f81e621d..34383ff5d11 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -1274,6 +1274,33 @@ func (MachineConfigurationList) SwaggerDoc() map[string]string { return map_MachineConfigurationList } +var map_MachineConfigurationSpec = map[string]string{ + "managedBootImageConfig": "managedBootImageConfig contains configuration data for the bootimages management feature", +} + +func (MachineConfigurationSpec) SwaggerDoc() map[string]string { + return map_MachineConfigurationSpec +} + +var map_ManagedBootImageConfig = map[string]string{ + "": "ManagedBootImageConfig contains configuration data for the bootimages management feature", + "mode": "mode determines which of the union members should be populated.", + "customConfig": "customConfig provides granular control of the ManagedBootImages feature to the user. Only permitted when mode is set to \"CustomConfig\".", +} + +func (ManagedBootImageConfig) SwaggerDoc() map[string]string { + return map_ManagedBootImageConfig +} + +var map_ManagedBootImageConfigCustomization = map[string]string{ + "": "ManagedBootImageConfigCustomization provides granular control of the ManagedBootImages feature. This object is only permitted when mode is set to \"CustomConfig\".", + "machineSetSelector": "machineSetSelector specifies a label selector for MachinesSets that will be managed by this feature. An empty MachineSetSelector will enroll all MachineSets.", +} + +func (ManagedBootImageConfigCustomization) SwaggerDoc() map[string]string { + return map_ManagedBootImageConfigCustomization +} + var map_AdditionalNetworkDefinition = map[string]string{ "": "AdditionalNetworkDefinition configures an extra network that is available but not created by default. Instead, pods must request them by name. type must be specified, along with exactly one \"Config\" that matches the type.", "type": "type is the type of network The supported values are NetworkTypeRaw, NetworkTypeSimpleMacvlan",