Skip to content

Commit b83ce21

Browse files
nammnfealebenpae
authored andcommitted
CLOUDP-303610 - [telemetry] hide away default values and default to true (#4137)
# Summary - don't expose the helm chart settings in values.yaml, only set the "false" env var if they are setting it to false. - bump helm version to 3.17 to allows nil with bool comparisons (makes helm chart less complex + version skew should allow that: https://helm.sh/docs/topics/version_skew/#supported-version-skew) - fix a helm chart naming bug for telemetry enabled ## Proof of Work ### Default case - nothing changes (as defaults to true) - ci passes - some cases below **default case installs clusterrole** ``` ❯ helm template operator helm_chart | rg clusterVersionDetection -C 2
1 parent 532ba07 commit b83ce21

File tree

12 files changed

+60
-62
lines changed

12 files changed

+60
-62
lines changed

config/manager/manager.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ spec:
5252
fieldPath: metadata.namespace
5353
- name: MANAGED_SECURITY_CONTEXT
5454
value: 'true'
55-
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
56-
value: "168h"
5755
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY
5856
value: "1h"
57+
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
58+
value: "168h"
5959
- name: CLUSTER_CLIENT_TIMEOUT
6060
value: "10"
6161
- name: IMAGE_PULL_POLICY

docker/mongodb-enterprise-tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ RUN apt-get -qq update \
3030
git \
3131
openssl
3232

33-
ENV HELM_NAME "helm-v3.6.3-linux-amd64.tar.gz"
33+
ENV HELM_NAME "helm-v3.17.1-linux-amd64.tar.gz"
3434
# install Helm
3535
RUN curl --fail --retry 3 -L -o "${HELM_NAME}" "https://get.helm.sh/${HELM_NAME}" \
3636
&& tar -xzf "${HELM_NAME}" \

helm_chart/templates/operator-roles.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,15 @@ subjects:
179179

180180
{{- end }}
181181

182-
183-
{{ if and .Values.operator.telemetry.collection.clusters.enabled .Values.operator.telemetry.enabled}}
184182
{{- $clusterRoleName := printf "%s-cluster-telemetry" .Values.operator.name }}
185-
{{- if .Values.operator.telemetry.installClusterRoles }}
183+
{{- $telemetry := default dict .Values.operator.telemetry }}
184+
185+
{{/* We can't use default here, as 0, false and nil as determined as unset and thus set the default value */}}
186+
{{- $telemetryEnabled := $telemetry.enabled }}
187+
{{- $installClusterRoles := $telemetry.installClusterRoles }}
188+
189+
{{- if ne $telemetry.enabled false }}
190+
{{- if ne $telemetry.installClusterRoles false}}
186191
---
187192
# Additional ClusterRole for clusterVersionDetection
188193
kind: ClusterRole

helm_chart/templates/operator.yaml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,38 @@ spec:
9898
- name: MANAGED_SECURITY_CONTEXT
9999
value: 'true'
100100
{{- end }}
101-
{{- if eq .Values.operator.telemetry.enabled false}}
101+
{{- $telemetry := default dict .Values.operator.telemetry }}
102+
{{- if eq $telemetry.enabled false }}
102103
- name: MDB_OPERATOR_TELEMETRY_ENABLED
103-
value: 'false'
104+
value: "false"
104105
{{- end }}
105-
{{- if eq .Values.operator.telemetry.send.enabled false}}
106-
- name: MDB_OPERATOR_TELEMETRY_SEND_ENABLED
107-
value: 'false'
106+
{{- if eq $telemetry.collection.clusters.enabled false }}
107+
- name: MDB_OPERATOR_TELEMETRY_CLUSTERS_ENABLED
108+
value: "false"
108109
{{- end }}
109-
{{- if .Values.operator.telemetry.send.frequency}}
110-
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
111-
value: "{{ .Values.operator.telemetry.send.frequency }}"
110+
{{- if eq $telemetry.collection.deployments.enabled false }}
111+
- name: MDB_OPERATOR_TELEMETRY_DEPLOYMENTS_ENABLED
112+
value: "false"
112113
{{- end }}
113-
{{- if .Values.operator.telemetry.send.baseUrl}}
114-
- name: MDB_OPERATOR_TELEMETRY_SEND_BASEURL
115-
value: "{{ .Values.operator.telemetry.send.baseUrl }}"
114+
{{- if eq $telemetry.collection.operators.enabled false }}
115+
- name: MDB_OPERATOR_TELEMETRY_OPERATORS_ENABLED
116+
value: "false"
116117
{{- end }}
117-
{{- if eq .Values.operator.telemetry.collection.clusters.enabled false}}
118-
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_CLUSTERS_ENABLED
119-
value: 'false'
118+
{{- if $telemetry.collection.frequency}}
119+
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY
120+
value: "{{ $telemetry.collection.frequency }}"
120121
{{- end }}
121-
{{- if eq .Values.operator.telemetry.collection.deployments.enabled false}}
122-
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_DEPLOYMENTS_ENABLED
123-
value: 'false'
122+
{{- if eq $telemetry.send.enabled false }}
123+
- name: MDB_OPERATOR_TELEMETRY_SEND_ENABLED
124+
value: "false"
124125
{{- end }}
125-
{{- if eq .Values.operator.telemetry.collection.operators.enabled false}}
126-
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_OPERATORS_ENABLED
127-
value: 'false'
126+
{{- if $telemetry.send.frequency}}
127+
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
128+
value: "{{ .Values.operator.telemetry.send.frequency }}"
128129
{{- end }}
129-
{{- if.Values.operator.telemetry.collection.frequency}}
130-
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY
131-
value: "{{ .Values.operator.telemetry.collection.frequency }}"
130+
{{- if $telemetry.send.baseUrl}}
131+
- name: MDB_OPERATOR_TELEMETRY_SEND_BASEURL
132+
value: "{{ $telemetry.send.baseUrl }}"
132133
{{- end }}
133134
{{- if .Values.multiCluster.clusterClientTimeout }}
134135
- name: CLUSTER_CLIENT_TIMEOUT

helm_chart/values.yaml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,14 @@ operator:
9999
registerConfiguration: true
100100

101101
telemetry:
102-
# Enables telemetry. Setting this to false will stop all telemetry related work on the operator.
103-
enabled: true
104-
# Adds RBAC clusterRole for kube-system uid detection for the kubernetes cluster uid
105-
# Adds RBAC clusterRole for RBAC for nodes. We are listing exactly one node to detect the cluster provider (e.g. eks)
106-
# Adds RBAC clusterRole for /version query for detecting kubernetes server version
107-
# Note: the cluster UUID is unique but random and mongoDB has no way to map this to a customer.
108-
installClusterRoles: true
109102
collection:
103+
clusters: {}
104+
deployments: {}
105+
operators: {}
110106
# Valid time units are "m", "h". Anything less than one minute defaults to 1h
111107
frequency: 1h
112-
# Enables the operator to collect and send cluster level telemetry
113-
clusters:
114-
enabled: true
115-
# Enables the operator to collect and send deployment level telemetry
116-
deployments:
117-
enabled: true
118-
# Enables the operator to collect and send operator level telemetry
119-
operators:
120-
enabled: true
121108
# Enables sending the collected telemetry to MongoDB
122109
send:
123-
enabled: true
124110
# 168 hours is one week
125111
# Valid time units are "h". Anything less than one hours defaults to 168h
126112
frequency: 168h

pkg/telemetry/configmap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func isTimestampOlderThanConfiguredFrequency(ctx context.Context, k8sClient kube
150150
return isOlder, nil
151151
}
152152

153-
// updateTelemetryConfigMapTimeStamp updates the configmap with the current collected telemetry data
153+
// updateTelemetryConfigMapPayload updates the configmap with the current collected telemetry data
154154
func updateTelemetryConfigMapPayload(ctx context.Context, k8sClient kubeclient.Client, events []Event, namespace string, OperatorConfigMapTelemetryConfigMapName string, eventType EventType) error {
155155
cm := &corev1.ConfigMap{}
156156
err := k8sClient.Get(ctx, types.NamespacedName{Name: OperatorConfigMapTelemetryConfigMapName, Namespace: namespace}, cm)
@@ -176,7 +176,7 @@ func updateTelemetryConfigMapPayload(ctx context.Context, k8sClient kubeclient.C
176176
return nil
177177
}
178178

179-
// updateTelemetryConfigMapPayload updates the configmap with the current timestamp
179+
// updateTelemetryConfigMapTimeStamp updates the configmap with the current timestamp
180180
func updateTelemetryConfigMapTimeStamp(ctx context.Context, k8sClient kubeclient.Client, namespace string, OperatorConfigMapTelemetryConfigMapName string, eventType EventType) error {
181181
cm := &corev1.ConfigMap{}
182182
err := k8sClient.Get(ctx, types.NamespacedName{Name: OperatorConfigMapTelemetryConfigMapName, Namespace: namespace}, cm)

pkg/telemetry/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ var AllEventTypes = []EventType{
6363
}
6464

6565
var EventTypeMappingToEnvVar = map[EventType]string{
66-
Deployments: "MDB_OPERATOR_TELEMETRY_COLLECTION_DEPLOYMENTS",
67-
Clusters: "MDB_OPERATOR_TELEMETRY_COLLECTION_CLUSTERS",
68-
Operators: "MDB_OPERATOR_TELEMETRY_COLLECTION_OPERATORS",
66+
Deployments: "MDB_OPERATOR_TELEMETRY_COLLECTION_DEPLOYMENTS_ENABLED",
67+
Clusters: "MDB_OPERATOR_TELEMETRY_COLLECTION_CLUSTERS_ENABLED",
68+
Operators: "MDB_OPERATOR_TELEMETRY_COLLECTION_OPERATORS_ENABLED",
6969
}
7070

7171
func (e EventType) GetPayloadKey() string {

public/mongodb-enterprise-multi-cluster.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ spec:
302302
valueFrom:
303303
fieldRef:
304304
fieldPath: metadata.namespace
305-
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
306-
value: "168h"
307305
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY
308306
value: "1h"
307+
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
308+
value: "168h"
309309
- name: CLUSTER_CLIENT_TIMEOUT
310310
value: "10"
311311
- name: IMAGE_PULL_POLICY

public/mongodb-enterprise-openshift.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ spec:
297297
fieldPath: metadata.namespace
298298
- name: MANAGED_SECURITY_CONTEXT
299299
value: 'true'
300-
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
301-
value: "168h"
302300
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY
303301
value: "1h"
302+
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
303+
value: "168h"
304304
- name: CLUSTER_CLIENT_TIMEOUT
305305
value: "10"
306306
- name: IMAGE_PULL_POLICY

public/mongodb-enterprise.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ spec:
298298
valueFrom:
299299
fieldRef:
300300
fieldPath: metadata.namespace
301-
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
302-
value: "168h"
303301
- name: MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY
304302
value: "1h"
303+
- name: MDB_OPERATOR_TELEMETRY_SEND_FREQUENCY
304+
value: "168h"
305305
- name: CLUSTER_CLIENT_TIMEOUT
306306
value: "10"
307307
- name: IMAGE_PULL_POLICY

0 commit comments

Comments
 (0)