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
Bug 1908598: Fix events filter for persitent dashboard #6856
Conversation
/assign @afreen23 |
) : ( | ||
<div className="co-status-card__alerts-body"> | ||
<div className="co-status-card__alert-item co-status-card__alert-item--loading"> | ||
<div className="skeleton-activity__dashboard" /> | ||
<div className="skeleton-activity__dashboard" /> | ||
<div className="skeleton-activity__dashboard" /> | ||
<div className="skeleton-activity__dashboard" /> | ||
<div className="skeleton-activity__dashboard" /> | ||
</div> | ||
</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.
Can we pass an additional prop to the RecentEventsBody
to handle this ?
@rawagner ^^ 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.
you could merge pvcs.loaded
prop with events.loaded
. Something like
const events = {...resources.events, loaded: resources.events.loaded && resources.pvcs.loaded}
return (
<RecentEventsBody
events={events}
filter={ocsEventNamespaceKindFilter}
/>
)
@@ -19,6 +19,7 @@ export const ATTACHED_DEVICES_ANNOTATION = 'cluster.ocs.openshift.io/local-devic | |||
export const DASHBOARD_LINK = '/dashboards/persistent-storage'; | |||
export const AVAILABLE = 'Available'; | |||
export const OSD_REMOVAL_TEMPLATE = 'ocs-osd-removal'; | |||
export const PVC_FILTER_ANNOTATION = 'volume.beta.kubernetes.io/storage-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.
export const PVC_FILTER_ANNOTATION = 'volume.beta.kubernetes.io/storage-provisioner'; | |
export const PVC_PROVISIONER_ANNOTATION = 'volume.beta.kubernetes.io/storage-provisioner'; |
const pvcItems = resources?.pvcs as FirehoseResult<PersistentVolumeClaimKind[]>; | ||
if (eventKind === PersistentVolumeClaimModel.kind) { | ||
const pvcObj = _.find( | ||
pvcItems.data, | ||
(obj: PersistentVolumeClaimKind) => obj?.metadata?.name === event?.involvedObject?.name, | ||
); | ||
const annotations = getAnnotations(pvcObj); | ||
return ( | ||
annotations && | ||
annotations[PVC_FILTER_ANNOTATION] && | ||
isCephProvisioner(annotations[PVC_FILTER_ANNOTATION]) | ||
); | ||
} | ||
return eventNamespace === 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.
It would be better to create a map for pvcName-annotation prior and then utilize in this filter function. Both events and pvc can go high in numbers and you will end up with n^2
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.
FYI the filter will show only events for existing PVCs. Its a tradeoff between showing events for all PVCs - non ceph ones but includes deleted ones too and only existing ceph PVCs. Is that really what you prefer ?
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.
Yes, thats what we want to do here as per UX
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.
The reason being , OCS supports ceph based storage classes only. PV/PVCs created by other storage classes should be filtered out.
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.
@afreen23, as per @rawagner's comment, if we keep this filter, the events of deleted PVC will no longer be listed (being Ceph or non-ceph), the Ceph one as well which were appearing before will also disappear as the events won't match any PVC in pvc list, doesn't that take away the purpose of showing events?
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 sorted this offline, commenting for reference here: Its a tradeoff but we need to have ocs based events only in the dashboard. All events can be looked anytime in console.
@a2batic Probably not just for PVC but also the pods that in this namespace.(Pods events in openshift-storage+PVC events) |
fdfe2e7
to
3d1d287
Compare
if (eventKind === PersistentVolumeClaimModel.kind) { | ||
return validPVC().includes(eventObjectName); | ||
} | ||
return eventNamespace === 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.
if (eventKind === PersistentVolumeClaimModel.kind) { | |
return validPVC().includes(eventObjectName); | |
} | |
return eventNamespace === CEPH_STORAGE_NAMESPACE; | |
return cephPVC[eventObjectName] || eventNamespace === 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.
If we are checking on the name of PVC, then we dont need to check for kind.
Also, instead of having a function called everytime, you can create a set/map at once and use that.
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 check for validPVC()
array only for PVC name, we need not check it for every resource.
Also, for validPVC()
, useCallback
is used, so number of calls are reduced, not sure we should maintenance a map, as we are already maintaining an array.
const validPVC = React.useCallback((): string[] => { | ||
const pvcList = resources.pvcs | ||
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => { | ||
const annotations = getAnnotations(obj); | ||
return ( | ||
annotations && | ||
annotations[PVC_PROVISIONER_ANNOTATION] && | ||
isCephProvisioner(annotations[PVC_PROVISIONER_ANNOTATION]) | ||
); | ||
}) | ||
: []; | ||
const pvcNames = _.reduce( | ||
pvcList, | ||
(res, pvcObj) => { | ||
const name = getName(pvcObj); | ||
res.push(name); | ||
return res; | ||
}, | ||
[], | ||
); | ||
return pvcNames; | ||
}, [resources]); |
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.
Since you are memoizing the value, so you should use "useMemo` , but I dont think any would help, since resources is an object and you will get the calculation always running.
Also I would fetch the names at once instead creating a pvc list, then getting pvc names.
I have not checked, but withDashboardResources
memoizes the values I guess.
3d1d287
to
ee36f51
Compare
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => { | ||
const annotations = getAnnotations(obj); | ||
return ( | ||
annotations && | ||
annotations[PVC_PROVISIONER_ANNOTATION] && | ||
isCephProvisioner(annotations[PVC_PROVISIONER_ANNOTATION]) | ||
); |
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.
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => { | |
const annotations = getAnnotations(obj); | |
return ( | |
annotations && | |
annotations[PVC_PROVISIONER_ANNOTATION] && | |
isCephProvisioner(annotations[PVC_PROVISIONER_ANNOTATION]) | |
); | |
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => | |
isCephProvisioner(getAnnotations(obj)?.[PVC_PROVISIONER_ANNOTATION]) |
const pvcNames = _.reduce( | ||
pvcList, | ||
(res, pvcObj) => { | ||
const name = getName(pvcObj); | ||
res.push(name); | ||
return res; | ||
}, | ||
[], | ||
); | ||
return pvcNames; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
const pvcNames = _.reduce( | |
pvcList, | |
(res, pvcObj) => { | |
const name = getName(pvcObj); | |
res.push(name); | |
return res; | |
}, | |
[], | |
); | |
return pvcNames; | |
// eslint-disable-next-line react-hooks/exhaustive-deps | |
return pvcList?.map(getName); |
I also don't see the need to disable the eslint rule.
const validPVC = React.useMemo((): string[] => { | ||
const pvcList = resources.pvcs | ||
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => { | ||
const annotations = getAnnotations(obj); | ||
return ( | ||
annotations && | ||
annotations[PVC_PROVISIONER_ANNOTATION] && | ||
isCephProvisioner(annotations[PVC_PROVISIONER_ANNOTATION]) | ||
); | ||
}) | ||
: []; | ||
const pvcNames = _.reduce( | ||
pvcList, | ||
(res, pvcObj) => { | ||
const name = getName(pvcObj); | ||
res.push(name); | ||
return res; | ||
}, | ||
[], | ||
); | ||
return pvcNames; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [resources.pvcs]); |
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.
resources.pvcs
is an array of objects, I would suggest you to use deepCompareMemoize
and use the memoized value of resources. pvcs.
You could completely eliminate this useMemo block by parsing the pvcList normally and then memoizing the list of PVC names. That should be more efficient.
const validPVC = React.useMemo((): string[] => { | |
const pvcList = resources.pvcs | |
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => { | |
const annotations = getAnnotations(obj); | |
return ( | |
annotations && | |
annotations[PVC_PROVISIONER_ANNOTATION] && | |
isCephProvisioner(annotations[PVC_PROVISIONER_ANNOTATION]) | |
); | |
}) | |
: []; | |
const pvcNames = _.reduce( | |
pvcList, | |
(res, pvcObj) => { | |
const name = getName(pvcObj); | |
res.push(name); | |
return res; | |
}, | |
[], | |
); | |
return pvcNames; | |
// eslint-disable-next-line react-hooks/exhaustive-deps | |
}, [resources.pvcs]); | |
const validPVC = (resources.pvcs?.data || [] as PersistentVolumeClaimKind[]).filter( | |
(obj) => isCephProvisioner(getAnnotations(obj)?.[PVC_PROVISIONER_ANNOTATION])) | |
.map(getName); | |
const memoizedPVCNames = useDeepCompareMemoize(validPVC, true); |
Use memoizedPVCNames
everywhere.
if (eventKind === PersistentVolumeClaimModel.kind) { | ||
return validPVC.includes(eventObjectName); | ||
} | ||
return eventNamespace === 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.
if (eventKind === PersistentVolumeClaimModel.kind) { | |
return validPVC.includes(eventObjectName); | |
} | |
return eventNamespace === CEPH_STORAGE_NAMESPACE; | |
return (eventKind === PersistentVolumeClaimModel.kind) ? validPVC.includes(eventObjectName) : eventNamespace === CEPH_STORAGE_NAMESPACE; |
Jira: https://issues.redhat.com/browse/RHSTOR-1106 Signed-off-by: Kanika Murarka <kmurarka@redhat.com>
ee36f51
to
b2ea878
Compare
/test analyze |
1 similar comment
/test analyze |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a2batic, bipuladh 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 |
@a2batic: This pull request references Bugzilla bug 1908598, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
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. |
@a2batic: All pull requests linked via external trackers have merged: Bugzilla bug 1908598 has been moved to the MODIFIED state. In response to this:
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. |
volume.beta.kubernetes.io/storage-provisioner: (ceph provisioner)
PVCsJira: https://issues.redhat.com/browse/RHSTOR-1106
Signed-off-by: Kanika Murarka kmurarka@redhat.com