minio / sidekick

High Performance HTTP Sidecar Load Balancer
GNU Affero General Public License v3.0
546 stars 82 forks source link

v2 is rejecting `tasks.*` (Docker Swarm) hostnames #69

Closed francisfontoura closed 2 years ago

francisfontoura commented 2 years ago

Expected Behavior

Command sidekick -p /minio/health/ready http://tasks.s3_minio{1...4} should work like v1.

Current Behavior

Console logs sidekick: <ERROR> invalid endpoint "http://tasks.s3_minio1:9000" and health check path "/minio/health/ready": invalid hostname and Sidekick fails to start.

Possible Solution

Sidekicks relies on github.com/minio/pkg/net package to validate endpoint argument. The library identifies the hostname as FQDN and test against ^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$ regular expression, what fails because of _ character.

Steps to Reproduce (for bugs)

N/A.

Context

tasks.* Docker Swarm hostnames are useful in cross stack network access between containers and always follows the tasks.${Stack.Name}_${Service.Name} pattern.

Regression

No.

Your Environment

harshavardhana commented 2 years ago

is not a valid DNS name @francisfontoura - however that it's supported via Docker it is incorrect to have such hostnames use something like - instead of ``

francisfontoura commented 2 years ago

According to RFC 2181, section 11 "Name syntax:

The DNS itself places only one restriction on the particular labels that can be used to identify resource records. That one restriction relates to the length of the label and the full name. [...] Implementations of the DNS protocols must not place any restrictions on the labels that can be used.

Despite RFC 952 defines legal internet host names restrictions, internal Docker Swarm DNS resolution doesn't have to follow It, because it's not about "internet host names", only DNS. tasks.* names are not FQDNs, but are valid DNS addresses and, IMO at least, should not be refused by MinIO Sidekick, nor by minio/pkg/net.

Hope you reconsider. Thanks for attention.

harshavardhana commented 2 years ago

Despite RFC 952 defines legal internet host names restrictions, internal Docker Swarm DNS resolution doesn't have to follow It, because it's not about "internet host names", only DNS. tasks.* names are not FQDNs, but are valid DNS addresses and, IMO at least, should not be refused by MinIO Sidekick, nor by minio/pkg/net.

No, for now, we may not support it - we have rejected similar requests in the past. Please change your hostnames to comply with the RFC 952

francisfontoura commented 2 years ago

Unfortunately, I cannot. As explained in "Context" section of post, the "invalid" character _ is put by Docker:

[...] follows the tasks.${Stack.Name}_${Service.Name} pattern.

In my example, s3 is stack's name and minio1 is service's. There's no way to change "underscore" intentionally. Until you reconsider, we're stuck on v1. Thanks anyway.