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

Wait for service dependencies to be running #2393

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Conversation

pipex
Copy link
Contributor

@pipex pipex commented Dec 5, 2024

This fixes a regression where dependencies would only be started in order and would start the dependent service if its dependency had been started at some point in the past, regardless of the running condition.

This makes the behavior more consistent with docker compose where the dependency needs to be
running or healthy
for the service to be started.

Change-type: patch

@@ -881,7 +885,7 @@ class AppImpl implements App {
// different to a dependency which is in the servicePairs below, as these
// are services which are changing). We could have a dependency which is
// starting up, but is not yet running.
const depInstallingButNotRunning = _.some(targetApp.services, (svc) => {
const depInstallingButNotRunning = _.some(this.services, (svc) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fix. Services in the target app are generally configured a running: true so dependencies would get started without waiting for the status of the actual container

}
return [generateStep('start', { target })];
} else {
// Wait for dependencies to be started
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need this noop here to avoid settling the state too early

If the dependency requires a reboot, this will prevent the release of locks :(

@pipex pipex marked this pull request as draft December 5, 2024 14:48
@pipex pipex requested a review from cywang117 December 5, 2024 14:48
@pipex pipex marked this pull request as ready for review December 5, 2024 15:54
@flowzone-app flowzone-app bot enabled auto-merge December 5, 2024 20:18
@@ -1294,29 +1293,31 @@ describe('compose/app', () => {
.to.deep.include({ serviceName: 'main' });
});

it('should not try to start a container which has exited and has restart policy of no', async () => {
it('should not try to start a container which has exited', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm misunderstanding this test change, but wouldn't we want to restart a container that has exited with an error code if the restart policy is always or on-failure? Doesn't this test case go against that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The supervisor never restarts a container that has already been started before. The restart policy is handled by the engine. The only exception is for the engine/hostOS race bug

const hostRaceErrorRegex = new RegExp(

This fixes a regression where dependencies would only be started in
order and would start the dependent service if its dependency had been
started at some point in the past, regardless of the running condition.

This makes the behavior more consistent with docker compose where the
[dependency needs to be
running or healthy](https://github.com/docker/compose/blob/69a83d1303a103d82b05d512baf273244b4dbd94/pkg/compose/convergence.go#L441) for the service to be started.

Change-type: patch
Copy link
Contributor

@cywang117 cywang117 left a comment

Choose a reason for hiding this comment

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

LGTM!

@flowzone-app flowzone-app bot merged commit 1a45805 into master Dec 18, 2024
61 checks passed
@flowzone-app flowzone-app bot deleted the depends-on-fix branch December 18, 2024 18:47
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