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

Ensure that hostname length is not greater than 255 chars #3791

Closed
pcrespov opened this issue Jan 24, 2023 · 2 comments · Fixed by #5379
Closed

Ensure that hostname length is not greater than 255 chars #3791

pcrespov opened this issue Jan 24, 2023 · 2 comments · Fixed by #5379
Assignees

Comments

@pcrespov
Copy link
Member

pcrespov commented Jan 24, 2023

In the past this string went over the limit in some deploys

    hostname: "{{.Node.Hostname}}-{{.Service.Name}}-{{.Task.Slot}}"

we need means to check before deploying or truncate names to guarantee

why no task.slot here? if it ever gets replicated (like when rolling out an update) it will conflict if by chance it starts on the same machine

Originally posted by @sanderegg in #3787 (comment)

@mrnicegyu11 pointed out that this composition might surpass the limit and causes an error difficult to trace (pending adding issue with more details)

The maximum length of a hostname in Linux is typically 255 characters. This limit is specified in the Internet standard for domain names, which defines the maximum length of a fully-qualified domain name (FQDN) to be 255 characters. The hostname is a part of the FQDN, so it must also adhere to this limit.

It's worth to mention that this 255 characters limit is not only for the hostname but also for the FQDN, which includes the domain name. This means that if your domain name is very long, then you may have less space for the hostname.

@pcrespov
Copy link
Member Author

pcrespov commented Jan 24, 2023

Try

services:
  serviceName:
    hostname: "{{.Node.Hostname}}-{{.Node.ID}}-{{.Service.Name}}"
    command:
      - "sh"
      - "-c"
      - "echo $(hostname) && sleep infinity"
    environment:
      HOSTNAME: ${HOSTNAME:=`strings.Truncate(fmt.Sprintf("{{.Node.Hostname}}-{{.Service.Name}}-{{.Task.Slot}}"), 256)`}

@pcrespov
Copy link
Member Author

pcrespov commented Apr 3, 2024

@YuryHrytsuk has reduced the length in #5379

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 a pull request may close this issue.

2 participants