From 16887119defa7f2a8a347c9861229fc94fc67ba5 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 28 Nov 2023 15:23:05 -0500 Subject: [PATCH] add boot images update opt-in & mcp degrade type --- machineconfiguration/v1/types.go | 3 ++ .../generated_openapi/zz_generated.openapi.go | 50 ++++++++++++++++++- openapi/openapi.json | 27 ++++++++++ ...machine-config-operator_01_config.crd.yaml | 44 ++++++++++++++++ operator/v1/types_machineconfiguration.go | 22 ++++++++ operator/v1/zz_generated.deepcopy.go | 22 ++++++++ .../v1/zz_generated.swagger_doc_generated.go | 18 +++++++ 7 files changed, 185 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..50c8360357b 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -940,6 +940,7 @@ 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.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 +47702,19 @@ func schema_openshift_api_operator_v1_MachineConfigurationSpec(ref common.Refere Format: "int32", }, }, + "managedBootImageConfig": { + SchemaProps: spec.SchemaProps{ + Description: "managedBootImageConfigData 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 +47811,46 @@ 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 has three settings: enabled - MCO will manage all machinesets matchSelector - MCO will manage machinesets that match with the label selector disabled - MCO will not manage any machinesets If unset, mode will default to disabled", + Type: []string{"string"}, + Format: "", + }, + }, + "matchSelector": { + SchemaProps: spec.SchemaProps{ + Description: "matchSelector specifies a label selector for MachinesSets that will be managed by this mechanism", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"), + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-unions": []interface{}{ + map[string]interface{}{ + "discriminator": "mode", + "fields-to-discriminateBy": map[string]interface{}{ + "matchSelector": "MatchSelector", + }, + }, + }, + }, + }, + }, + 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..0c8663d0296 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": "managedBootImageConfigData 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,28 @@ } } }, + "com.github.openshift.api.operator.v1.ManagedBootImageConfig": { + "description": "ManagedBootImageConfig contains configuration data for the bootimages management feature", + "type": "object", + "properties": { + "matchSelector": { + "description": "matchSelector specifies a label selector for MachinesSets that will be managed by this mechanism", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "mode": { + "description": "mode has three settings: enabled - MCO will manage all machinesets matchSelector - MCO will manage machinesets that match with the label selector disabled - MCO will not manage any machinesets If unset, mode will default to disabled", + "type": "string" + } + }, + "x-kubernetes-unions": [ + { + "discriminator": "mode", + "fields-to-discriminateBy": { + "matchSelector": "MatchSelector" + } + } + ] + }, "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..cfc4747fdd0 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,50 @@ spec: - Debug - Trace - TraceAll + managedBootImageConfig: + description: managedBootImageConfigData contains configuration data for the bootimages management feature + type: object + required: + - mode + properties: + matchSelector: + description: matchSelector specifies a label selector for MachinesSets that will be managed by this mechanism + 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 has three settings: enabled - MCO will manage all machinesets matchSelector - MCO will manage machinesets that match with the label selector disabled - MCO will not manage any machinesets If unset, mode will default to disabled' + type: string + enum: + - Enabled + - Selected + - MatchSelector 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..0ef25a327ed 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 + + // managedBootImageConfigData contains configuration data for the bootimages management feature + // +optional + ManagedBootImageConfig ManagedBootImageConfig `json:"managedBootImageConfig,omitempty"` } type MachineConfigurationStatus struct { @@ -56,3 +60,21 @@ type MachineConfigurationList struct { // Items contains the items Items []MachineConfiguration `json:"items"` } + +// ManagedBootImageConfig contains configuration data for the bootimages management feature +// +union +type ManagedBootImageConfig struct { + // mode has three settings: + // enabled - MCO will manage all machinesets + // matchSelector - MCO will manage machinesets that match with the label selector + // disabled - MCO will not manage any machinesets + // If unset, mode will default to disabled + // +unionDiscriminator + // +kubebuilder:validation:Enum:="Enabled";"Selected";"MatchSelector" + // +kubebuilder:validation:Required + Mode string `json:"mode,omitempty"` + + // matchSelector specifies a label selector for MachinesSets that will be managed by this mechanism + // +optional + MatchSelector *metav1.LabelSelector `json:"matchSelector,omitempty"` +} diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go index 290dd2f3a67..cd60ee02ddd 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,27 @@ 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.MatchSelector != nil { + in, out := &in.MatchSelector, &out.MatchSelector + *out = new(metav1.LabelSelector) + (*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 *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..2d3b0cac002 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -1274,6 +1274,24 @@ func (MachineConfigurationList) SwaggerDoc() map[string]string { return map_MachineConfigurationList } +var map_MachineConfigurationSpec = map[string]string{ + "managedBootImageConfig": "managedBootImageConfigData 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 has three settings: enabled - MCO will manage all machinesets matchSelector - MCO will manage machinesets that match with the label selector disabled - MCO will not manage any machinesets If unset, mode will default to disabled", + "matchSelector": "matchSelector specifies a label selector for MachinesSets that will be managed by this mechanism", +} + +func (ManagedBootImageConfig) SwaggerDoc() map[string]string { + return map_ManagedBootImageConfig +} + 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",