-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix container name creation to generate valid DNS hostnames #2078
Conversation
Fixes #2077 Change-type: patch Signed-off-by: Ramiro Gonzalez <[email protected]>
@ramirogm why do you need this change? Could you describe the problem you are trying to solve? Who is trying to use the full container name as a hostname? The supervisor already configures the serviceName as an alias for all services, see balena-supervisor/src/compose/service.ts Line 189 in a482174
The commit in the container name is used in a bunch of places in the code, including to identify the releases when patching the current state so the way you are doing the transformation might not work. The Web terminal also uses the container name for accessing the services, although that is easier to change. FWIW, I hope that we can remove the serviceId and imageId from the name in the future, making the container name much shorter. |
@pipex This looks to be in response to #2077, which was created from the attached JF ticket in that issue. I'll upload a docker-compose.yml with this message shortly with a local reproduction, if possible. EDIT: I've verified that this can't be reproduced locally @ramirogm. Take the following docker-compose.yml for instance:
The second service has 59 chars by itself, and after the Supervisor adds
I definitely learned about the limits on container name length, so thank you for that, and great work on diving right into the Supervisor codebase! Unfortunately, it looks like the container name length is not the culprit here :( |
Oh, thank you @cywang117, I'll reply on the issue |
@pipex Hi Felipe! Thanks for looking into this. I've just added more context on #2077 (comment) This is an issue we found with container names being used by the docker embedded DNS server to perform reverse DNS lookups. Some apps use that, and is also used by Then I went ahead and created this PR with a candidate solution, just to get this going. The main goal is to get the hostname to be a valid DNS hostname, meaning 1 <= length <= 63. I don't have much knowledge about the dependencies of other projects on that, so I chose a solution that didn't break what's here. The solution is basically to leave the About the specific questions:
On a test device, on a container running
We get the IP from a container with a long but legal name:
and if we do the reverse lookup we get the container name, not the alias:
If I do the same with a container whose name is 64 bytes, the embedded DNS server logs an error.
note:
while on journalctl:
Ok, if we decide to shorten it to 12-chars it should be consistent. Something like https://pkg.go.dev/github.com/docker/docker/pkg/stringid#TruncateID @cywang117 About
I think that this doesn't faithfully reproduces the issue, because the error we found is with the reverse lookup. |
Closing as this should be improved by #2136 |
👍🏼😁Sent from my iPhoneOn 19 Jun 2023, at 19:01, Felipe Lalanne ***@***.***> wrote:
Closed #2078.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Fixes #2077
Change-type: patch
Signed-off-by: Ramiro Gonzalez [email protected]
If this is a regression, consider adding it to #1898!
Description
Fix container name creation to generate valid DNS hostnames
Fixes #2077
Type of change
Patch
How Has This Been Tested?
Unit tests added