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

Apply update strategies app-wide #2230

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Conversation

cywang117
Copy link
Contributor

@cywang117 cywang117 commented Dec 15, 2023

The Supervisor's state engine has some edge cases where it does not respect the update strategy of the app. These edge cases relate to a release update which removes an old service and also adds a new service. This PR fixes those edge cases.

See: https://balena.fibery.io/Work/Improvement/Supervisor-improved-multi-container-updates-1329
Change-type: patch
Closes: #2095
Signed-off-by: Christina Ying Wang [email protected]

@cywang117 cywang117 force-pushed the multi-container-state-apply branch 2 times, most recently from c83496d to 369c358 Compare December 15, 2023 20:24
@cywang117 cywang117 changed the title Multi container state apply Apply update strategies app-wide Dec 18, 2023
@cywang117 cywang117 marked this pull request as ready for review December 20, 2023 21:16
@cywang117 cywang117 requested review from jaomaloy and pipex December 20, 2023 21:17
@pipex pipex force-pushed the multi-container-state-apply branch from 369c358 to a908942 Compare January 3, 2024 14:18
@flowzone-app flowzone-app bot enabled auto-merge January 3, 2024 14:20
src/compose/app.ts Outdated Show resolved Hide resolved
src/compose/app.ts Outdated Show resolved Hide resolved
src/compose/app.ts Outdated Show resolved Hide resolved
@cywang117 cywang117 force-pushed the multi-container-state-apply branch from a908942 to 565f373 Compare January 4, 2024 01:23
@pipex
Copy link
Contributor

pipex commented Jan 4, 2024

Could you add a test for this too? #2095

@cywang117
Copy link
Contributor Author

Could you add a test for this too? #2095

That should be covered under

it('should not infer a kill step for current service A before target service B download finishes with download-then-kill', async () => {

The test case defines current services A & B, and target services A & C. While C is still downloading, the test expects 2 noop steps, one for each of service A & B. When C has finished downloading, only then does the test expect the kill step.

@cywang117 cywang117 force-pushed the multi-container-state-apply branch from 565f373 to 9eb75ef Compare January 4, 2024 20:03
@cywang117
Copy link
Contributor Author

@pipex I made some changes following your feedback. The new changes make it so that the Supervisor fetches new target services even if the update strategy is kill|delete-then-download .

// if kill|delete-then-download, don't kill any services
// before new images in target have been downloaded.
// Services are safe to kill if they are in both current and target
// even if the target image isn't yet ready.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why this is needed. Result of dependenciesMetForServiceKill is not used by getStepsForStrategy if the strategy is kill-then-download or delete-then-download so this code would be redundant. Also this doesn't seem like the most efficient alternative considering this function is called for every service.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, wait, sorry, you changed the getStepsForStrategy but function, but I still don't understand why

@cywang117 cywang117 force-pushed the multi-container-state-apply branch from 96291b9 to e0d5a5f Compare January 14, 2024 01:30
pipex and others added 2 commits January 29, 2024 12:25
Fixes behavior for release updates which removes a service in current state
and adds a new service in target state.

Change-type: patch
Closes: #2095
Signed-off-by: Christina Ying Wang <[email protected]>
@cywang117 cywang117 force-pushed the multi-container-state-apply branch from e0d5a5f to 3afcef2 Compare January 29, 2024 20:27
Copy link
Contributor

@pipex pipex left a comment

Choose a reason for hiding this comment

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

Nice work @cywang117 !

@flowzone-app flowzone-app bot merged commit c31cf8c into master Feb 1, 2024
54 checks passed
@flowzone-app flowzone-app bot deleted the multi-container-state-apply branch February 1, 2024 19:30
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.

Supervisor deletes no longer defined service before finishing update
2 participants