Skip to content

Commit cce4ef9

Browse files
committed
feat: align DataGather with InsightsDataGather
This commit aligns the configuration options of the DataGather CRD with those of InsightsDataGather, making it easier to use both CRDs. Signed-off-by: Ondrej Pokorny <[email protected]>
1 parent bb4323d commit cce4ef9

File tree

10 files changed

+829
-332
lines changed

10 files changed

+829
-332
lines changed

insights/v1alpha2/tests/datagathers.insights.openshift.io/InsightsOnDemandDataGather.yaml

+148-60
Large diffs are not rendered by default.

insights/v1alpha2/types_insights.go

+93-43
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,70 @@ type DataGather struct {
3737

3838
// DataGatherSpec contains the configuration for the DataGather.
3939
type DataGatherSpec struct {
40-
// dataPolicy allows user to enable additional global obfuscation of the IP addresses and base domain
41-
// in the Insights archive data. Valid values are "ClearText" and "ObfuscateNetworking".
42-
// When set to ClearText the data is not obfuscated.
40+
// dataPolicy is an optional list of DataPolicyOptions that allows user to enable additional obfuscation of the Insights archive data.
41+
// It may not exceed 2 items and must not contain duplicates.
42+
// Valid values are ObfuscateNetworking and WorkloadNames.
4343
// When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated.
44-
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
45-
// The current default is ClearText.
44+
// When set to WorkloadNames, the gathered data about cluster resources will not contain the workload names for your deployments. Resources UIDs will be used instead.
45+
// When omitted no obfuscation is applied.
46+
// +kubebuilder:validation:MaxItems=2
47+
// +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, x == y))",message="dataPolicy items must be unique"
48+
// +listType=atomic
4649
// +optional
47-
DataPolicy DataPolicy `json:"dataPolicy"`
48-
// gatherers is an optional list of gatherers configurations.
49-
// The list must not exceed 100 items.
50-
// The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
51-
// Run the following command to get the names of last active gatherers:
52-
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
53-
// +kubebuilder:validation:MaxItems=100
50+
DataPolicy []DataPolicyOption `json:"dataPolicy"`
51+
// gatherers is an optional field that specifies the configuration of the gatherers.
5452
// +optional
55-
Gatherers []GathererConfig `json:"gatherers,omitempty"`
53+
Gatherers Gatherers `json:"gatherers,omitempty"`
5654
// storage is an optional field that allows user to define persistent storage for gathering jobs to store the Insights data archive.
5755
// If omitted, the gathering job will use ephemeral storage.
5856
// +optional
5957
Storage *Storage `json:"storage,omitempty"`
6058
}
6159

60+
// +kubebuilder:validation:XValidation:rule="has(self.mode) && self.mode == 'Custom' ? has(self.custom) : !has(self.custom)",message="custom is required when mode is Custom, and forbidden otherwise"
61+
type Gatherers struct {
62+
// mode is a required field that specifies the mode for gatherers. Allowed values are All, None, and Custom.
63+
// When set to All, all gatherers wil run and gather data.
64+
// When set to None, all gatherers will be disabled and no data will be gathered.
65+
// When set to Custom, the custom configuration from the custom field will be applied.
66+
// +required
67+
Mode GatheringMode `json:"mode"`
68+
// custom provides gathering configuration.
69+
// It is required when mode is Custom, and forbidden otherwise.
70+
// Custom configuration allows user to disable only a subset of gatherers.
71+
// Gatherers that are not explicitly disabled in custom configuration will run.
72+
// +optional
73+
Custom *Custom `json:"custom,omitempty"`
74+
}
75+
76+
// custom provides the custom configuration of gatherers
77+
type Custom struct {
78+
// configs is a required list of gatherers configurations that can be used to enable or disable specific gatherers.
79+
// It may not exceed 100 items and each gatherer can be present only once.
80+
// It is possible to disable an entire set of gatherers while allowing a specific function within that set.
81+
// The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
82+
// Run the following command to get the names of last active gatherers:
83+
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
84+
// +kubebuilder:validation:MaxItems=100
85+
// +listType=map
86+
// +listMapKey=name
87+
// +required
88+
Configs []GathererConfig `json:"configs"`
89+
}
90+
91+
// gatheringMode defines the valid gathering modes.
92+
// +kubebuilder:validation:Enum=All;None;Custom
93+
type GatheringMode string
94+
95+
const (
96+
// Enabled enables all gatherers
97+
GatheringModeAll GatheringMode = "All"
98+
// Disabled disables all gatherers
99+
GatheringModeNone GatheringMode = "None"
100+
// Custom applies the configuration from GatheringConfig.
101+
GatheringModeCustom GatheringMode = "Custom"
102+
)
103+
62104
// storage provides persistent storage configuration options for gathering jobs.
63105
// If the type is set to PersistentVolume, then the PersistentVolume must be defined.
64106
// If the type is set to Ephemeral, then the PersistentVolume must not be defined.
@@ -114,52 +156,49 @@ type PersistentVolumeClaimReference struct {
114156
Name string `json:"name"`
115157
}
116158

159+
// dataPolicyOption declares valid data policy types
160+
// +kubebuilder:validation:Enum=ObfuscateNetworking;WorkloadNames
161+
type DataPolicyOption string
162+
117163
const (
118-
// No data obfuscation
119-
NoPolicy DataPolicy = "ClearText"
120164
// IP addresses and cluster domain name are obfuscated
121-
ObfuscateNetworking DataPolicy = "ObfuscateNetworking"
122-
// Data gathering is running
123-
Running DataGatherState = "Running"
124-
// Data gathering is completed
125-
Completed DataGatherState = "Completed"
126-
// Data gathering failed
127-
Failed DataGatherState = "Failed"
128-
// Data gathering is pending
129-
Pending DataGatherState = "Pending"
130-
// Gatherer state marked as disabled, which means that the gatherer will not run.
131-
Disabled GathererState = "Disabled"
132-
// Gatherer state marked as enabled, which means that the gatherer will run.
133-
Enabled GathererState = "Enabled"
165+
DataPolicyOptionObfuscateNetworking DataPolicyOption = "ObfuscateNetworking"
166+
// Data from Deployment Validation Operator are obfuscated
167+
DataPolicyOptionObfuscateWorkloadNames DataPolicyOption = "WorkloadNames"
134168
)
135169

136-
// dataPolicy declares valid data policy types
137-
// +kubebuilder:validation:Enum="";ClearText;ObfuscateNetworking
138-
type DataPolicy string
139-
140-
// state declares valid gatherer state types.
141-
// +kubebuilder:validation:Enum="";Enabled;Disabled
142-
type GathererState string
143-
144170
// gathererConfig allows to configure specific gatherers
145171
type GathererConfig struct {
146-
// name is the required name of specific gatherer
147-
// It must be at most 256 characters in length.
148-
// The format for the gatherer name should be: {gatherer}/{function} where the function is optional.
172+
// name is the required name of a specific gatherer
173+
// It may not exceed 256 characters.
174+
// The format for a gatherer name is: {gatherer}/{function} where the function is optional.
149175
// Gatherer consists of a lowercase letters only that may include underscores (_).
150176
// Function consists of a lowercase letters only that may include underscores (_) and is separated from the gatherer by a forward slash (/).
151177
// The particular gatherers can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
178+
// Run the following command to get the names of last active gatherers:
179+
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
152180
// +kubebuilder:validation:MaxLength=256
153181
// +kubebuilder:validation:XValidation:rule=`self.matches("^[a-z]+[_a-z]*[a-z]([/a-z][_a-z]*)?[a-z]$")`,message=`gatherer name must be in the format of {gatherer}/{function} where the gatherer and function are lowercase letters only that may include underscores (_) and are separated by a forward slash (/) if the function is provided`
154182
// +required
155183
Name string `json:"name"`
156-
// state allows you to configure specific gatherer. Valid values are "Enabled", "Disabled" and omitted.
157-
// When omitted, this means no opinion and the platform is left to choose a reasonable default.
158-
// The current default is Enabled.
159-
// +optional
184+
// state is a required field that allows you to configure specific gatherer. Valid values are "Enabled" and "Disabled".
185+
// When set to Enabled the gatherer will run.
186+
// When set to Disabled the gatherer will not run.
187+
// +required
160188
State GathererState `json:"state"`
161189
}
162190

191+
// state declares valid gatherer state types.
192+
// +kubebuilder:validation:Enum=Enabled;Disabled
193+
type GathererState string
194+
195+
const (
196+
// GathererStateEnabled gatherer state, which means that the gatherer will run.
197+
GathererStateEnabled GathererState = "Enabled"
198+
// GathererStateDisabled gatherer state, which means that the gatherer will not run.
199+
GathererStateDisabled GathererState = "Disabled"
200+
)
201+
163202
// dataGatherState declares valid gathering state types
164203
// +kubebuilder:validation:Optional
165204
// +kubebuilder:validation:Enum=Running;Completed;Failed;Pending
@@ -170,6 +209,17 @@ type GathererConfig struct {
170209
// +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Failed' && self == 'Running')", message="dataGatherState cannot transition from Failed to Running"
171210
type DataGatherState string
172211

212+
const (
213+
// Data gathering is running
214+
DataGatherStateRunning DataGatherState = "Running"
215+
// Data gathering is completed
216+
DataGatherStateCompleted DataGatherState = "Completed"
217+
// Data gathering failed
218+
DataGatherStateFailed DataGatherState = "Failed"
219+
// Data gathering is pending
220+
DataGatherStatePending DataGatherState = "Pending"
221+
)
222+
173223
// DataGatherStatus contains information relating to the DataGather state.
174224
// +kubebuilder:validation:XValidation:rule="(!has(oldSelf.insightsRequestID) || has(self.insightsRequestID))",message="cannot remove insightsRequestID attribute from status"
175225
// +kubebuilder:validation:XValidation:rule="(!has(oldSelf.startTime) || has(self.startTime))",message="cannot remove startTime attribute from status"

insights/v1alpha2/zz_generated.crd-manifests/0000_10_insights_01_datagathers-CustomNoUpgrade.crd.yaml

+95-49
Original file line numberDiff line numberDiff line change
@@ -60,58 +60,104 @@ spec:
6060
properties:
6161
dataPolicy:
6262
description: |-
63-
dataPolicy allows user to enable additional global obfuscation of the IP addresses and base domain
64-
in the Insights archive data. Valid values are "ClearText" and "ObfuscateNetworking".
65-
When set to ClearText the data is not obfuscated.
63+
dataPolicy is an optional list of DataPolicyOptions that allows user to enable additional obfuscation of the Insights archive data.
64+
It may not exceed 2 items and must not contain duplicates.
65+
Valid values are ObfuscateNetworking and WorkloadNames.
6666
When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated.
67-
When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
68-
The current default is ClearText.
69-
enum:
70-
- ""
71-
- ClearText
72-
- ObfuscateNetworking
73-
type: string
74-
gatherers:
75-
description: |-
76-
gatherers is an optional list of gatherers configurations.
77-
The list must not exceed 100 items.
78-
The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
79-
Run the following command to get the names of last active gatherers:
80-
"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
67+
When set to WorkloadNames, the gathered data about cluster resources will not contain the workload names for your deployments. Resources UIDs will be used instead.
68+
When omitted no obfuscation is applied.
8169
items:
82-
description: gathererConfig allows to configure specific gatherers
83-
properties:
84-
name:
85-
description: |-
86-
name is the required name of specific gatherer
87-
It must be at most 256 characters in length.
88-
The format for the gatherer name should be: {gatherer}/{function} where the function is optional.
89-
Gatherer consists of a lowercase letters only that may include underscores (_).
90-
Function consists of a lowercase letters only that may include underscores (_) and is separated from the gatherer by a forward slash (/).
91-
The particular gatherers can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
92-
maxLength: 256
93-
type: string
94-
x-kubernetes-validations:
95-
- message: gatherer name must be in the format of {gatherer}/{function}
96-
where the gatherer and function are lowercase letters only
97-
that may include underscores (_) and are separated by a
98-
forward slash (/) if the function is provided
99-
rule: self.matches("^[a-z]+[_a-z]*[a-z]([/a-z][_a-z]*)?[a-z]$")
100-
state:
101-
description: |-
102-
state allows you to configure specific gatherer. Valid values are "Enabled", "Disabled" and omitted.
103-
When omitted, this means no opinion and the platform is left to choose a reasonable default.
104-
The current default is Enabled.
105-
enum:
106-
- ""
107-
- Enabled
108-
- Disabled
109-
type: string
110-
required:
111-
- name
112-
type: object
113-
maxItems: 100
70+
description: dataPolicyOption declares valid data policy types
71+
enum:
72+
- ObfuscateNetworking
73+
- WorkloadNames
74+
type: string
75+
maxItems: 2
11476
type: array
77+
x-kubernetes-list-type: atomic
78+
x-kubernetes-validations:
79+
- message: dataPolicy items must be unique
80+
rule: self.all(x, self.exists_one(y, x == y))
81+
gatherers:
82+
description: gatherers is an optional field that specifies the configuration
83+
of the gatherers.
84+
properties:
85+
custom:
86+
description: |-
87+
custom provides gathering configuration.
88+
It is required when mode is Custom, and forbidden otherwise.
89+
Custom configuration allows user to disable only a subset of gatherers.
90+
Gatherers that are not explicitly disabled in custom configuration will run.
91+
properties:
92+
configs:
93+
description: |-
94+
configs is a required list of gatherers configurations that can be used to enable or disable specific gatherers.
95+
It may not exceed 100 items and each gatherer can be present only once.
96+
It is possible to disable an entire set of gatherers while allowing a specific function within that set.
97+
The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
98+
Run the following command to get the names of last active gatherers:
99+
"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
100+
items:
101+
description: gathererConfig allows to configure specific
102+
gatherers
103+
properties:
104+
name:
105+
description: |-
106+
name is the required name of a specific gatherer
107+
It may not exceed 256 characters.
108+
The format for a gatherer name is: {gatherer}/{function} where the function is optional.
109+
Gatherer consists of a lowercase letters only that may include underscores (_).
110+
Function consists of a lowercase letters only that may include underscores (_) and is separated from the gatherer by a forward slash (/).
111+
The particular gatherers can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
112+
Run the following command to get the names of last active gatherers:
113+
"oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
114+
maxLength: 256
115+
type: string
116+
x-kubernetes-validations:
117+
- message: gatherer name must be in the format of {gatherer}/{function}
118+
where the gatherer and function are lowercase letters
119+
only that may include underscores (_) and are separated
120+
by a forward slash (/) if the function is provided
121+
rule: self.matches("^[a-z]+[_a-z]*[a-z]([/a-z][_a-z]*)?[a-z]$")
122+
state:
123+
description: |-
124+
state is a required field that allows you to configure specific gatherer. Valid values are "Enabled" and "Disabled".
125+
When set to Enabled the gatherer will run.
126+
When set to Disabled the gatherer will not run.
127+
enum:
128+
- Enabled
129+
- Disabled
130+
type: string
131+
required:
132+
- name
133+
- state
134+
type: object
135+
maxItems: 100
136+
type: array
137+
x-kubernetes-list-map-keys:
138+
- name
139+
x-kubernetes-list-type: map
140+
required:
141+
- configs
142+
type: object
143+
mode:
144+
description: |-
145+
mode is a required field that specifies the mode for gatherers. Allowed values are All, None, and Custom.
146+
When set to All, all gatherers wil run and gather data.
147+
When set to None, all gatherers will be disabled and no data will be gathered.
148+
When set to Custom, the custom configuration from the custom field will be applied.
149+
enum:
150+
- All
151+
- None
152+
- Custom
153+
type: string
154+
required:
155+
- mode
156+
type: object
157+
x-kubernetes-validations:
158+
- message: custom is required when mode is Custom, and forbidden otherwise
159+
rule: 'has(self.mode) && self.mode == ''Custom'' ? has(self.custom)
160+
: !has(self.custom)'
115161
storage:
116162
description: |-
117163
storage is an optional field that allows user to define persistent storage for gathering jobs to store the Insights data archive.

0 commit comments

Comments
 (0)