-
Notifications
You must be signed in to change notification settings - Fork 32
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 fallback layer for multi cluster code in External mode #1212
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||
import { StorageClassModel } from '@odf/shared/models'; | ||||||
import { StorageClassResourceKind } from '@odf/shared/types'; | ||||||
import { referenceForModel } from '@odf/shared/utils'; | ||||||
import { | ||||||
WatchK8sResource, | ||||||
useK8sWatchResource, | ||||||
} from '@openshift-console/dynamic-plugin-sdk'; | ||||||
|
||||||
const scResource: WatchK8sResource = { | ||||||
isList: true, | ||||||
kind: referenceForModel(StorageClassModel), | ||||||
}; | ||||||
|
||||||
const fsProvisionerPostFix = '.cephfs.csi.ceph.com'; | ||||||
|
||||||
/** | ||||||
* This hooks is for ODF Client Mode use case only. | ||||||
* ODF client mode doesn't deploy ODF StorageCluster hence falling back to StorageClases. | ||||||
*/ | ||||||
const useClientFallback = (storageClusterName) => { | ||||||
const [storageClasses, storageClassesLoaded, storageClassLoadError] = | ||||||
useK8sWatchResource<StorageClassResourceKind[]>(scResource); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this way it won't even poll when we already have a value for
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this resource is already called in the same page for inventory card. so we can live with this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sense then !! (I did not check the other active components) |
||||||
if (storageClusterName) { | ||||||
return storageClusterName; | ||||||
} | ||||||
|
||||||
const provisioners = storageClasses.map((sc) => sc.provisioner); | ||||||
const fileSystemProvisioner = provisioners.find((item) => | ||||||
item.includes(fsProvisionerPostFix) | ||||||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we replace this with a util function like isCephFSProvisioner? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can do that but I don't think we would have a very specific use case. We could probably go with isOCSProvisioner with more args. Adding it to #1215 |
||||||
); | ||||||
const clusterName = fileSystemProvisioner?.split(fsProvisionerPostFix)?.[0]; | ||||||
return storageClassesLoaded && !storageClassLoadError | ||||||
? clusterName | ||||||
: 'ocs-storagecluster'; | ||||||
bipuladh marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
}; | ||||||
|
||||||
export default useClientFallback; |
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.
under common.ts let's create an enum for each ceph provisioner type and reuse the same here, in this way we can replace the cephStorageProvisioners list under common also can be replaced with enums.
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 need to backport this to 4.15. I will create a seperate PR on top of this for 4.16
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.
and here declare the fsProvisionerPostFix like: '.' + CEPH_FILESYSTEM_PROVISIONER
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.
Tracking at #1215
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