pygmystack / pygmy

the pygmy stack is a container stack for local development
MIT License
25 stars 13 forks source link

[bug] Resolver file on macOS has incorrect file name #356

Closed ocean90 closed 2 years ago

ocean90 commented 2 years ago

Describe the bug On macOS 12.0.1 (21A559) the domain docker.amazee.io can't be resolved because the resolver file is named docker.amazee.io.conf but needs to match the domain name, in this case docker.amazee.io.

To Reproduce Steps to reproduce the behavior:

  1. Install pygmy-go
  2. Run pygmy-go up
  3. Run ping docker.amazee.io
  4. See error: ping: cannot resolve docker.amazee.io: Unknown host

With fix:

  1. Run sudo mv /etc/resolver/docker.amazee.io.conf /etc/resolver/docker.amazee.io
  2. Run ping docker.amazee.io
  3. See no error.

Expected behavior The ping command resolves the domain to 127.0.0.1.

Output

❯ scutil --dns | grep docker.amazee.io -A 5
  domain   : docker.amazee.io.conf
  nameserver[0] : 127.0.0.1
  port     : 6053
  flags    : Request A records, Request AAAA records
  reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)

Additional context The file name was changed in https://github.com/fubarhouse/pygmy-go/commit/8ac4871a90a6f465a61e0b52f4e3d955ab73dc9c.

Exported configuration

output.yml ``` yaml Defaults: true Domain: docker.amazee.io Keys: null Networks: amazeeio-network: Attachable: false ConfigFrom: Network: "" ConfigOnly: false Containers: null Created: "0001-01-01T00:00:00Z" Driver: "" EnableIPv6: false IPAM: Config: - Gateway: 10.99.99.1 Subnet: 10.99.99.0/24 Driver: "" Options: null Id: "" Ingress: false Internal: false Labels: pygmy.name: amazeeio-network Name: amazeeio-network Options: null Scope: "" Resolvers: - Data: | # Generated by amazeeio pygmy nameserver 127.0.0.1 port 6053 Enabled: true File: docker.amazee.io.conf Folder: /etc/resolver Name: MacOS Resolver Services: amazeeio-dnsmasq: Config: AttachStderr: false AttachStdin: false AttachStdout: false Cmd: - --log-facility=- - -A - /docker.amazee.io/127.0.0.1 Domainname: "" Entrypoint: null Env: null Hostname: "" Image: pygmystack/dnsmasq Labels: pygmy.defaults: "true" pygmy.enable: "true" pygmy.name: amazeeio-dnsmasq pygmy.weight: "13" OnBuild: null OpenStdin: false StdinOnce: false Tty: false User: "" Volumes: null WorkingDir: "" HostConfig: AutoRemove: false Binds: null BlkioDeviceReadBps: null BlkioDeviceReadIOps: null BlkioDeviceWriteBps: null BlkioDeviceWriteIOps: null BlkioWeight: 0 BlkioWeightDevice: null CapAdd: - NET_ADMIN CapDrop: null Cgroup: "" CgroupParent: "" ConsoleSize: - 0 - 0 ContainerIDFile: "" CpuCount: 0 CpuPercent: 0 CpuPeriod: 0 CpuQuota: 0 CpuRealtimePeriod: 0 CpuRealtimeRuntime: 0 CpuShares: 0 CpusetCpus: "" CpusetMems: "" DeviceCgroupRules: null Devices: null DiskQuota: 0 Dns: null DnsOptions: null DnsSearch: null ExtraHosts: null GroupAdd: null IOMaximumBandwidth: 0 IOMaximumIOps: 0 IpcMode: private Isolation: "" KernelMemory: 0 Links: null LogConfig: Config: null Type: "" Memory: 0 MemoryReservation: 0 MemorySwap: 0 MemorySwappiness: null NanoCpus: 0 NetworkMode: "" OomKillDisable: null OomScoreAdj: 0 PidMode: "" PidsLimit: 0 PortBindings: 53/tcp: - HostIp: "" HostPort: "6053" 53/udp: - HostIp: "" HostPort: "6053" Privileged: false PublishAllPorts: false ReadonlyRootfs: false RestartPolicy: MaximumRetryCount: 0 Name: unless-stopped SecurityOpt: null ShmSize: 0 UTSMode: "" Ulimits: null UsernsMode: "" VolumeDriver: "" VolumesFrom: null NetworkConfig: EndpointsConfig: null amazeeio-haproxy: Config: AttachStderr: false AttachStdin: false AttachStdout: false Cmd: null Domainname: "" Entrypoint: null Env: - AMAZEEIO_URL=docker.amazee.io Hostname: "" Image: pygmystack/haproxy Labels: pygmy.defaults: "true" pygmy.enable: "true" pygmy.name: amazeeio-haproxy pygmy.network: amazeeio-network pygmy.url: http://docker.amazee.io/stats pygmy.weight: "14" OnBuild: null OpenStdin: false StdinOnce: false Tty: false User: "" Volumes: null WorkingDir: "" HostConfig: AutoRemove: false Binds: - /var/run/docker.sock:/tmp/docker.sock BlkioDeviceReadBps: null BlkioDeviceReadIOps: null BlkioDeviceWriteBps: null BlkioDeviceWriteIOps: null BlkioWeight: 0 BlkioWeightDevice: null CapAdd: null CapDrop: null Cgroup: "" CgroupParent: "" ConsoleSize: - 0 - 0 ContainerIDFile: "" CpuCount: 0 CpuPercent: 0 CpuPeriod: 0 CpuQuota: 0 CpuRealtimePeriod: 0 CpuRealtimeRuntime: 0 CpuShares: 0 CpusetCpus: "" CpusetMems: "" DeviceCgroupRules: null Devices: null DiskQuota: 0 Dns: null DnsOptions: null DnsSearch: null ExtraHosts: null GroupAdd: null IOMaximumBandwidth: 0 IOMaximumIOps: 0 IpcMode: "" Isolation: "" KernelMemory: 0 Links: null LogConfig: Config: null Type: "" Memory: 0 MemoryReservation: 0 MemorySwap: 0 MemorySwappiness: null NanoCpus: 0 NetworkMode: "" OomKillDisable: null OomScoreAdj: 0 PidMode: "" PidsLimit: 0 PortBindings: 80/tcp: - HostIp: "" HostPort: "80" 443/tcp: - HostIp: "" HostPort: "443" Privileged: false PublishAllPorts: false ReadonlyRootfs: false RestartPolicy: MaximumRetryCount: 0 Name: unless-stopped SecurityOpt: null ShmSize: 0 UTSMode: "" Ulimits: null UsernsMode: "" VolumeDriver: "" VolumesFrom: null NetworkConfig: EndpointsConfig: null amazeeio-mailhog: Config: AttachStderr: false AttachStdin: false AttachStdout: false Cmd: null Domainname: "" Entrypoint: null Env: - MH_UI_BIND_ADDR=0.0.0.0:80 - MH_API_BIND_ADDR=0.0.0.0:80 - AMAZEEIO=AMAZEEIO - AMAZEEIO_URL=mailhog.docker.amazee.io ExposedPorts: 80/tcp: {} 1025/tcp: {} 8025/tcp: {} Hostname: "" Image: pygmystack/mailhog Labels: pygmy.defaults: "true" pygmy.enable: "true" pygmy.name: amazeeio-mailhog pygmy.network: amazeeio-network pygmy.url: http://mailhog.docker.amazee.io pygmy.weight: "15" OnBuild: null OpenStdin: false StdinOnce: false Tty: false User: "0" Volumes: null WorkingDir: "" HostConfig: AutoRemove: false Binds: null BlkioDeviceReadBps: null BlkioDeviceReadIOps: null BlkioDeviceWriteBps: null BlkioDeviceWriteIOps: null BlkioWeight: 0 BlkioWeightDevice: null CapAdd: null CapDrop: null Cgroup: "" CgroupParent: "" ConsoleSize: - 0 - 0 ContainerIDFile: "" CpuCount: 0 CpuPercent: 0 CpuPeriod: 0 CpuQuota: 0 CpuRealtimePeriod: 0 CpuRealtimeRuntime: 0 CpuShares: 0 CpusetCpus: "" CpusetMems: "" DeviceCgroupRules: null Devices: null DiskQuota: 0 Dns: null DnsOptions: null DnsSearch: null ExtraHosts: null GroupAdd: null IOMaximumBandwidth: 0 IOMaximumIOps: 0 IpcMode: "" Isolation: "" KernelMemory: 0 Links: null LogConfig: Config: null Type: "" Memory: 0 MemoryReservation: 0 MemorySwap: 0 MemorySwappiness: null NanoCpus: 0 NetworkMode: "" OomKillDisable: null OomScoreAdj: 0 PidMode: "" PidsLimit: 0 PortBindings: 1025/tcp: - HostIp: "" HostPort: "1025" Privileged: false PublishAllPorts: false ReadonlyRootfs: false RestartPolicy: MaximumRetryCount: 0 Name: unless-stopped SecurityOpt: null ShmSize: 0 UTSMode: "" Ulimits: null UsernsMode: "" VolumeDriver: "" VolumesFrom: null NetworkConfig: EndpointsConfig: null amazeeio-ssh-agent: Config: AttachStderr: false AttachStdin: false AttachStdout: false Cmd: null Domainname: "" Entrypoint: null Env: null Hostname: "" Image: pygmystack/ssh-agent Labels: pygmy.defaults: "true" pygmy.enable: "true" pygmy.name: amazeeio-ssh-agent pygmy.network: amazeeio-network pygmy.output: "false" pygmy.purpose: sshagent pygmy.weight: "30" OnBuild: null OpenStdin: false StdinOnce: false Tty: false User: "" Volumes: null WorkingDir: "" HostConfig: AutoRemove: false Binds: null BlkioDeviceReadBps: null BlkioDeviceReadIOps: null BlkioDeviceWriteBps: null BlkioDeviceWriteIOps: null BlkioWeight: 0 BlkioWeightDevice: null CapAdd: null CapDrop: null Cgroup: "" CgroupParent: "" ConsoleSize: - 0 - 0 ContainerIDFile: "" CpuCount: 0 CpuPercent: 0 CpuPeriod: 0 CpuQuota: 0 CpuRealtimePeriod: 0 CpuRealtimeRuntime: 0 CpuShares: 0 CpusetCpus: "" CpusetMems: "" DeviceCgroupRules: null Devices: null DiskQuota: 0 Dns: null DnsOptions: null DnsSearch: null ExtraHosts: null GroupAdd: null IOMaximumBandwidth: 0 IOMaximumIOps: 0 IpcMode: private Isolation: "" KernelMemory: 0 Links: null LogConfig: Config: null Type: "" Memory: 0 MemoryReservation: 0 MemorySwap: 0 MemorySwappiness: null NanoCpus: 0 NetworkMode: "" OomKillDisable: null OomScoreAdj: 0 PidMode: "" PidsLimit: 0 PortBindings: null Privileged: false PublishAllPorts: false ReadonlyRootfs: false RestartPolicy: MaximumRetryCount: 0 Name: unless-stopped SecurityOpt: null ShmSize: 0 UTSMode: "" Ulimits: null UsernsMode: "" VolumeDriver: "" VolumesFrom: null NetworkConfig: EndpointsConfig: null amazeeio-ssh-agent-add-key: Config: AttachStderr: false AttachStdin: false AttachStdout: false Cmd: null Domainname: "" Entrypoint: null Env: null Hostname: "" Image: pygmystack/ssh-agent Labels: pygmy.defaults: "true" pygmy.discrete: "true" pygmy.enable: "true" pygmy.name: amazeeio-ssh-agent-add-key pygmy.network: amazeeio-network pygmy.output: "false" pygmy.purpose: addkeys pygmy.weight: "31" OnBuild: null OpenStdin: false StdinOnce: false Tty: false User: "" Volumes: null WorkingDir: "" HostConfig: AutoRemove: false Binds: null BlkioDeviceReadBps: null BlkioDeviceReadIOps: null BlkioDeviceWriteBps: null BlkioDeviceWriteIOps: null BlkioWeight: 0 BlkioWeightDevice: null CapAdd: null CapDrop: null Cgroup: "" CgroupParent: "" ConsoleSize: - 0 - 0 ContainerIDFile: "" CpuCount: 0 CpuPercent: 0 CpuPeriod: 0 CpuQuota: 0 CpuRealtimePeriod: 0 CpuRealtimeRuntime: 0 CpuShares: 0 CpusetCpus: "" CpusetMems: "" DeviceCgroupRules: null Devices: null DiskQuota: 0 Dns: null DnsOptions: null DnsSearch: null ExtraHosts: null GroupAdd: null IOMaximumBandwidth: 0 IOMaximumIOps: 0 IpcMode: private Isolation: "" KernelMemory: 0 Links: null LogConfig: Config: null Type: "" Memory: 0 MemoryReservation: 0 MemorySwap: 0 MemorySwappiness: null NanoCpus: 0 NetworkMode: "" OomKillDisable: null OomScoreAdj: 0 PidMode: "" PidsLimit: 0 PortBindings: null Privileged: false PublishAllPorts: false ReadonlyRootfs: false RestartPolicy: MaximumRetryCount: 0 Name: "" SecurityOpt: null ShmSize: 0 UTSMode: "" Ulimits: null UsernsMode: "" VolumeDriver: "" VolumesFrom: - amazeeio-ssh-agent NetworkConfig: EndpointsConfig: null SortedServices: - amazeeio-dnsmasq - amazeeio-haproxy - amazeeio-mailhog - amazeeio-ssh-agent - amazeeio-ssh-agent-add-key Volumes: {} ```
fubarhouse commented 2 years ago

We can certainly add a condition for changing the path to the resolver - would you happen to know if this is MacOS-specific, or M1 specific? And, was it working before; did you upgrade to this version and it stop working?

I ask because I don't have direct access to any Apple desktop operating systems beyond Catalina, and probably won't for a while. It would be an easy fix though - first time I've heard of this.

ocean90 commented 2 years ago

I’m on a non-M1 Mac but my colleague with a M1 chip has the same issue. I don’t think the file name with the conf extension was/will ever be supported on macOS and the change to the file extension in https://github.com/fubarhouse/pygmy-go/commit/8ac4871a90a6f465a61e0b52f4e3d955ab73dc9c should be reverted.

It’s the first time I’m using the go version. The Ruby version does not have this issue.

ocean90 commented 2 years ago

Quoting the manual of resolver

domain Domain name associated with this resolver configuration. This option is normally not required by the Mac OS X DNS search system when the resolver configuration is read from a file in the /etc/resolver directory. In that case the file name is used as the domain name. However, domain must be provided when there are multiple resolver clients for the same domain name, since multiple files may not exist having the same name. See the SEARCH STRATEGY section for more details.

(Source: man 5 resolver)

So if you want to keep the conf extension you have to add the domain entry to the config too.

❯ cat /etc/resolver/docker.amazee.io.conf
# Generated by amazeeio pygmy
domain docker.amazee.io
nameserver 127.0.0.1
port 6053

With that config I can also access docker.amazee.io and mailhog.docker.amazee.io.

derpaschi commented 2 years ago

I, as the colleague @ocean90 mentioned, have tested the fix and it worked well.

By default my requests were not resolved and i got a ERR_NAME_NOT_RESOLVED when trying to access anything at docker.amazee.io or *.docker.amazee.io inside the browser.

With the renamed file without the .conf extension all works fine.

fubarhouse commented 2 years ago

I'll do a quick test tonight on the MacBook I do have access to - shouldn't be any issue changing the value for all MacOS versions.

Thanks for the input.

fubarhouse commented 2 years ago

Please feel free to test #359 - I'll give it a little time before merging.

fubarhouse commented 2 years ago

Merged - I'll need to do some testing on PowerShell & WSL to validate things still work before I can cut a release.

fubarhouse commented 2 years ago

Closing - the next release will have the fix included. I've been thinking about cutting a release mid-Feb.