Faas: docker-compose.yml uses depends_on (which is ignored by stack deploy)

Created on 20 Sep 2017  路  13Comments  路  Source: openfaas/faas

In the version _47d0fdcf_ of the file faas/docker-compose.yml in several services depends_on is used.
In deploy_stack.sh this file used with docker stack deploy.
Unfortunately the compose file reference points out that depends_on is ignored then deploying a stack using a compose file version 3.x, see https://docs.docker.com/compose/compose-file/#depends_on

I've not tested it but possibly this can result in some problems setting up faas on Swarm.

hacktoberfest proposal

Most helpful comment

For reference - https://github.com/moby/moby/issues/30404#issuecomment-274825244

depends_on is a no-op when used with docker stack deploy. Swarm mode services are restarted when they fail, so there's no reason to delay their startup. Even if they fail a few times, they will eventually recover.

All 13 comments

So we've not run into those issues yet, but the services have a restart policy which should allow them to be rescheduled. 3.x is needed for Swarm secrets - do you have any other suggestions?

Maybe using something like vishnubob/wait-for-it or jwilder/dockerize in the services which are depending from e.g. _gateway_, simply waiting for a reachable port.

p.s.: another alternative would be to implement the circuit breaker pattern in the containers which use e.g. gateway.

@johnmccabe @rgee0 - should we drop the depends_on then?

@alexellis yep I think so, they're ignored as @hcguersoy points out. Docker are pushing stack users towards using healthchecks and fault tolerant service implementations - ie you shouldn't blow up when a service you depend on isn't there, you should just wait for it to appear.

Derek add label: proposal

@hcguersoy if you'd like to submit a PR with those removed for docker-compose.* we'll merge it 馃憤

@alexellis If I find some time I'll create a PR involving some changes making the components somewhat resilient and removing the depends_on directives in the compose file.

Thank you 馃憤 The NATS + gateway for instance already has retry logic in place in docker-compose.extended.yml

We could simulate errors in the other services

Hacktoberfest - remove all depends_on metadata in compose files.

For reference - https://github.com/moby/moby/issues/30404#issuecomment-274825244

depends_on is a no-op when used with docker stack deploy. Swarm mode services are restarted when they fail, so there's no reason to delay their startup. Even if they fail a few times, they will eventually recover.

We have a PR for this now

Yeah I know, have commented on it, added this here to give more background to the reason its been deprecated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

derailed picture derailed  路  6Comments

maxbry picture maxbry  路  7Comments

jvice152 picture jvice152  路  7Comments

alexellis picture alexellis  路  7Comments

ndarilek picture ndarilek  路  4Comments