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

Bug 1908598: Fix events filter for persitent dashboard #6856

Merged
merged 1 commit into from Dec 17, 2020

Conversation

a2batic
Copy link
Contributor

@a2batic a2batic commented Oct 6, 2020

  • Activity card component cleanup
  • Filters the PVC event only for volume.beta.kubernetes.io/storage-provisioner: (ceph provisioner) PVCs

Jira: https://issues.redhat.com/browse/RHSTOR-1106
Signed-off-by: Kanika Murarka kmurarka@redhat.com

@openshift-ci-robot openshift-ci-robot added the component/ceph Related to ceph-storage-plugin label Oct 6, 2020
@a2batic
Copy link
Contributor Author

a2batic commented Oct 6, 2020

/assign @afreen23

Comment on lines 82 to 91
) : (
<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>
Copy link
Contributor

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

Copy link
Contributor

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';
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
export const PVC_FILTER_ANNOTATION = 'volume.beta.kubernetes.io/storage-provisioner';
export const PVC_PROVISIONER_ANNOTATION = 'volume.beta.kubernetes.io/storage-provisioner';

Comment on lines 61 to 78
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;
};

Copy link
Contributor

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

Copy link
Contributor

@rawagner rawagner Oct 7, 2020

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 ?

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@cloudbehl
Copy link
Contributor

@a2batic Probably not just for PVC but also the pods that in this namespace.(Pods events in openshift-storage+PVC events)

@afreen23
Copy link
Contributor

afreen23 commented Oct 7, 2020

@a2batic Probably not just for PVC but also the pods that in this namespace.(Pods events in openshift-storage+PVC events)

We return the events for openshift-storage namespace here which covers pods

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 20, 2020
Comment on lines 85 to 90
if (eventKind === PersistentVolumeClaimModel.kind) {
return validPVC().includes(eventObjectName);
}
return eventNamespace === 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.

Suggested change
if (eventKind === PersistentVolumeClaimModel.kind) {
return validPVC().includes(eventObjectName);
}
return eventNamespace === CEPH_STORAGE_NAMESPACE;
return cephPVC[eventObjectName] || eventNamespace === 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.

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.

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 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.

Comment on lines 58 to 79
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]);
Copy link
Contributor

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.

Comment on lines 61 to 67
? (resources?.pvcs?.data as PersistentVolumeClaimKind[]).filter((obj) => {
const annotations = getAnnotations(obj);
return (
annotations &&
annotations[PVC_PROVISIONER_ANNOTATION] &&
isCephProvisioner(annotations[PVC_PROVISIONER_ANNOTATION])
);
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
? (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])

Comment on lines 70 to 80
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
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
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.

Comment on lines 59 to 81
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]);
Copy link
Contributor

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.

Suggested change
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.

Comment on lines 87 to 90
if (eventKind === PersistentVolumeClaimModel.kind) {
return validPVC.includes(eventObjectName);
}
return eventNamespace === 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.

Suggested change
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>
@a2batic
Copy link
Contributor Author

a2batic commented Dec 16, 2020

/test analyze

1 similar comment
@a2batic
Copy link
Contributor Author

a2batic commented Dec 16, 2020

/test analyze

Copy link
Contributor

@bipuladh bipuladh left a comment

Choose a reason for hiding this comment

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

/lgtm

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

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@a2batic a2batic changed the title Fix events filter for persitent dashboard Bug 1908598: Fix events filter for persitent dashboard Dec 17, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Dec 17, 2020
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1908598: Fix events filter for persitent dashboard

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.

@openshift-merge-robot openshift-merge-robot merged commit e0cba4a into openshift:master Dec 17, 2020
@openshift-ci-robot
Copy link
Contributor

@a2batic: All pull requests linked via external trackers have merged:

Bugzilla bug 1908598 has been moved to the MODIFIED state.

In response to this:

Bug 1908598: Fix events filter for persitent dashboard

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.

@spadgett spadgett added this to the v4.7 milestone Jan 7, 2021
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. bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. 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

8 participants