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

Independent Mode Dashboard #3907

Merged

Conversation

bipuladh
Copy link
Contributor

@bipuladh bipuladh commented Jan 9, 2020

  • Added blocker extension point to block out the CEPH dashboard if the independent mode is present.

@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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 9, 2020
@openshift-ci-robot openshift-ci-robot added component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dashboard Related to dashboard component/sdk Related to console-plugin-sdk labels Jan 9, 2020
frontend/packages/ceph-storage-plugin/src/plugin.ts Outdated Show resolved Hide resolved
frontend/packages/console-plugin-sdk/src/registry.ts Outdated Show resolved Hide resolved
frontend/public/actions/features.ts Outdated Show resolved Hide resolved
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 13, 2020
frontend/packages/console-plugin-sdk/src/registry.ts Outdated Show resolved Hide resolved
frontend/packages/console-plugin-sdk/src/registry.ts Outdated Show resolved Hide resolved
frontend/packages/console-plugin-sdk/src/registry.ts Outdated Show resolved Hide resolved
frontend/packages/ceph-storage-plugin/src/plugin.ts Outdated Show resolved Hide resolved
frontend/packages/console-plugin-sdk/src/registry.ts Outdated Show resolved Hide resolved
frontend/packages/ocs-independent-plugin/src/plugin.ts Outdated Show resolved Hide resolved
frontend/packages/ocs-independent-plugin/src/plugin.ts Outdated Show resolved Hide resolved
frontend/packages/ocs-independent-plugin/src/plugin.ts Outdated Show resolved Hide resolved
frontend/public/actions/features.ts Outdated Show resolved Hide resolved
@@ -9,3 +9,4 @@ export const PODS = 'Pods';
export const BY_USED = 'By Used Capacity';
export const BY_REQUESTED = 'By Requested Capacity';
export const OCS_OPERATOR = 'ocs-operator';
export const INDEPENDENT_FLAG = 'INDEPENDENT_FLAG';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to keep a clear exported API boundary between Console plugins.

  1. in ocs-independent-plugin/src/plugin.ts
export const INDEPENDENT_FLAG = 'INDEPENDENT_FLAG';
  1. add ocs-independent-plugin/src/index.ts
export { INDEPENDENT_FLAG } from './plugin';
  1. in ocs-independent-plugin/package.json
..
"private": true,
"main": "src/index.ts",
"dependencies": ..
..

and finally in ceph-storage-plugin/src/plugin.ts

import { INDEPENDENT_FLAG } from '@console/ocs-independent-plugin';

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 did this because. ocs is dependent on ceph already. If I export this from ocs then wouldn't this cause a circular dependency issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant is the feature flag constant should live close to the Console plugin which "owns" it.

In this case, it would be ocs-independent-plugin which declares it as

{
  type: 'FeatureFlag/Model',
  properties: {
    model: OCSServiceModel,
    flag: INDEPENDENT_FLAG,
  },
},

We should avoid duplicating the same constant value across different packages.

Also, I'd suggest to modify the flag's value to CEPH_INDEPENDENT or OCS_INDEPENDENT to reflect relationship with OCS.

Copy link
Contributor

Choose a reason for hiding this comment

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

ocs is dependent on ceph already

Does it make sense to merge OCS/independent plugin code into existing Ceph plugin? These two plugins seem to be closely related.

If we want to keep them separated and avoid dependency cycle, we should move the common code into console-shared package, e.g. packages/console-shared/src/constants/flags.ts declaring shared flags.

frontend/packages/ceph-storage-plugin/src/plugin.ts Outdated Show resolved Hide resolved
const requiredFlags = e.properties.required ? _.castArray(e.properties.required) : [];
return _.every(requiredFlags, (f) => flags[f]);
return (
_.every(requiredFlags, (f) => flags[f]) && _.every(disallowedFlags, (f) => flags[f] === false)
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
_.every(requiredFlags, (f) => flags[f]) && _.every(disallowedFlags, (f) => flags[f] === false)
_.every(requiredFlags, (f) => flags[f] === true) && _.every(disallowedFlags, (f) => flags[f] === false)

frontend/packages/metal3-plugin/src/plugin.tsx Outdated Show resolved Hide resolved
frontend/packages/metal3-plugin/src/plugin.tsx Outdated Show resolved Hide resolved
import { GridPosition } from '@console/shared/src/components/dashboard/DashboardGrid';
import { OCSServiceModel } from '@console/ceph-storage-plugin/src/models';
import { detectIndependentMode } from './feature';
import { INDEPENDENT_FLAG } from './consts';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest keeping flag name constants inside the plugin entry module (this file).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest keeping flag name constants inside the plugin entry module (this file).

Update: if the flag is managed via detector function, move it to corresponding features module. If it's shared between multiple packages, move it to console-shared constants.

@@ -294,7 +281,6 @@ export const detectFeatures = () => (dispatch: Dispatch) =>
[
detectOpenShift,
// TODO(vojtech): move this flag definition to metal3-plugin via ActionFeatureFlag extension
detectBaremetalPlatform,

This comment was marked as resolved.

case ActionType.AddFlag:
// eslint-disable-next-line no-console
console.log(`${action.payload.flag} is added`);
return state.set(action.payload.flag, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

The initial value should be set to undefined (feature detection in progress).

false means the feature detection is complete and feature is not available.

But I don't think we really need another action, like ActionType.AddFlag.

The simplest way to handle flags outside the base FLAGS enum is to remove unknown flag check for ActionType.SetFlag:

case ActionType.SetFlag:
  return state.set(action.payload.flag, action.payload.value);

But I think the best solution is to iterate over all extensions which deal with flags and build an array of allowed flag names, and check against that.

@vojtechszocs
Copy link
Contributor

@bipuladh For now, I'd suggest not doing any Metal3 plugin refactoring to keep this PR focused on the OCS/Independent plugin.

Also see #3987 which makes Console plugin infra changes also needed by this PR.

@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. component/olm Related to OLM and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 20, 2020
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 23, 2020
@bipuladh bipuladh changed the title [WIP] Independent Mode Dashboard Independent Mode Dashboard Jan 23, 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 Jan 23, 2020
@vojtechszocs
Copy link
Contributor

/retest

@openshift-bot
Copy link
Contributor

/retest

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

@bipuladh
Copy link
Contributor Author

/retest

@rawagner
Copy link
Contributor

/hold

build is failing due to incorrect import

ERROR in ./packages/ceph-storage-plugin/src/components/independent-dashboard-page/utilization-card/card.tsx
Module not found: Error: Can't resolve '@console/internal/components/dashboard/dashboards-page/overview-dashboard/utilization-card' in '/go/src/github.com/openshift/console/frontend/packages/ceph-storage-plugin/src/components/independent-dashboard-page/utilization-card'

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 23, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2020
@vojtechszocs
Copy link
Contributor

Fixed rebase conflict in packages/ceph-storage-plugin/src/plugin.ts and the import error.

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 23, 2020
@rawagner
Copy link
Contributor

/lgtm

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

/retest

@rawagner
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bipuladh, rawagner, 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

@vojtechszocs
Copy link
Contributor

/retest

@openshift-bot
Copy link
Contributor

/retest

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

3 similar comments
@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-merge-robot openshift-merge-robot merged commit 2e2a7b1 into openshift:master Jan 24, 2020
@spadgett spadgett added this to the v4.4 milestone Jan 27, 2020
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/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dashboard Related to dashboard component/metal3 Related to metal3-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants