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

[BUG] Cannot resolve unqualified name "salt" #63068

Open
2 of 9 tasks
DaAwesomeP opened this issue Nov 15, 2022 · 2 comments
Open
2 of 9 tasks

[BUG] Cannot resolve unqualified name "salt" #63068

DaAwesomeP opened this issue Nov 15, 2022 · 2 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@DaAwesomeP
Copy link
Contributor

DaAwesomeP commented Nov 15, 2022

Description
When systemd-resolved is used to resolve names on a system, it does not resolve unqualified hosts (hosts without a domain name) into FQDNs using the machine's domain. For example, if a minion's FQDN is minion.mydomain.com, systemd-resolved will fail to resolve salt as salt.mydomain.com on that machine.

Setup

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Running in a OVH US VPS on Debian 11 amd64. Saltstack 3005.1 from the Saltstack repos. On this machine I disabled cloud-init, changed the FQDN, and installed salt. Nothing else was changed from the Debian 11 install given by OVH.

Steps to Reproduce the behavior

  1. Setup machine that resolves using systemd-resolved, set full FQDN
  2. Install Salt minion 3005.1 on machine
  3. Start salt-minion
  4. Nov 15 21:32:16 some-minion salt-minion[2991]: [ERROR   ] DNS lookup or connection check of 'salt' failed.
    Nov 15 21:32:16 some-minion salt-minion[2991]: [ERROR   ] Master hostname: 'salt' not found or not responsive. Retrying in 30 seconds
    

Expected behavior
Because the resolver cannot be trusted to attempt to resolve with the machine's domain, minions should try resolving both salt and salt.machinedomain.com at startup.

Screenshots
N/A

Versions Report

salt --versions-report
Salt Version:
          Salt: 3005.1
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.5
     gitpython: 3.1.14
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.9.7
        pygit2: Not Installed
        Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 20.0.0
         smmap: 4.0.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: debian 11 bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-19-cloud-amd64
        system: Linux
       version: Debian GNU/Linux 11 bullseye

Additional context
Related: systemd/systemd#2514

See above link, it is apparently the correct functionality for the resolver not to resolve unqualified names.

@DaAwesomeP DaAwesomeP added Bug broken, incorrect, or confusing behavior needs-triage labels Nov 15, 2022
@DaAwesomeP DaAwesomeP changed the title [BUG] single-word resolve for "salt" not consistent [BUG] unqualified name resolve for "salt" not consistent Nov 16, 2022
@DaAwesomeP
Copy link
Contributor Author

Here is the default:

DEFAULT_MINION_OPTS = immutabletypes.freeze(
{
"interface": "0.0.0.0",
"master": "salt",

Since using unqualified domains goes against spec, it doesn't seem like a good default. However, configuration-less minions are fantastic. Would this be the appropriate place to change it to something like:

import socket
DEFAULT_MASTER_HOSTNAME = "salt"

def findDefaultMasterName() -> str:
    fqdn = socket.getfqdn()
    # If this machine has a domain name, use it instead of unqualified hostname
    if "." in fqdn:
        return DEFAULT_MASTER_HOSTNAME + "." + fqdn.partition(".")[2]
    # Fall back to unqualified hostname
    return DEFAULT_MASTER_HOSTNAME

DEFAULT_MINION_OPTS = immutabletypes.freeze( 
     { 
         "interface": "0.0.0.0", 
         "master": findDefaultMasterName()
         ...

Note that simply socket.getfqdn("salt") should not be used here because it actually performs a lookup.

If the above looks good then I will open a pull! Although I'm not sure in which file that function should be defined. Maybe a util file?

@DaAwesomeP DaAwesomeP changed the title [BUG] unqualified name resolve for "salt" not consistent [BUG] Cannot resolve unqualified name "salt" Nov 16, 2022
@OrangeDog
Copy link
Contributor

OrangeDog commented Nov 16, 2022

Wouldn't that break the common setup of adding salt to /etc/hosts?

Also, systemd-resolved handles "salt" just fine on my system - systemd v245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants