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

Workflow backends: ignore on hot reloading #7433

Merged
merged 12 commits into from Jan 30, 2024

Conversation

JoshVanL
Copy link
Contributor

@JoshVanL JoshVanL commented Jan 23, 2024

Updates the hot reloading reconciler so that Daprd will log and error and ignore workflow backends when they are hot reloaded.

Adds integration tests for daprd ensuring workflow backends can be loaded on boot.

Adds tests to ensure daprd will log an error on a workflow backend being hot reloaded.

Adds tests to ensure multiple workflow backends cannot be loaded at once.

closes #7409

@JoshVanL JoshVanL requested review from a team as code owners January 23, 2024 17:45
func (wfbe *workflowBackend) Init(ctx context.Context, comp compapi.Component) error {
wfbe.lock.Lock()
defer wfbe.lock.Unlock()
func (w *workflowBackend) Init(ctx context.Context, comp compapi.Component) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't rename variables for no reason, it causes unnecessary merge conflicts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By convention we use single letter variable names for method receiver variables. This gives overhead to the reader as it is unexpected. wfbe initially tripped my up as I was confused as to where this variable was coming from until I realized it was the receiver.

pkg/runtime/hotreload/reconciler/reconciler.go Outdated Show resolved Hide resolved
pkg/runtime/hotreload/reconciler/reconciler.go Outdated Show resolved Hide resolved
pkg/runtime/hotreload/reconciler/reconciler.go Outdated Show resolved Hide resolved
wg.Wait()

errs := make([]error, 0, len(group.resources))
for range group.resources {
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
for range group.resources {
for i := 0; i < len(group.resources); i++ {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the benefit of creating the variable i here?

@@ -48,7 +49,7 @@ type ComponentStore struct {
pubSubs map[string]PubsubItem
topicRoutes map[string]TopicRoutes
workflowComponents map[string]workflows.Workflow
workflowBackends map[string]wfbe.WorkflowBackend
workflowBackends map[string]backend.Backend
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the correct type for the workflow backend implementation interface. Notice the other component types are using the interface types defined in components-contrib however backends is using durabletask-go directly. This wasn't picked up before as this field wasn't previously being used (workflowbackend.go didn't exist). wfbe.WorkflowBackend is a factory func type.

@artursouza artursouza added the autoupdate DaprBot will keep the Pull Request up to date with master branch label Jan 23, 2024
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

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

Comparison is base (db1ece4) 62.30% compared to head (0607ef9) 62.29%.

Files Patch % Lines
pkg/runtime/hotreload/reconciler/component.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7433      +/-   ##
==========================================
- Coverage   62.30%   62.29%   -0.01%     
==========================================
  Files         244      244              
  Lines       22203    22210       +7     
==========================================
+ Hits        13833    13836       +3     
  Misses       7232     7232              
- Partials     1138     1142       +4     

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

JoshVanL added a commit to JoshVanL/dapr that referenced this pull request Jan 24, 2024
Updates the hot reloading reconciler so that Daprd will exit error when
a actor state store enabled Component is hot reloaded. This is chosen
because today, the actors subsystem is not written with any closing or
dynamic support. Doing so will cause panics/corruption in its current
state.

Exiting error is the safest option as this ensures consistency across a
replica set and ensures there is no surprise for the user that behaviour
does not match given configuration.

See also dapr#7433

Signed-off-by: joshvanl <me@joshvanl.dev>
JoshVanL added a commit to JoshVanL/dapr that referenced this pull request Jan 25, 2024
Updates the hot reloading reconciler so that Daprd will exit error when
a actor state store enabled Component is hot reloaded. This is chosen
because today, the actors subsystem is not written with any closing or
dynamic support. Doing so will cause panics/corruption in its current
state.

Exiting error is the safest option as this ensures consistency across a
replica set and ensures there is no surprise for the user that behaviour
does not match given configuration.

See also dapr#7433

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL JoshVanL force-pushed the hotreloading-workflowbackends-exit1 branch from 4450de0 to e05b4b9 Compare January 26, 2024 14:03
@JoshVanL JoshVanL mentioned this pull request Jan 26, 2024
Updates the hot reloading reconciler so that Daprd will exit error when
a workflowbackend Component is hot reloaded. This is chosen because
today, the actors and workflow subsystems are not written with any
closing or dynamic support. Doing so will cause panics/corruption in its
current state.

Exiting error is the safest option as this ensures consistency across a
replica set and ensures there is no surprise for the user that
behaviour does not match given configuration.

Adds integration tests for daprd ensuring workflow backends can be
loaded on boot.

Adds tests to ensure daprd will exist error on a workflow backend being
hot reloaded.

We should do the same for actor state store and the actor subsystem.

Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
registered

Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL JoshVanL force-pushed the hotreloading-workflowbackends-exit1 branch from e05b4b9 to ba58da7 Compare January 29, 2024 13:12
@JoshVanL JoshVanL changed the title Workflow backends: exit error on hot reload Workflow backends: ignore on hot reloading Jan 29, 2024
yaron2 pushed a commit that referenced this pull request Jan 30, 2024
* Exit error if actor state store hot reloaded

Updates the hot reloading reconciler so that Daprd will exit error when
a actor state store enabled Component is hot reloaded. This is chosen
because today, the actors subsystem is not written with any closing or
dynamic support. Doing so will cause panics/corruption in its current
state.

Exiting error is the safest option as this ensures consistency across a
replica set and ensures there is no surprise for the user that behaviour
does not match given configuration.

See also #7433

Signed-off-by: joshvanl <me@joshvanl.dev>

* Remove expected workflow.dapr component from actorastate tests

Signed-off-by: joshvanl <me@joshvanl.dev>

* Increase assert Eventually timeout

Signed-off-by: joshvanl <me@joshvanl.dev>

* Only log error and don't exit error when reocnciling actor state store

Signed-off-by: joshvanl <me@joshvanl.dev>

---------

Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Co-authored-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
artursouza
artursouza previously approved these changes Jan 30, 2024
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
@artursouza artursouza merged commit 2fe1316 into dapr:master Jan 30, 2024
30 of 31 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.

Test Integration: Workflow HotReload testing
4 participants