vitessio/vitess · error

err

Error message

err

What it means

FullyQualifiedHostnameOrPanic wraps FullyQualifiedHostname, which resolves the local hostname to a fully qualified domain name via DNS (net.LookupHost). It panics with the raw error when resolution fails — typically no network/DNS availability or the hostname not resolving back to an address. It is meant for startup paths where a hostname is mandatory.

Source

Thrown at go/netutil/netutil.go:104

	if len(resolvedHostnames) == 0 {
		return "", fmt.Errorf("FullyQualifiedHostname: reverse lookup of this machine's local IP (%v) did not return any hostnames", localIP)
	}
	// If multiple hostnames are found, we return only the first one.
	// If multiple hostnames are listed e.g. in an entry in the /etc/hosts file,
	// the current Go implementation returns them in that order.
	// Example for an /etc/hosts entry:
	//   127.0.0.1	localhost.localdomain localhost
	// If the FQDN isn't returned by this function, check the order in the entry
	// in your /etc/hosts file.
	return strings.TrimSuffix(resolvedHostnames[0], "."), nil
}

// FullyQualifiedHostnameOrPanic is the same as FullyQualifiedHostname
// but panics in case of an error.
func FullyQualifiedHostnameOrPanic() string {
	hostname, err := FullyQualifiedHostname()
	if err != nil {
		panic(err)
	}
	return hostname
}

func dnsLookup(host string) ([]net.IP, error) {
	addrs, err := net.LookupHost(host)
	if err != nil {
		return nil, fmt.Errorf("Error looking up dns name [%v]: (%v)", host, err)
	}
	naddr := make([]net.IP, len(addrs))
	for i, a := range addrs {
		naddr[i] = net.ParseIP(a)
	}
	sort.Slice(naddr, func(i, j int) bool {
		return bytes.Compare(naddr[i], naddr[j]) < 0
	})
	return naddr, nil
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Fix the environment: ensure `hostname -f` works — add the machine's hostname to /etc/hosts (e.g. '127.0.0.1 myhost.mydomain myhost') or configure DNS.
  2. Use FullyQualifiedHostname() and handle the error instead of the OrPanic variant in non-critical paths.
  3. Set an explicit hostname via the tool's config flag rather than auto-detection.
  4. Retry on transient DNS failures if the environment is known-good.

Example fix

// before
host := netutil.FullyQualifiedHostnameOrPanic() // panics without DNS
// after
host, err := netutil.FullyQualifiedHostname()
if err != nil {
    log.Warn("FQDN lookup failed, falling back to short hostname", slog.Any("error", err))
    host, _ = os.Hostname()
}
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := net.LookupHost(hostname()); err != nil {
    log.Warn("hostname not resolvable; fix /etc/hosts or DNS before startup")
}

Try / catch

// prefer the error-returning variant:
host, err := netutil.FullyQualifiedHostname()
if err != nil {
    host, _ = os.Hostname() // fallback
}

Prevention

When it happens

Trigger: Calling FullyQualifiedHostnameOrPanic (directly or via MakeZkConfigFromString, StartLocalZk) on a machine whose hostname is not in /etc/hosts, has no DNS record, or in a container/sandbox with no network; also transient DNS lookup failures.

Common situations: Running vitess tools (zkctl, vtctld local setup) in minimal Docker containers or Kubernetes pods where the pod hostname isn't resolvable; offline CI environments; misconfigured /etc/hosts.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/42f4a66afba96ee7. Report an issue: GitHub.