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

Added insights-plugin #6660

Merged

Conversation

bond95
Copy link
Contributor

@bond95 bond95 commented Sep 17, 2020

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#

image
image

@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 Sep 17, 2020
@openshift-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/invalid-owners-file Indicates that a PR should not merge because it has an invalid OWNERS file in it. labels Sep 17, 2020
@bond95 bond95 changed the title WIP: Added insights-plugin Added insights-plugin Sep 22, 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 Sep 22, 2020
@@ -0,0 +1,13 @@
import { K8sKind } from '@console/internal/module/k8s';

export const InsightsModel: K8sKind = {
Copy link

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@bond95
Copy link
Contributor Author

bond95 commented Sep 29, 2020

@spadgett @smarterclayton @vojtechszocs @doruskova Could you, please, also take a look?

@doruskova
Copy link

@bond95 Can you add a better quality image for the card? Thanks

@bond95
Copy link
Contributor Author

bond95 commented Sep 29, 2020

@doruskova done

@doruskova
Copy link

@bond95 It looks great, but is possible to align the icons with the title "Total risk"?

Copy link
Member

@spadgett spadgett left a 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!

Comment on lines 11 to 21
"@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",
Copy link
Member

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
Copy link
Member

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

Copy link
Contributor Author

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', '');
Copy link
Member

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

Suggested change
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}`}>
Copy link
Member

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:

<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">
Copy link
Member

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);
}
}
Copy link
Member

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

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

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',
},
Copy link
Contributor

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:

  1. create ModelDefinition extension
{
    type: 'ModelDefinition',
    properties: {
      models: [YourModel],
    },
  },
  1. Add FeatureFlag extension
const INSIGHTS_FLAG = 'INSIGHTS_FLAG';
{
    type: 'FeatureFlag/Model',
    properties: {
      model: YourModel,
      flag: INSIGHTS_FLAG,
    },
  },
  1. gate Dashboard Health with the above flag
Suggested change
},
flags: {
required: [InsightsFlag],
},
},

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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 👍

@bond95
Copy link
Contributor Author

bond95 commented Sep 30, 2020

@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",
Copy link
Contributor

Choose a reason for hiding this comment

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

@bond95 @spadgett FYI, this means Insights plugin will be included in all Console builds by default.

{
"name": "@console/insights-plugin",
"version": "0.0.0-fixed",
"description": "Plugin for Insights operator",
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"test": "yarn --cwd ../.. run test packages/insights-plugin"
"test": "yarn --cwd ../.. test packages/insights-plugin"

(m) => m.InsightsPopup,
),
popupTitle: 'Insights status',
},
Copy link
Contributor

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.

@doruskova
Copy link

@bond95 Thank you for the update. I noticed 2 things:

  • Insights status title looks smaller than the Total risk title. Insights status should use 16px and Total risk 14px (If it's too small > use 16px).
  • Could you align Insights status, Total risk, and Fixable issues? Currently, the total risk is more indented to the right.

@bond95
Copy link
Contributor Author

bond95 commented Oct 5, 2020

@doruskova I updated screenshot. About headers, Insights header is default one, it size is 14px, so I made Total risk size same as Fixable issues (13px).

@doruskova
Copy link

@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 :)

global_palette_gold_400,
global_palette_orange_300,
global_palette_red_200,
} from '@patternfly/react-tokens';
Copy link
Contributor

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',
},
Copy link
Contributor

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,
Copy link
Contributor

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.

@bond95 bond95 force-pushed the added-insights-plugin branch 3 times, most recently from 9fb0646 to dbf394b Compare October 7, 2020 13:33
@vojtechszocs
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 7, 2020
@vojtechszocs
Copy link
Contributor

/lgtm cancel

@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 7, 2020
@vojtechszocs
Copy link
Contributor

Please import from @patternfly/react-tokens like

import { global_palette_blue_300 as blueInfoColor } from '@patternfly/react-tokens/dist/js/global_palette_blue_300';

@vojtechszocs
Copy link
Contributor

/lgtm

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

[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 /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 Oct 7, 2020
@spadgett
Copy link
Member

spadgett commented Oct 7, 2020

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 7, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Oct 7, 2020

@bond95: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/kubevirt-plugin f15bcd5 link /test kubevirt-plugin

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-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

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/insights Related to insights plugin component/sdk Related to console-plugin-sdk lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants