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

Adds Pool creation modal for storageClass form #6024

Merged
merged 1 commit into from Jul 28, 2020

Conversation

a2batic
Copy link
Contributor

@a2batic a2batic commented Jul 20, 2020

Enable user to create a Pool while creating OCS backed storage Class.
Screenshot from 2020-07-24 00-43-19
Screenshot from 2020-07-28 12-11-26

Jira: https://issues.redhat.com/browse/RHSTOR-1154
Signed-off-by: Kanika Murarka kmurarka@redhat.com
Co-authored-by: Paul Cuzner pcuzner@redhat.com

@openshift-ci-robot openshift-ci-robot added the component/ceph Related to ceph-storage-plugin label Jul 20, 2020
@a2batic a2batic marked this pull request as draft July 20, 2020 05:36
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 20, 2020
@a2batic a2batic changed the title Adds Pool creation modal for storageClass form [WIP] Adds Pool creation modal for storageClass form Jul 20, 2020
@a2batic a2batic force-pushed the pool-component branch 2 times, most recently from 9d31d11 to afc43b1 Compare July 23, 2020 20:21
@a2batic a2batic marked this pull request as ready for review July 23, 2020 20:21
@a2batic a2batic changed the title [WIP] Adds Pool creation modal for storageClass form Adds Pool creation modal for storageClass form Jul 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 Jul 23, 2020
@@ -0,0 +1,10 @@
export const replicas = {
ReplicaTWO: '2',
ReplicaTHREE: '3',
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

import { CEPH_STORAGE_NAMESPACE, OCS_INTERNAL_CR_NAME } from '../../../constants/index';

import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
import { referenceForModel } from '@console/internal/module/k8s';
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 imports need to be moved up before the relative ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

const PoolStatusComponent: React.FC<PoolStatusComponentProps> = ({ status, name, error = '' }) => {
return (
<div>
{status === 'progress' && (
Copy link
Contributor

Choose a reason for hiding this comment

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

We should create a constant for all the status, an enum may be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

<EmptyStateBody>Pool {name} was successfully created</EmptyStateBody>
</EmptyState>
)}
{status === 'failed' && (
Copy link
Contributor

Choose a reason for hiding this comment

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

switch might be better here.

);

React.useEffect(() => {
k8sGet(OCSServiceModel, OCS_INTERNAL_CR_NAME, CEPH_STORAGE_NAMESPACE)
Copy link
Contributor

Choose a reason for hiding this comment

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

K8sGet -> fetchK8s, Just replacing the word will make it work. No extra efforts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

setPoolStatus('created');
setIsSubmit(false);
setTimeClear(true);
} else if (newPoolLoaded && newPool?.status?.phase === 'ReconcileFailed') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Create an enum for all possible phase values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

const timeoutTimer = setTimeout(() => {
setPoolStatus('timeout');
setIsSubmit(false);
}, 15000);
Copy link
Contributor

Choose a reason for hiding this comment

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

15 * SECOND, Constant for SECOND already present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

const [isCompressed, setCompression] = React.useState(false);
const [deviceClass, setdeviceClass] = React.useState('');
const [poolStatus, setPoolStatus] = React.useState('');
const [storageClusterLoading, setStorageClusterLoading] = React.useState(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

May be you can create an object like

const storageClustetState = {
   loading: true,
   error: false,
   ready: false,
}

and use this whole object as state. It will look more cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

</EmptyState>
)}
{status === 'timeout' && (
<EmptyState>
Copy link
Contributor

@gnehapk gnehapk Jul 24, 2020

Choose a reason for hiding this comment

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

        <EmptyState>
          <EmptyStateIcon icon={ExclamationCircleIcon} className="ceph-storage-pool__error-icon" />
          <EmptyStateBody>
            {error || `An error occurred, Pool ${name} was not created`}
          </EmptyStateBody>
        </EmptyState>

It make sense to create a common component for this, since its used at many places. for eg.
<EmptyStateContainer icon={} message={} /> WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

if (poolStatus === 'created') {
onPoolCreation(newPoolName);
}
close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to a function and use it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

!poolStatus &&
!storageClusterError &&
storageClusterReady &&
cephClusterObj[0]?.status?.phase === 'Ready' ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Moving these conditions to a function and calling here, might be a better approach as so many conditions are checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@@ -0,0 +1,27 @@
//@import '../../../../console-shared/src/styles/skeleton-screen.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why _ for the file name?

</div>
);
}
return <>{loaded || poolDataLoaded || <LoadingInline />}</>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be {(loaded || poolDataLoaded) && <LoadingInline />}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack


export const modalTitle = 'Create New Pool';
export const modalDescription =
'Pools are logical groups of Ceph objects. Such objects live inside of Ceph, or rather they live inside RADOS.';
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't mention Ceph & RADOS as they are internal entities. @yuvalgalanti ^^

export const modalDescription =
'Pools are logical groups of Ceph objects. Such objects live inside of Ceph, or rather they live inside RADOS.';
export const notReadyDesc =
'The creation of an OCS storage cluster is still in progress or have failed, please try again after the storage cluster is ready to use.';
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we checking the storage cluster or Ceph Cluster both are different entities? The storage cluster might be ready even when ceph cluster is not & user will be baffled with this message on why this is happening.


const PoolStatusComponent: React.FC<PoolStatusComponentProps> = ({ status, name, error = '' }) => {
return (
<div>
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
<div>
<>

</EmptyStateBody>
</EmptyState>
)}
</div>
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
</div>
</>

const [timeoutClear, setTimeClear] = React.useState(false);
const [timer, setTimer] = React.useState<NodeJS.Timer>(null);

const poolResource = React.useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we pooling single pool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are pooling to get status of pool, before closing the modal.

k8sGet(OCSServiceModel, OCS_INTERNAL_CR_NAME, CEPH_STORAGE_NAMESPACE)
.then((cluster: OCSStorageClusterKind) => {
setStorageClusterLoading(false);
if (cluster.status.phase === 'Ready') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cluster might not be ready because of something with NooBaa & will not let user create pool?

@a2batic a2batic force-pushed the pool-component branch 2 times, most recently from 8624739 to 4fd777b Compare July 27, 2020 12:40
ModalComponentProps,
ModalFooter,
} from '@console/internal/components/factory/modal';
import { apiVersionForModel } from '@console/kubevirt-plugin/integration-tests/tests/utils/selectors';
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to be imported from @console/internal/module/k8s and not kubevirt-plugin 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.

Good catch!!

@a2batic a2batic force-pushed the pool-component branch 2 times, most recently from 31715a3 to cdd6f90 Compare July 28, 2020 05:53
Jira: https://issues.redhat.com/browse/RHSTOR-1154
Signed-off-by: Kanika Murarka kmurarka@redhat.com
Co-authored-by: Paul Cuzner pcuzner@redhat.com
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 28, 2020
@cloudbehl
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a2batic, cloudbehl, gnehapk

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

/retest

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

@a2batic
Copy link
Contributor Author

a2batic commented Jul 28, 2020

/test e2e-gcp-console

@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-merge-robot openshift-merge-robot merged commit 0594dab into openshift:master Jul 28, 2020
@spadgett spadgett added this to the v4.6 milestone Jul 30, 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 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