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
Added insights-plugin #6660
Added insights-plugin #6660
Conversation
Hi @bond95. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
5a7d565
to
4ec3d93
Compare
4ec3d93
to
c8e0826
Compare
@@ -0,0 +1,13 @@ | |||
import { K8sKind } from '@console/internal/module/k8s'; | |||
|
|||
export const InsightsModel: K8sKind = { |
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 guess this can be removed now, right?
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.
Fixed
c8e0826
to
2cae023
Compare
@spadgett @smarterclayton @vojtechszocs @doruskova Could you, please, also take a look? |
@bond95 Can you add a better quality image for the card? Thanks |
@doruskova done |
@bond95 It looks great, but is possible to align the icons with the title "Total risk"? |
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.
A few comments, but looks good overall. Nice work. Thanks!
"@console/ceph-storage-plugin": "0.0.0-fixed", | ||
"@console/container-security": "0.0.0-fixed", | ||
"@console/dev-console": "0.0.0-fixed", | ||
"@console/internal": "0.0.0-fixed", | ||
"@console/knative-plugin": "0.0.0-fixed", | ||
"@console/kubevirt-plugin": "0.0.0-fixed", | ||
"@console/local-storage-operator-plugin": "0.0.0-fixed", | ||
"@console/metal3-plugin": "0.0.0-fixed", | ||
"@console/network-attachment-definition-plugin": "0.0.0-fixed", | ||
"@console/noobaa-storage-plugin": "0.0.0-fixed", | ||
"@console/operator-lifecycle-manager": "0.0.0-fixed", |
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 assume you don't really depend on all of these? You should only need to specify dependencies specific to your plugin here.
- bond95 | ||
- tisnik | ||
labels: | ||
- component/insights |
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.
You'll need a PR to the openshift/release repo to add this label. See openshift/release#4526
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 created PR for that openshift/release#12398
|
||
export const InsightsPopup: React.FC<PrometheusHealthPopupProps> = ({ responses, k8sResult }) => { | ||
const resource = mapMetrics(responses[0].response); | ||
const clusterId = _.get(k8sResult, 'data.spec.clusterID', ''); |
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.
nit: For new code, we prefer optional chaining. Console naming conventions would make this uppercase ID
const clusterId = _.get(k8sResult, 'data.spec.clusterID', ''); | |
const clusterID = k8sResult?.data?.spec?.clusterID || ''; |
<> | ||
<div style={{ fontWeight: 'bold' }}>Fixable issues</div> | ||
<div> | ||
<a href={`https://cloud.redhat.com/openshift/details/${clusterId}`}> |
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.
Use the ExternalLink
component. Here's an example:
Lines 52 to 55 in 24912ac
<ExternalLink | |
href={RH_OPERATOR_SUPPORT_POLICY_LINK} | |
text="Learn more about Red Hat’s third party software support policy" | |
/> |
</> | ||
)} | ||
{!isThereIssues && ( | ||
<a href="https://docs.openshift.com/container-platform/latest/support/getting-support.html"> |
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.
ExternalLink
here as well.
.co-insights__no-rules { | ||
color: var(--pf-global--Color--200); | ||
} | ||
} |
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.
nit: missing newline at the end of the file.
@@ -0,0 +1,5 @@ | |||
.co-insights__box { | |||
.co-insights__no-rules { |
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.
We typically avoid nesting of CSS styles and find it's not often necessary with BEM. Is .co-insights__no-rules
by itself specific enough here?
moderate?: number; | ||
}; | ||
|
||
export const mapMetrics = (response) => { |
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.
missing types
(m) => m.InsightsPopup, | ||
), | ||
popupTitle: 'Insights status', | ||
}, |
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.
You need to gate the extension by some model contributed by Insights operator. To do so:
- create ModelDefinition extension
{
type: 'ModelDefinition',
properties: {
models: [YourModel],
},
},
- Add FeatureFlag extension
const INSIGHTS_FLAG = 'INSIGHTS_FLAG';
{
type: 'FeatureFlag/Model',
properties: {
model: YourModel,
flag: INSIGHTS_FLAG,
},
},
- gate Dashboard Health with the above flag
}, | |
flags: { | |
required: [InsightsFlag], | |
}, | |
}, |
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.
@bond95 As @rawagner wrote, we should enable the plugin's extensions only when the cluster has the right capability (i.e. Insights operator is installed).
Detecting Insights operator can be done via CRD detection. Use ModelDefinition
extension to make Console aware of your CRD, then use FeatureFlag/Model
extension to introduce a feature flag reflecting the presence of such CRD.
Every other extension can then use the flags
object to declare which feature flags are required and/or disallowed in order for that particular extension to be in use. Typically, you'd want all Insights extensions to be gated by INSIGHTS_FLAG
.
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.
@rawagner @vojtechszocs What if we don't have any CRD?
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.
Another option is to implement your own detection logic and use CustomFeatureFlag
. Example https://github.com/openshift/console/blob/master/frontend/packages/ceph-storage-plugin/src/plugin.ts#L76
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.
@rawagner We had discussion with @smarterclayton and @spadgett, they suggested not to hide tab even if insights-operator is disabled.
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.
@bond95 Assuming that Insights integration is implemented via cluster-level operator (i.e. not via OLM operator), it makes sense to have Insights plugin extensions active by default 👍
2cae023
to
761f37c
Compare
@doruskova I updated screenshot, please, take a look |
@@ -12,6 +12,7 @@ | |||
"@console/container-security": "0.0.0-fixed", | |||
"@console/dev-console": "0.0.0-fixed", | |||
"@console/internal": "0.0.0-fixed", | |||
"@console/insights-plugin": "0.0.0-fixed", |
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.
{ | ||
"name": "@console/insights-plugin", | ||
"version": "0.0.0-fixed", | ||
"description": "Plugin for Insights operator", |
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.
Nit: I'd put a more descriptive message here, like:
Insights - provide cluster health data and integrate with OpenShift Cluster Manager
"private": true, | ||
"main": "src/index.ts", | ||
"scripts": { | ||
"test": "yarn --cwd ../.. run test packages/insights-plugin" |
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.
"test": "yarn --cwd ../.. run test packages/insights-plugin" | |
"test": "yarn --cwd ../.. test packages/insights-plugin" |
(m) => m.InsightsPopup, | ||
), | ||
popupTitle: 'Insights status', | ||
}, |
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.
@bond95 As @rawagner wrote, we should enable the plugin's extensions only when the cluster has the right capability (i.e. Insights operator is installed).
Detecting Insights operator can be done via CRD detection. Use ModelDefinition
extension to make Console aware of your CRD, then use FeatureFlag/Model
extension to introduce a feature flag reflecting the presence of such CRD.
Every other extension can then use the flags
object to declare which feature flags are required and/or disallowed in order for that particular extension to be in use. Typically, you'd want all Insights extensions to be gated by INSIGHTS_FLAG
.
@bond95 Thank you for the update. I noticed 2 things:
|
77fce98
to
eff72c0
Compare
@doruskova I updated screenshot. About headers, |
@bond95 The alignment looks great now, but you should keep 14px for every title because 13px is not an official variable and it's too small for a user. Then it should be fine :) |
eff72c0
to
a596493
Compare
global_palette_gold_400, | ||
global_palette_orange_300, | ||
global_palette_red_200, | ||
} from '@patternfly/react-tokens'; |
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.
Please disable @typescript-eslint/camelcase
rule only for the relevant imports:
import * as _ from 'lodash';
/* eslint-disable @typescript-eslint/camelcase */
import {
global_palette_blue_50,
global_palette_blue_300,
global_palette_gold_400,
global_palette_orange_300,
global_palette_red_200,
} from '@patternfly/react-tokens';
/* eslint-enable @typescript-eslint/camelcase */
(m) => m.InsightsPopup, | ||
), | ||
popupTitle: 'Insights status', | ||
}, |
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.
@bond95 Assuming that Insights integration is implemented via cluster-level operator (i.e. not via OLM operator), it makes sense to have Insights plugin extensions active by default 👍
import { | ||
Plugin, | ||
DashboardsOverviewHealthPrometheusSubsystem, | ||
ModelFeatureFlag, |
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.
Nit: unnecessary type import, since we don't need to add any feature flags.
Please remove it here and update the ConsumedExtensions
type alias.
9fb0646
to
dbf394b
Compare
/lgtm |
/lgtm cancel |
Please import from import { global_palette_blue_300 as blueInfoColor } from '@patternfly/react-tokens/dist/js/global_palette_blue_300'; |
dbf394b
to
7e2d6df
Compare
7e2d6df
to
79a226b
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bond95, vojtechszocs 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 |
/ok-to-test |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@bond95: The following test failed, say
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. |
/retest Please review the full test history for this PR and help us cut down flakes. |
This PR adds new insights-plugin, which is used to show insights information about cluster, such as number of issues that was found and Total Risks of issues and link to cluster's page in OCM.
More info about integration insights into OCP WebConsole could be found here: https://docs.google.com/document/d/1d4KdH3DpUrUTFIrFN6tnItQPFV2NRFYnm_-yMJ6gNN0/edit#