Skip to content
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

Merged
merged 3 commits into from Apr 18, 2024

Conversation

TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented Mar 15, 2024

Disable console-telemetry-plugin segment analytics when window.SERVER_FLAGS.telemetry.TELEMETER_CLIENT_DISABLED flag is set

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 15, 2024
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Mar 15, 2024

@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue.

In response to this:

Disable console telemetry listeners when telemeterClientDisabled flag is set

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.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 15, 2024
@TheRealJon
Copy link
Member Author

/retest

@TheRealJon
Copy link
Member Author

QE Approver
/assign @yapei

Docs Approver:
/assign @opayne1

PX Approver:
/assign @RickJWagner

@RickJWagner RickJWagner removed their assignment Mar 15, 2024
@RickJWagner
Copy link

/label px-approved

@openshift-ci openshift-ci bot added the px-approved Signifies that Product Support has signed off on this PR label Mar 15, 2024
@jerolimov
Copy link
Member

jerolimov commented Mar 18, 2024

/cc @jerolimov @jhadvig
/assign @jerolimov @jhadvig

@openshift-ci openshift-ci bot requested a review from jerolimov March 18, 2024 10:30
@openshift-ci openshift-ci bot requested a review from jhadvig March 18, 2024 10:30
@openshift-ci openshift-ci bot added component/core Related to console core functionality component/shared Related to console-shared labels Mar 20, 2024
@opayne1
Copy link
Contributor

opayne1 commented Mar 20, 2024

/label docs-approved

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Mar 20, 2024
…abled

Disabe console telemetry listeners when `telemeterClientDisabled` flag is set
…handler, and log events that have been ignored.
@TheRealJon
Copy link
Member Author

/retest

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Apr 3, 2024

@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue.

In response to this:

Disable console telemetry listeners when window.SERVER_FLAGS.telemetry.TELEMETER_CLIENT_DISABLED flag is set

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) {
Copy link
Contributor

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

  1. 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)

  1. 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

Copy link
Contributor

@yapei yapei Apr 7, 2024

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)

  1. 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
  1. Check browser console message, this time we didn't print telemetry disabled - ignoring telemetry event xxx message
    Screenshot 2024-04-07 at 2 31 31 PM

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member

@jerolimov jerolimov Apr 16, 2024

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.

https://access.redhat.com/documentation/de-de/openshift_container_platform/4.1/html/telemetry/opting-out-of-telemetry

Peek.2024-04-16.11-07.mp4

Copy link
Member

@jerolimov jerolimov left a 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

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2024
Copy link
Contributor

openshift-ci bot commented Apr 16, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -110,12 +110,18 @@ export const eventListener: TelemetryEventListener = async (
eventType: string,
properties?: any,
) => {
if (TELEMETRY_DEBUG) {
if (TELEMETRY_DISABLED || !apiKey) {
Copy link
Member Author

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) {
Copy link
Member Author

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:

Suggested change
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;

@yapei
Copy link
Contributor

yapei commented Apr 17, 2024

Thanks @jerolimov @TheRealJon except this issue everything looks good in my testing
/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Apr 17, 2024
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Apr 17, 2024

@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue.

In response to this:

Disable console telemetry listeners when window.SERVER_FLAGS.telemetry.TELEMETER_CLIENT_DISABLED flag is set

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.

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD f666ce3 and 2 for PR HEAD 5f6dc89 in total

@jerolimov
Copy link
Member

/retest

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Apr 17, 2024

@TheRealJon: This pull request references CONSOLE-3944 which is a valid jira issue.

In response to this:

Disable console-telemetry-plugin segment analytics when window.SERVER_FLAGS.telemetry.TELEMETER_CLIENT_DISABLED flag is set

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.

@TheRealJon
Copy link
Member Author

/retest

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 7b8d108 and 1 for PR HEAD 5f6dc89 in total

Copy link
Contributor

openshift-ci bot commented Apr 18, 2024

@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.

@openshift-merge-bot openshift-merge-bot bot merged commit 8ef3b38 into openshift:master Apr 18, 2024
6 checks passed
@TheRealJon TheRealJon deleted the CONSOLE-3944 branch April 18, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/shared Related to console-shared docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants