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
filter deployments created by event sources #4770
filter deployments created by event sources #4770
Conversation
/retest |
9467713
to
fea657a
Compare
const allEventSourceModels: K8sKind[] = [ | ||
EventSourceCronJobModel, | ||
EventSourceContainerModel, | ||
EventSourceApiServerModel, | ||
EventSourceCamelModel, | ||
EventSourceKafkaModel, | ||
EventSourceServiceBindingModel, | ||
]; |
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 see if there is a way to handle it in a generic way i.e without have check for specific models for ES as dynamic sources will in introduced soon. Then this may not work
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 still don't have an solution for dynamic event sources, so dealing with the static set is ok for now.
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.
i suggested to create a util which will roll up uid's for eventsource and then check for it against ownerefrences in deployments if they match filter it out, I think this should do what we want instead of using all ES models.
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.
I have used the knEventSources
which was already present in the scope, passed it to the filterNonKnativeDeployments
function as an optional argument to use as reference to filter the deployments for event sources.
/kind feature |
4d52ebb
to
f52c588
Compare
/retest |
2 similar comments
/retest |
/retest |
@nemesis09 pls rebase with master |
sampleEventSourceApiServer.data[0], | ||
]); | ||
expect(filteredResources).toHaveLength(1); | ||
expect(filteredResources[0].metadata?.name).toEqual('analytics-deployment'); |
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.
nit: Is there a chance that mock data will not have metadata.name?
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.
I didn't find any such event source yet. although metadata itself is optional.
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.
@nemesis09 i think what @sahil143 mean is these are mock data so it'll always have metadata.name
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 test checks of the deployments for knative service and event sources have been filtered out, leaving behind only the deployment which was not associated with either knative service or event source, i.e analytics-deployment
const KNATIVE_EVENTS_CAMEL = 'sources.eventing.knative.dev/camelSource'; | ||
const KNATIVE_EVENTS_KAFKA = 'sources.eventing.knative.dev/kafkaSource'; | ||
const isEventSourceKind = (uid: string): boolean => | ||
!!eventSources?.find((eventSource) => eventSource.metadata?.uid === uid); | ||
return _.filter(resources, (d) => { | ||
return ( | ||
!_.get(d, ['metadata', 'labels', KNATIVE_CONFIGURATION]) && |
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.
nit: third param for _.get
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.
done
!_.get(d, ['metadata', 'labels', KNATIVE_EVENTS_APISERVER]) && | ||
!_.get(d, ['metadata', 'labels', KNATIVE_EVENTS_CAMEL]) && | ||
!_.get(d, ['metadata', 'labels', KNATIVE_EVENTS_KAFKA]) | ||
!isEventSourceKind(d.metadata?.ownerReferences ? d.metadata.ownerReferences[0].uid : '') |
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.
!isEventSourceKind(d.metadata?.ownerReferences ? d.metadata.ownerReferences[0].uid : '') | |
!isEventSourceKind(d.metadata?.ownerReferences?.[0].uid) |
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.
done
const KNATIVE_EVENTS_CAMEL = 'sources.eventing.knative.dev/camelSource'; | ||
const KNATIVE_EVENTS_KAFKA = 'sources.eventing.knative.dev/kafkaSource'; | ||
const isEventSourceKind = (uid: string): boolean => | ||
!!eventSources?.find((eventSource) => eventSource.metadata?.uid === uid); |
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.
!!eventSources?.find((eventSource) => eventSource.metadata?.uid === uid); | |
uid && !!eventSources?.find((eventSource) => eventSource.metadata?.uid === uid); |
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.
done
3816894
to
4201a89
Compare
4201a89
to
00b9096
Compare
/approve Verified locally works as expected |
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: invincibleJai, nemesis09, sahil143 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. |
/retest Please review the full test history for this PR and help us cut down flakes. |
Fixes:
https://issues.redhat.com/browse/ODC-3011
Analysis / Root cause:
Some Event Sources have associated deployment which are shown in topology view along with the eventSource e.g in case of kafka and api server source.
Solution Description:
Topology view should only show eventSource and not the deployments associated with it
Screens:
Test Coverage:
Browser Conformance: