Skip to content

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Mar 30, 2022

  • Event sources not need to start in particular order this is handled by the processor - it starts after event sources started
  • If asked for a secondary resource from the context for a event source using the name, throws exception if event source not present with that name

@csviri csviri self-assigned this Mar 30, 2022
@csviri
Copy link
Collaborator Author

csviri commented Mar 30, 2022

see related PR where it caused issues: #1103

(issues were not recoginized)

@metacosm
Copy link
Collaborator

  • Event sources not need to start in particular order this is handled by the processor - it starts after event sources started

Are you sure? This used to be a problem…

  • If asked for a secondary resource from the context for a event source using the name, throws exception if event source not present with that name

👍🏼

csviri added 4 commits March 30, 2022 12:48
…eption

- Event sources not need to start in particular order this is handled by the processor - it starts after event sources started
- If asked for a secondary resource from the context for a event source using the name, throws exception if event source not present with that name
@csviri csviri force-pushed the simplify-secondary-from-context branch from 956af6b to 5498355 Compare March 30, 2022 10:48
@csviri
Copy link
Collaborator Author

csviri commented Mar 30, 2022

Are you sure? This used to be a problem…

Yep, the fix in event processor happened after, so now the event processor start after each event source started. So no event processed before all of the started. (The issue before was that the ControllerEventSource did not start before than others, so the cache was not populated soon enough)

…tor/processing/event/EventSourceManagerTest.java

Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>
static String defaultNameFor(EventSource source) {
return source.getClass().getCanonicalName();
// we can have multiple event sources for the same class
return source.getClass().getName() + "#" + source.hashCode();
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 I'm not sure how this would work… Why do we need a name if the generated names are unique already? Also, this only works if the user already has access to the EventSource instance, which kind of defeats the purpose of being able to retrieve it by its name… so something doesn't really work here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous implementation simply does not work when there are multiple instances with the same type. Those would get the same name (there was already a bug with that) so basically not addressable. The default name is only for the case when the user does not want to explicitly address the event source.
So either:

  • there is just 1 event source by type, so the resource is accessed via the context and type
  • the cached resource addressed via a dependent resource

On every other cases it's just needs an explicit name, so the generated name is only basically a workaround to user does not need to think about a name is it's not used anywhere. It's correct in this sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that InformerEventSoure for a config map and a deployment for example still has the same class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What could ne done is just move this to EventSourceInitializer method and make it more explicit that is generated. Would make ti a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok pushed a small refactor regarding to this

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

66.7% 66.7% Coverage
0.0% 0.0% Duplication

@csviri csviri merged commit 2eac098 into main Mar 30, 2022
@csviri csviri deleted the simplify-secondary-from-context branch March 30, 2022 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants