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
Conversation
/cc @kyoto @christianvogt |
canAccessMonitoring && perspective === 'admin' | ||
perspective === 'admin' |
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.
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?
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 thought that if canAccessNS === false
we cannot redirect the user to /monitoring
otherwise they get a bunch of graphs with Forbidden errors.
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.
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?
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.
It looks like we're reverting fix #3333 for https://bugzilla.redhat.com/show_bug.cgi?id=1770808
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.
Updated the PR. Now, wrapping the chart with PrometheusGraphLink
only if prometheusBaseURL
is present.
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.
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()}`;
}
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.
Actually, if the canAccess
check is being removed from PageContents
, I think we can leave PrometheusGraphLink
unchanged.
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 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.
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.
@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; |
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.
With the ||
, isn't this logically the same as...?
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; |
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.
Should this be prometheusTenancyBaseURL
?
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.
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?
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.
Updated it.
6742d18
to
3136392
Compare
@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 |
This page should work for basic users. You don't need 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? |
Yes, this PR removes the check
Not completely white screen. and there is no runtime error.
It happens in both the environment development as well as in cluster. |
/retitle Bug 1842875: Hide metrics section from topology sidepanel if user has no access to monitoring |
@vikram-raj: This pull request references Bugzilla bug 1842875, which is invalid:
Comment 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 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; |
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.
Should this be window.SERVER_FLAGS. prometheusTenancyBaseURL
?
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.
yes.
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 see what the changes in this file are achieving. Could you please explain the intention here?
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.
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', () => { |
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.
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; |
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.
Per @spadgett's #5661 (comment), this would always be true. So I don't think we should be making any change in this file.
25e5ef4
to
ef55f0a
Compare
a693d3a
to
22cf7af
Compare
…hboard and Metrics tabs in devconsole
/bugzilla refresh |
@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
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 kubernetes/test-infra repository. |
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. |
/lgtm |
[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 |
@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:
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. |
/cherry-pick release-4.5 |
@vikram-raj: new pull request created: #5725 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 kubernetes/test-infra repository. |
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:
Checks for only
window.SERVER_FLAGS.prometheusBaseURL
in devconsole to hide the monitoring dashboard and metrics.Remove the link from the metrics chart if monitoring is not enabled.
Browser conformance: