From ba54f2573697011c21bb793f33ba03be1515e210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Reme=C5=A1?= Date: Fri, 17 Feb 2023 09:10:53 +0100 Subject: [PATCH] Update list of gatherers config and some validations --- .../v1alpha1/0000_10_01_datagather.crd.yaml | 21 ++++++++-- insights/v1alpha1/types_insights.go | 24 ++++++++--- insights/v1alpha1/zz_generated.deepcopy.go | 22 ++++++++-- .../zz_generated.swagger_doc_generated.go | 14 ++++++- .../generated_openapi/zz_generated.openapi.go | 42 ++++++++++++++++--- openapi/openapi.json | 28 +++++++++++-- 6 files changed, 128 insertions(+), 23 deletions(-) diff --git a/insights/v1alpha1/0000_10_01_datagather.crd.yaml b/insights/v1alpha1/0000_10_01_datagather.crd.yaml index 5ac2fd77896..3bf1501b01d 100644 --- a/insights/v1alpha1/0000_10_01_datagather.crd.yaml +++ b/insights/v1alpha1/0000_10_01_datagather.crd.yaml @@ -57,11 +57,24 @@ spec: - "" - ClearText - ObfuscateNetworking - disabledGatherers: - description: 'disabledGatherers is a list of gatherers to be excluded from the gathering. All the gatherers can be disabled by providing "all" value. If all the gatherers are disabled, the Insights operator does not gather any data. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: "oc get insightsoperators.operator.openshift.io cluster -o json | jq ''.status.gatherStatus.gatherers[].name''" An example of disabling gatherers looks like this: `disabledGatherers: ["clusterconfig/machine_configs", "workloads/workload_info"]`' + gatherersConfig: + description: 'gatherersConfig is a list of gatherers configurations. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: "oc get insightsoperators.operator.openshift.io cluster -o json | jq ''.status.gatherStatus.gatherers[].name''"' type: array items: - type: string + description: gathererConfig allows to configure specific gatherers + type: object + required: + - name + - state + properties: + name: + description: name is the name of specific gatherer + type: string + state: + description: state allows you to disable specific gatherer + type: string + enum: + - Disabled status: description: status holds observed values from the cluster. They may not be overridden. type: object @@ -284,7 +297,7 @@ spec: - rule: self == oldSelf message: startTime is immutable once set x-kubernetes-validations: - - rule: '!has(oldSelf.insightsRequestID) || has(self.insightsRequestID) && !has(oldSelf.startTime) || has(self.startTime) && !has(oldSelf.finishTime) || has(self.finishTime)' + - rule: (!has(oldSelf.insightsRequestID) || has(self.insightsRequestID)) && (!has(oldSelf.startTime) || has(self.startTime)) && (!has(oldSelf.finishTime) || has(self.finishTime)) && (!has(oldSelf.dataGatherState) || has(self.dataGatherState)) message: cannot remove attributes from status served: true storage: true diff --git a/insights/v1alpha1/types_insights.go b/insights/v1alpha1/types_insights.go index 7e52885df30..1504b029997 100644 --- a/insights/v1alpha1/types_insights.go +++ b/insights/v1alpha1/types_insights.go @@ -33,14 +33,12 @@ type DataGatherSpec struct { // The current default is ClearText. // +optional DataPolicy DataPolicy `json:"dataPolicy"` - // disabledGatherers is a list of gatherers to be excluded from the gathering. All the gatherers can be disabled by providing "all" value. - // If all the gatherers are disabled, the Insights operator does not gather any data. + // gatherersConfig is a list of gatherers configurations. // The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. // Run the following command to get the names of last active gatherers: // "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'" - // An example of disabling gatherers looks like this: `disabledGatherers: ["clusterconfig/machine_configs", "workloads/workload_info"]` // +optional - DisabledGatherers []string `json:"disabledGatherers"` + GatherersConfig []GathererConfig `json:"gatherersConfig"` } const ( @@ -56,19 +54,35 @@ const ( Failed DataGatherState = "Failed" // Data gathering is pending Pending DataGatherState = "Pending" + // Gatherer state marked as disabled, which means that the gatherer will not run. + Disabled GathererState = "Disabled" ) // dataPolicy declares valid data policy types // +kubebuilder:validation:Enum="";ClearText;ObfuscateNetworking type DataPolicy string +// state declares valid gatherer state types +// +kubebuilder:validation:Enum=Disabled +type GathererState string + +// gathererConfig allows to configure specific gatherers +type GathererConfig struct { + // name is the name of specific gatherer + // +kubebuilder:validation:Required + Name string `json:"name"` + // state allows you to disable specific gatherer + // +kubebuilder:validation:Required + State GathererState `json:"state"` +} + // dataGatherState declares valid gathering state types // +kubebuilder:validation:Optional // +kubebuilder:validation:Enum=Running;Completed;Failed;Pending // +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Running' && self == 'Pending') && !(oldSelf == 'Completed' && self == 'Pending') && !(oldSelf == 'Failed' && self == 'Pending') && !(oldSelf == 'Completed' && self == 'Running') && !(oldSelf == 'Failed' && self == 'Running')", message="state cannot be changed backwards" type DataGatherState string -// +kubebuilder:validation:XValidation:rule="!has(oldSelf.insightsRequestID) || has(self.insightsRequestID) && !has(oldSelf.startTime) || has(self.startTime) && !has(oldSelf.finishTime) || has(self.finishTime)",message="cannot remove attributes from status" +// +kubebuilder:validation:XValidation:rule="(!has(oldSelf.insightsRequestID) || has(self.insightsRequestID)) && (!has(oldSelf.startTime) || has(self.startTime)) && (!has(oldSelf.finishTime) || has(self.finishTime)) && (!has(oldSelf.dataGatherState) || has(self.dataGatherState))",message="cannot remove attributes from status" // +kubebuilder:validation:Optional type DataGatherStatus struct { // conditions provide details on the status of the gatherer job. diff --git a/insights/v1alpha1/zz_generated.deepcopy.go b/insights/v1alpha1/zz_generated.deepcopy.go index de62e74cf29..f9bc1c32a8d 100644 --- a/insights/v1alpha1/zz_generated.deepcopy.go +++ b/insights/v1alpha1/zz_generated.deepcopy.go @@ -74,9 +74,9 @@ func (in *DataGatherList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DataGatherSpec) DeepCopyInto(out *DataGatherSpec) { *out = *in - if in.DisabledGatherers != nil { - in, out := &in.DisabledGatherers, &out.DisabledGatherers - *out = make([]string, len(*in)) + if in.GatherersConfig != nil { + in, out := &in.GatherersConfig, &out.GatherersConfig + *out = make([]GathererConfig, len(*in)) copy(*out, *in) } return @@ -130,6 +130,22 @@ func (in *DataGatherStatus) DeepCopy() *DataGatherStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GathererConfig) DeepCopyInto(out *GathererConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GathererConfig. +func (in *GathererConfig) DeepCopy() *GathererConfig { + if in == nil { + return nil + } + out := new(GathererConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GathererStatus) DeepCopyInto(out *GathererStatus) { *out = *in diff --git a/insights/v1alpha1/zz_generated.swagger_doc_generated.go b/insights/v1alpha1/zz_generated.swagger_doc_generated.go index 761212d9acc..407f6ec1d95 100644 --- a/insights/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/insights/v1alpha1/zz_generated.swagger_doc_generated.go @@ -30,8 +30,8 @@ func (DataGatherList) SwaggerDoc() map[string]string { } var map_DataGatherSpec = map[string]string{ - "dataPolicy": "dataPolicy allows user to enable additional global obfuscation of the IP addresses and base domain in the Insights archive data. Valid values are \"ClearText\" and \"ObfuscateNetworking\". When set to ClearText the data is not obfuscated. When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated. When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time. The current default is ClearText.", - "disabledGatherers": "disabledGatherers is a list of gatherers to be excluded from the gathering. All the gatherers can be disabled by providing \"all\" value. If all the gatherers are disabled, the Insights operator does not gather any data. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: \"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'\" An example of disabling gatherers looks like this: `disabledGatherers: [\"clusterconfig/machine_configs\", \"workloads/workload_info\"]`", + "dataPolicy": "dataPolicy allows user to enable additional global obfuscation of the IP addresses and base domain in the Insights archive data. Valid values are \"ClearText\" and \"ObfuscateNetworking\". When set to ClearText the data is not obfuscated. When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated. When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time. The current default is ClearText.", + "gatherersConfig": "gatherersConfig is a list of gatherers configurations. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: \"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'\"", } func (DataGatherSpec) SwaggerDoc() map[string]string { @@ -53,6 +53,16 @@ func (DataGatherStatus) SwaggerDoc() map[string]string { return map_DataGatherStatus } +var map_GathererConfig = map[string]string{ + "": "gathererConfig allows to configure specific gatherers", + "name": "name is the name of specific gatherer", + "state": "state allows you to disable specific gatherer", +} + +func (GathererConfig) SwaggerDoc() map[string]string { + return map_GathererConfig +} + var map_GathererStatus = map[string]string{ "": "gathererStatus represents information about a particular data gatherer.", "conditions": "conditions provide details on the status of each gatherer.", diff --git a/openapi/generated_openapi/zz_generated.openapi.go b/openapi/generated_openapi/zz_generated.openapi.go index c22e00ffe93..00cf5101123 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -472,6 +472,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/openshift/api/insights/v1alpha1.DataGatherList": schema_openshift_api_insights_v1alpha1_DataGatherList(ref), "github.com/openshift/api/insights/v1alpha1.DataGatherSpec": schema_openshift_api_insights_v1alpha1_DataGatherSpec(ref), "github.com/openshift/api/insights/v1alpha1.DataGatherStatus": schema_openshift_api_insights_v1alpha1_DataGatherStatus(ref), + "github.com/openshift/api/insights/v1alpha1.GathererConfig": schema_openshift_api_insights_v1alpha1_GathererConfig(ref), "github.com/openshift/api/insights/v1alpha1.GathererStatus": schema_openshift_api_insights_v1alpha1_GathererStatus(ref), "github.com/openshift/api/insights/v1alpha1.HealthCheck": schema_openshift_api_insights_v1alpha1_HealthCheck(ref), "github.com/openshift/api/insights/v1alpha1.InsightsReport": schema_openshift_api_insights_v1alpha1_InsightsReport(ref), @@ -22570,16 +22571,15 @@ func schema_openshift_api_insights_v1alpha1_DataGatherSpec(ref common.ReferenceC Format: "", }, }, - "disabledGatherers": { + "gatherersConfig": { SchemaProps: spec.SchemaProps{ - Description: "disabledGatherers is a list of gatherers to be excluded from the gathering. All the gatherers can be disabled by providing \"all\" value. If all the gatherers are disabled, the Insights operator does not gather any data. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: \"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'\" An example of disabling gatherers looks like this: `disabledGatherers: [\"clusterconfig/machine_configs\", \"workloads/workload_info\"]`", + Description: "gatherersConfig is a list of gatherers configurations. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: \"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'\"", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Default: map[string]interface{}{}, + Ref: ref("github.com/openshift/api/insights/v1alpha1.GathererConfig"), }, }, }, @@ -22588,6 +22588,8 @@ func schema_openshift_api_insights_v1alpha1_DataGatherSpec(ref common.ReferenceC }, }, }, + Dependencies: []string{ + "github.com/openshift/api/insights/v1alpha1.GathererConfig"}, } } @@ -22700,6 +22702,36 @@ func schema_openshift_api_insights_v1alpha1_DataGatherStatus(ref common.Referenc } } +func schema_openshift_api_insights_v1alpha1_GathererConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "gathererConfig allows to configure specific gatherers", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the name of specific gatherer", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "state": { + SchemaProps: spec.SchemaProps{ + Description: "state allows you to disable specific gatherer", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "state"}, + }, + }, + } +} + func schema_openshift_api_insights_v1alpha1_GathererStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/openapi/openapi.json b/openapi/openapi.json index 8c66fe3718b..3e9057e7a9a 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -12651,12 +12651,12 @@ "type": "string", "default": "" }, - "disabledGatherers": { - "description": "disabledGatherers is a list of gatherers to be excluded from the gathering. All the gatherers can be disabled by providing \"all\" value. If all the gatherers are disabled, the Insights operator does not gather any data. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: \"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'\" An example of disabling gatherers looks like this: `disabledGatherers: [\"clusterconfig/machine_configs\", \"workloads/workload_info\"]`", + "gatherersConfig": { + "description": "gatherersConfig is a list of gatherers configurations. The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. Run the following command to get the names of last active gatherers: \"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'\"", "type": "array", "items": { - "type": "string", - "default": "" + "default": {}, + "$ref": "#/definitions/com.github.openshift.api.insights.v1alpha1.GathererConfig" } } } @@ -12723,6 +12723,26 @@ } } }, + "com.github.openshift.api.insights.v1alpha1.GathererConfig": { + "description": "gathererConfig allows to configure specific gatherers", + "type": "object", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "description": "name is the name of specific gatherer", + "type": "string", + "default": "" + }, + "state": { + "description": "state allows you to disable specific gatherer", + "type": "string", + "default": "" + } + } + }, "com.github.openshift.api.insights.v1alpha1.GathererStatus": { "description": "gathererStatus represents information about a particular data gatherer.", "type": "object",