Skip to content

Commit

Permalink
Update list of gatherers config and some validations
Browse files Browse the repository at this point in the history
  • Loading branch information
tremes committed Feb 17, 2023
1 parent 8d8b668 commit ba54f25
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 23 deletions.
21 changes: 17 additions & 4 deletions insights/v1alpha1/0000_10_01_datagather.crd.yaml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 19 additions & 5 deletions insights/v1alpha1/types_insights.go
Expand Up @@ -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 (
Expand All @@ -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.
Expand Down
22 changes: 19 additions & 3 deletions insights/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions insights/v1alpha1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 37 additions & 5 deletions openapi/generated_openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 24 additions & 4 deletions openapi/openapi.json
Expand Up @@ -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"
}
}
}
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit ba54f25

Please sign in to comment.