New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CONSOLE-3944: Disable segment analytics when cluster telemetry is disabled #13677
CONSOLE-3944: Disable segment analytics when cluster telemetry is disabled #13677
Conversation
@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/retest |
QE Approver Docs Approver: PX Approver: |
/label px-approved |
/cc @jerolimov @jhadvig |
/label docs-approved |
…abled Disabe console telemetry listeners when `telemeterClientDisabled` flag is set
…handler, and log events that have been ignored.
2c140d2
to
f4e140d
Compare
/retest |
@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@@ -110,12 +110,18 @@ export const eventListener: TelemetryEventListener = async ( | |||
eventType: string, | |||
properties?: any, | |||
) => { | |||
if (TELEMETRY_DEBUG) { | |||
if (TELEMETRY_DISABLED || !apiKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the changes and it looks like we have some issue here
- confirm if telemeter client is disabled or not(based on latest code change, we check deployment/telemeter-client status)
$ oc get deployment telemeter-client -n openshift-monitoring
NAME READY UP-TO-DATE AVAILABLE AGE
telemeter-client 1/1 1 1 3h7m
$ oc get cm console-config -n openshift-console | grep tele (nothing returned)
- Enable demo plugin and do some navigation in the web, we can see messages in browser console
console-telemetry-plugin: telemetry disabled - ignoring telemetry event xxxx
based on the data in step1 we can see that telemeter client is NOT disabled
, so it looks a bit wired we are printing telemetry disabled
message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However after I disabled telemeter client, browser console prints following message(when telemeter is actually disabled, we didn't print correct message)
- confirm telemeter is actually disabled
$ oc get cm console-config -n openshift-console -o yaml | grep telemetry -A2
telemetry:
TELEMETER_CLIENT_DISABLED: "true"
kind: ConfigMap
$ oc get deployment telemeter-client -n openshift-monitoring
Error from server (NotFound): deployments.apps "telemeter-client" not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be some confusion about the scope of this change. This PR is only meant to disable Segment analytics when cluster telemetry is disabled in the cluster monitoring operator. It will not disable all telemetry in the UI.
Additionally, other conditions will cause Segment analytics to be disabled. Could you check these four conditions to ensure we shouldn't show the disabled message:
- window.SERVER_FLAGS?.telemetry?.DISABLED === 'false'
- window.SERVER_FLAGS?.telemetry?.DEVSANDBOX_DISABLED === 'false'
- window.SERVER_FLAGS?.telemetry?.TELEMETER_CLIENT_DISABLED === 'false'
- window.SERVER_FLAGS?.telemetry?.DEVSANDBOX_SEGMENT_API_KEY or window.SERVER_FLAGS?.telemetry?.SEGMENT_API_KEY is defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yapei , please take a look how I've tested the changes below. Maybe this is enough to get your qe-approve label.
The problem I've noticed with the telemeter-client
Deployment is, that it was automatically removed again. I expect that the monitoring-operator reconciler removed it. A better test might be to enable telemetry on a cluster bot but I don't know how to enable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that was easier then expected. Instead of creating the telemeter-client
Deployment manually, I just enabled telemetry in the cluster-monitoring-config
ConfigMap in the openshift-monitoring
namespace.
After that you must wait a bit and reload the web console.
Peek.2024-04-16.11-07.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified this change on a cluster bot:
Works as expected. I personally would recommend a small change on the operator side:
Allow cluster admins to override TELEMETRY_CLIENT_DISABLED with an annotation! Currently, there is no option to enable segment analytics if the telemeter-client
Deployment isn't available because TELEMETRY_CLIENT_DISABLED is then always true.
@jhadvig maybe you can apply that if you touch the operator again.
Here are two long recordings how I've tested the change:
Peek.2024-04-16.10-49.mp4
Peek.2024-04-16.10-54.mp4
Peek.2024-04-16.11-07.mp4
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jerolimov, TheRealJon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -110,12 +110,18 @@ export const eventListener: TelemetryEventListener = async ( | |||
eventType: string, | |||
properties?: any, | |||
) => { | |||
if (TELEMETRY_DEBUG) { | |||
if (TELEMETRY_DISABLED || !apiKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might also be some confusion about this conditional block because there is no case where it will evaluate to true if TELEMETRY_DISABLED === true. This entire extension will not be resolved in that case. See the following:
@@ -110,12 +110,18 @@ export const eventListener: TelemetryEventListener = async ( | |||
eventType: string, | |||
properties?: any, | |||
) => { | |||
if (TELEMETRY_DEBUG) { | |||
if (TELEMETRY_DISABLED || !apiKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to add further changes to this PR since it's already got an lgtm, but I might follow on with a tweak like this:
if (TELEMETRY_DISABLED || !apiKey) { | |
if (!apiKey) { | |
// eslint-disable-next-line no-console | |
console.debug( | |
'console-telemetry-plugin: segment API key missing - ignoring telemetry event:', | |
eventType, | |
properties, | |
); | |
return; |
Thanks @jerolimov @TheRealJon except this issue everything looks good in my testing |
@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/retest |
@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/retest |
@TheRealJon: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Disable console-telemetry-plugin segment analytics when
window.SERVER_FLAGS.telemetry.TELEMETER_CLIENT_DISABLED
flag is set