mailtrain icon indicating copy to clipboard operation
mailtrain copied to clipboard

Fixed issues with Zone-MTA to resolve dns

Open aamirmhussain opened this issue 4 years ago • 3 comments

Fixed issues with Zone-MTA regarding dns resolution by minimizing dns resolution time. This will fix connection timed out errors and minimize mailtrain load time

mailtrain    | ERR! Queue/47 Could not initialize database: connection timed out
mailtrain    | ERR! Child/default/47 [] Sender process for default exited with 1

depends_on ensures all other container services are up before mailtrain container starts links ensure proper network connectivity for mailtrain container with rest of the container services

aamirmhussain avatar Jun 11 '21 16:06 aamirmhussain

This change will also solve the following issue https://github.com/Mailtrain-org/mailtrain/issues/977

aamirmhussain avatar Jun 11 '21 16:06 aamirmhussain

Thank you for the patch. I have doubts about why it is needed. The links section are just aliases and as per the documentation, they are not needed for services to communicate (https://docs.docker.com/compose/compose-file/compose-file-v2/#links). The depends_on only tells in which order services are started. But it does not wait for a service to be up and ready. Waiting for other services to become ready happens in https://github.com/Mailtrain-org/mailtrain/blob/v2/docker-entrypoint.sh . So from this perspective, I don't really understand the patch.

bures avatar Jun 11 '21 22:06 bures

Yes, links (to other containers) are not needed, when two containers belong to the same docker network. Compose will also provide hostnames that map to a services definition, so they can be easily reached. This is solved via an internal DNS to Docker. Links were an early Docker feature, that have been suitable replaced by depends_on and healthcheck.

The https://docs.docker.com/compose/compose-file/compose-file-v2/#depends_on specification for a v2 Compose file knows a condition: service_healthy that will wait for a dependant service to pass its healtcheck, before attempting to run the container.

See https://docs.docker.com/compose/compose-file/compose-file-v2/#healthcheck

Since the Compose v3 format used for Mailtrain v2 does not know the condition: service_healthy format, it comes to my mind to ask, if this PR could be reworked to introduce a dedicated user network for connecting the database services to the frontend, which is currently not present, and to follow the official guideline for maintaining a startup order, instead?

almereyda avatar Dec 19 '21 16:12 almereyda