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
Conversation
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>
Codecov ReportAttention:
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. |
return c.components[i], true | ||
} | ||
} | ||
return compsv1alpha1.Component{}, false | ||
} | ||
|
||
func (c *ComponentStore) AddComponent(component compsv1alpha1.Component) { | ||
func (c *ComponentStore) AddPendingComponentForCommit(component compsv1alpha1.Component) error { |
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.
Why need a pending queue as we add component one by one?
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 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.
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.
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>
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.