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
Adds Pool creation modal for storageClass form #6024
Conversation
9d31d11
to
afc43b1
Compare
@@ -0,0 +1,10 @@ | |||
export const replicas = { | |||
ReplicaTWO: '2', | |||
ReplicaTHREE: '3', |
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.
There is already one constant defined for replica 3 here - https://github.com/openshift/console/blob/master/frontend/packages/ceph-storage-plugin/src/constants/index.ts#L17
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.
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'; |
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.
These 2 imports need to be moved up before the relative ones.
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.
ack
const PoolStatusComponent: React.FC<PoolStatusComponentProps> = ({ status, name, error = '' }) => { | ||
return ( | ||
<div> | ||
{status === 'progress' && ( |
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 should create a constant for all the status, an enum may be.
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.
ack
<EmptyStateBody>Pool {name} was successfully created</EmptyStateBody> | ||
</EmptyState> | ||
)} | ||
{status === 'failed' && ( |
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.
switch might be better here.
...packages/ceph-storage-plugin/src/components/modals/storage-pool-modal/storage-pool-modal.tsx
Show resolved
Hide resolved
); | ||
|
||
React.useEffect(() => { | ||
k8sGet(OCSServiceModel, OCS_INTERNAL_CR_NAME, CEPH_STORAGE_NAMESPACE) |
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.
K8sGet -> fetchK8s, Just replacing the word will make it work. No extra efforts.
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.
ack
setPoolStatus('created'); | ||
setIsSubmit(false); | ||
setTimeClear(true); | ||
} else if (newPoolLoaded && newPool?.status?.phase === 'ReconcileFailed') { |
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.
Create an enum for all possible phase values.
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.
ack
const timeoutTimer = setTimeout(() => { | ||
setPoolStatus('timeout'); | ||
setIsSubmit(false); | ||
}, 15000); |
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.
15 * SECOND, Constant for SECOND already 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.
ack
...packages/ceph-storage-plugin/src/components/modals/storage-pool-modal/storage-pool-modal.tsx
Outdated
Show resolved
Hide resolved
const [isCompressed, setCompression] = React.useState(false); | ||
const [deviceClass, setdeviceClass] = React.useState(''); | ||
const [poolStatus, setPoolStatus] = React.useState(''); | ||
const [storageClusterLoading, setStorageClusterLoading] = React.useState(true); |
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.
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.
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.
ack
</EmptyState> | ||
)} | ||
{status === 'timeout' && ( | ||
<EmptyState> |
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.
<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?
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.
ack
if (poolStatus === 'created') { | ||
onPoolCreation(newPoolName); | ||
} | ||
close(); |
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 move this to a function and use it 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.
ack
!poolStatus && | ||
!storageClusterError && | ||
storageClusterReady && | ||
cephClusterObj[0]?.status?.phase === 'Ready' ? ( |
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.
Moving these conditions to a function and calling here, might be a better approach as so many conditions are checked.
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.
ack
@@ -0,0 +1,27 @@ | |||
//@import '../../../../console-shared/src/styles/skeleton-screen.scss'; |
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.
Why _
for the file name?
</div> | ||
); | ||
} | ||
return <>{loaded || poolDataLoaded || <LoadingInline />}</>; |
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.
Shouldn't this be {(loaded || poolDataLoaded) && <LoadingInline />}
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.
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.'; |
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 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.'; |
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.
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> |
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.
<div> | |
<> |
</EmptyStateBody> | ||
</EmptyState> | ||
)} | ||
</div> |
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.
</div> | |
</> |
const [timeoutClear, setTimeClear] = React.useState(false); | ||
const [timer, setTimer] = React.useState<NodeJS.Timer>(null); | ||
|
||
const poolResource = React.useMemo(() => { |
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.
Why are we pooling single pool?
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 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') { |
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.
Cluster might not be ready because of something with NooBaa & will not let user create pool?
8624739
to
4fd777b
Compare
ModalComponentProps, | ||
ModalFooter, | ||
} from '@console/internal/components/factory/modal'; | ||
import { apiVersionForModel } from '@console/kubevirt-plugin/integration-tests/tests/utils/selectors'; |
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.
this needs to be imported from @console/internal/module/k8s
and not kubevirt-plugin
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.
Good catch!!
31715a3
to
cdd6f90
Compare
Jira: https://issues.redhat.com/browse/RHSTOR-1154 Signed-off-by: Kanika Murarka kmurarka@redhat.com Co-authored-by: Paul Cuzner pcuzner@redhat.com
/lgtm |
[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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test e2e-gcp-console |
/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. |
Enable user to create a Pool while creating OCS backed storage Class.
Jira: https://issues.redhat.com/browse/RHSTOR-1154
Signed-off-by: Kanika Murarka kmurarka@redhat.com
Co-authored-by: Paul Cuzner pcuzner@redhat.com