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

Bug 1842875: Remove the checks CAN_GET_NS and prometheusBaseURL for monitoring Dashboard and Metrics tabs in devconsole #5661

Merged
merged 1 commit into from Jun 10, 2020

Conversation

vikram-raj
Copy link
Member

@vikram-raj vikram-raj commented Jun 3, 2020

Fixes:
https://issues.redhat.com/browse/ODC-4082

Analysis / Root cause:
Basic user redirects to a blank page after clicking on the metrics chart on utilization card or topology metrics chart.

Solution Description:

  1. Checks for only window.SERVER_FLAGS.prometheusBaseURL in devconsole to hide the monitoring dashboard and metrics.

  2. Remove the link from the metrics chart if monitoring is not enabled.

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. component/core Related to console core functionality labels Jun 3, 2020
@openshift-ci-robot openshift-ci-robot added the component/dev-console Related to dev-console label Jun 3, 2020
@vikram-raj vikram-raj changed the title [WIP]: hide metrics section from topology sidepanel if user has no access to monitoring Hide metrics section from topology sidepanel if user has no access to monitoring Jun 3, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 3, 2020
@vikram-raj
Copy link
Member Author

/cc @kyoto @christianvogt

canAccessMonitoring && perspective === 'admin'
perspective === 'admin'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? Can't normal users see monitoring for workloads in their own namespace even if they don't have the get namespace permission?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that if canAccessNS === false we cannot redirect the user to /monitoring otherwise they get a bunch of graphs with Forbidden errors.

Copy link
Member

@spadgett spadgett Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the admin query browser uses prometheusBaseURL, which will return errors for a normal user. Dev console uses prometheusTenancyBaseURL, which will work for a normal user. That's why we're linking to the developer view when the user doesn't have get namespace permission.

Regardless, I wouldn't expect to ever have a blank page. Is there a runtime error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're reverting fix #3333 for https://bugzilla.redhat.com/show_bug.cgi?id=1770808

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR. Now, wrapping the chart with PrometheusGraphLink only if prometheusBaseURL is present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @spadgett mentioned, the dev console uses prometheusTenancyBaseURL rather than prometheusBaseURL.

So I think the logic should be like.

if (perspective === 'admin' && canAccessNS && window.SERVER_FLAGS.prometheusBaseURL) {
  url = `/monitoring/query-browser?${params.toString()}`;
} else if (window.SERVER_FLAGS.prometheusTenancyBaseURL) {
  url = `/dev-monitoring/ns/${namespace}/metrics?${params.toString()}`;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if the canAccess check is being removed from PageContents, I think we can leave PrometheusGraphLink unchanged.

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 added check for prometheusTenancyBaseURL on Link so that if prometheusTenancyBaseURL is not present then we should not redirect the user to metrics page after clicking on the chart.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vikram-raj Adding the check isn't bad, but prometheusBaseURL and prometheusTenancyBaseURL will always be set in an OpenShift cluster. The only times those aren't set are when running against native k8s or running off-cluster, which is for development only. So it's unclear to me what bug that fixes.

@@ -39,19 +38,22 @@ export const PrometheusGraphLink_: React.FC<PrometheusGraphLinkProps> = ({
if (!query) {
return <>{children}</>;
}

const prometheusBaseURLPresent = !!window.SERVER_FLAGS.prometheusBaseURL;
const canAccessMonitoring = (canAccessNS && prometheusBaseURLPresent) || prometheusBaseURLPresent;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the ||, isn't this logically the same as...?

Suggested change
const canAccessMonitoring = (canAccessNS && prometheusBaseURLPresent) || prometheusBaseURLPresent;
const canAccessMonitoring = prometheusBaseURLPresent;

I'm unclear on the intent here.

const activeNamespace = match.params.ns;
const canAccessPrometheus = canAccess && !!window.SERVER_FLAGS.prometheusBaseURL;

const canAccessPrometheus = !!window.SERVER_FLAGS.prometheusBaseURL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be prometheusTenancyBaseURL?

Copy link
Member

@kyoto kyoto Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.SERVER_FLAGS.prometheusBaseURL / window.SERVER_FLAGS.prometheusTenancyBaseURL is constant, so there should be no need for the React.useMemo below now.

Maybe it's easier to move the definition of pages outside the component now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it.

@vikram-raj vikram-raj force-pushed the odc-4082 branch 3 times, most recently from 6742d18 to 3136392 Compare June 4, 2020 07:19
@spadgett
Copy link
Member

spadgett commented Jun 4, 2020

@vikram-raj Can you describe exactly the bug you're seeing? The JIRA issue, Bugzilla, and PR description are vague, so I'm not sure what we're fixing.

Adding the checks for the Prometheus URL will not have an effects for an in-cluster console. Are you seeing the problem only in your development environment?

@vikram-raj
Copy link
Member Author

@vikram-raj Can you describe exactly the bug you're seeing? The JIRA issue, Bugzilla, and PR description are vague, so I'm not sure what we're fixing.

Adding the checks for the Prometheus URL will not have an effects for an in-cluster console. Are you seeing the problem only in your development environment?

Currently, there is an issue for basic users. As we have checks for CAN_GET_NS and !!window.SERVER_FLAGS.prometheusBaseURL to hide the monitoring Dashboard and Metrics tabs. So, as basic-users has no access to CAN_GET_NS user navigate to a blank page when the user clicks on charts in Utilization card.

@spadgett
Copy link
Member

spadgett commented Jun 4, 2020

Currently, there is an issue for basic users. As we have checks for CAN_GET_NS and !!window.SERVER_FLAGS.prometheusBaseURL to hide the monitoring Dashboard and Metrics tabs. So, as basic-users has no access to CAN_GET_NS user navigate to a blank page when the user clicks on charts in Utilization card.

This page should work for basic users. You don't need CAN_GET_NS permission for the dev console metrics view. Instead of disabling the link, we should figure out why the page is broken.

When you say blank page, do you mean a completely white screen? What exactly is the error? Is there a stack trace in the JS console?

Does this happen only in a development environment or can you reproduce with an in-cluster console?

@vikram-raj
Copy link
Member Author

This page should work for basic users. You don't need CAN_GET_NS permission for the dev console metrics view. Instead of disabling the link, we should figure out why the page is broken.

Yes, this PR removes the check CAN_GET_NS. which is being there to hide the dashboard and metrics page.

When you say blank page, do you mean a completely white screen? What exactly is the error? Is there a stack trace in the JS console?

Not completely white screen. and there is no runtime error.

Does this happen only in a development environment or can you reproduce with an in-cluster console?

It happens in both the environment development as well as in cluster.

This is the scenario
metrics-bug

@vikram-raj
Copy link
Member Author

/retitle Bug 1842875: Hide metrics section from topology sidepanel if user has no access to monitoring

@openshift-ci-robot openshift-ci-robot changed the title Hide metrics section from topology sidepanel if user has no access to monitoring Bug 1842875: Hide metrics section from topology sidepanel if user has no access to monitoring Jun 9, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jun 9, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1842875, which is invalid:

  • expected the bug to target the "4.6.0" release, but it targets "4.5.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1842875: Hide metrics section from topology sidepanel if user has no access to monitoring

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.

@@ -33,7 +33,7 @@ type MonitoringOverviewProps = {
const MonitoringOverview: React.FC<MonitoringOverviewProps> = (props) => {
const { resource, pods, resourceEvents } = props;
const [expanded, setExpanded] = React.useState(['metrics']);

const canAccessMonitoring = !!window.SERVER_FLAGS.prometheusBaseURL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be window.SERVER_FLAGS. prometheusTenancyBaseURL ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see what the changes in this file are achieving. Could you please explain the intention here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo the changes. As prometheusTenancyBaseURL is always available I removed the checks for it that I added.

@@ -52,4 +56,10 @@ describe('Monitoring Metric Section', () => {
const component = shallow(<MonitoringOverview {...monitoringOverviewProps} />);
expect(component.find(Badge).props().children).toBe(2);
});

it('should not show metrics accordian if monitoring si disable', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: si -> is

@@ -42,16 +42,18 @@ export const PrometheusGraphLink_: React.FC<PrometheusGraphLinkProps> = ({

const params = new URLSearchParams();
params.set('query0', query);

const prometheusTenancyBaseURLPresent = !!window.SERVER_FLAGS.prometheusTenancyBaseURL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per @spadgett's #5661 (comment), this would always be true. So I don't think we should be making any change in this file.

@vikram-raj vikram-raj force-pushed the odc-4082 branch 2 times, most recently from 25e5ef4 to ef55f0a Compare June 10, 2020 02:01
@vikram-raj vikram-raj requested a review from kyoto June 10, 2020 02:01
@vikram-raj vikram-raj force-pushed the odc-4082 branch 2 times, most recently from a693d3a to 22cf7af Compare June 10, 2020 02:32
@vikram-raj vikram-raj changed the title Bug 1842875: Hide metrics section from topology sidepanel if user has no access to monitoring Bug 1842875: Remove the checks CAN_GET_NS and prometheusBaseURL for monitoring Dashboard and Metrics tabs in devconsole Jun 10, 2020
@vikram-raj
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Jun 10, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1842875, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

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.

@openshift-ci-robot openshift-ci-robot removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Jun 10, 2020
@christianvogt
Copy link
Contributor

Looks to me like we are simply reverting #5602 which introduced these checks for a usecase that's considered invalid because monitoring will always be available for the dev user?

@vikram-raj
Copy link
Member Author

Looks to me like we are simply reverting #5602 which introduced these checks for a usecase that's considered invalid because monitoring will always be available for the dev user?

Yes Christian, this PR removing the checks that have been added for hiding the Dashboard and Metrics tabs in this PR #5602.

@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 10, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, vikram-raj

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 10, 2020
@openshift-merge-robot openshift-merge-robot merged commit af0c33a into openshift:master Jun 10, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: All pull requests linked via external trackers have merged: openshift/console#5661. Bugzilla bug 1842875 has been moved to the MODIFIED state.

In response to this:

Bug 1842875: Remove the checks CAN_GET_NS and prometheusBaseURL for monitoring Dashboard and Metrics tabs in devconsole

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.

@vikram-raj vikram-raj deleted the odc-4082 branch June 10, 2020 18:42
@vikram-raj
Copy link
Member Author

/cherry-pick release-4.5

@openshift-cherrypick-robot

@vikram-raj: new pull request created: #5725

In response to this:

/cherry-pick release-4.5

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.

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. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality component/dev-console Related to dev-console lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants