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

Enforce Component names to be unique #7195

Merged
merged 7 commits into from Nov 21, 2023

Conversation

JoshVanL
Copy link
Contributor

Currently in standalone mode, it is possible to load multiple components with the same name but of different types. This is problematic as it can produce undefined behaviour in Daprd where global state indexed on Component name (like state encryption) can "leak" to another Component. It also makes it impossible to implement the hot reloader reconciler as that controller is level based, and without a single unique name to index on, the reconciler cannot determine which Components have been deleted/editted. It is also confusing to different requirements to Kubernetes whether a Component name must be unique within a namespace.

PR implements a check to ensure that Component names are unique. The component store implements a pending & lock mechanism to ensure that another Component of the same name cannot be added whilst another is initialising.

Adds an integration test to ensure daprd errors when multiple Components with the same name are added.

Currently in standalone mode, it is possible to load multiple components
with the same name but of different types. This is problematic as it can
produce undefined behaviour in Daprd where global state indexed on
Component name (like state encryption) can "leak" to another Component.
It also makes it impossible to implement the hot reloader reconciler as
that controller is level based, and without a single unique name to
index on, the reconciler cannot determine which Components have been
deleted/editted. It is also confusing to different requirements to
Kubernetes whether a Component name _must_ be unique within a namespace.

PR implements a check to ensure that Component names are unique. The
component store implements a pending & lock mechanism to ensure that
another Component of the same name cannot be added whilst another is
initialising.

Adds an integration test to ensure daprd errors when multiple Components
with the same name are added.

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL JoshVanL requested review from a team as code owners November 15, 2023 17:36
Signed-off-by: joshvanl <me@joshvanl.dev>
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (6d000be) 64.89% compared to head (4c100c4) 64.92%.

Files Patch % Lines
pkg/runtime/processor/processor.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7195      +/-   ##
==========================================
+ Coverage   64.89%   64.92%   +0.03%     
==========================================
  Files         221      221              
  Lines       21003    21004       +1     
==========================================
+ Hits        13629    13637       +8     
+ Misses       6216     6212       -4     
+ Partials     1158     1155       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return c.components[i], true
}
}
return compsv1alpha1.Component{}, false
}

func (c *ComponentStore) AddComponent(component compsv1alpha1.Component) {
func (c *ComponentStore) AddPendingComponentForCommit(component compsv1alpha1.Component) error {
Copy link
Member

Choose a reason for hiding this comment

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

Why need a pending queue as we add component one by one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it is necessarily true when we introduce hot reloading. Adding the name as pending means we can reserve name before committing when Init is successful.

Copy link
Member

Choose a reason for hiding this comment

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

With hot reloading components can be updated in the sidecar in parallel, as opposed to being initialized sequentially when loaded at startup.

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL JoshVanL added the autoupdate DaprBot will keep the Pull Request up to date with master branch label Nov 20, 2023
@yaron2 yaron2 merged commit a86f9d6 into dapr:master Nov 21, 2023
20 of 22 checks passed
@JoshVanL JoshVanL added this to the v1.13 milestone Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoupdate DaprBot will keep the Pull Request up to date with master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants