Skip to content

CLUSTER_DOMAIN is ignored when /etc/resolv.conf is missing #3417

Description

@RaphaelFakhri

/kind bug
/area networking

Expected behavior

network.GetClusterDomainName() and network.GetServiceHostname() return the value of the CLUSTER_DOMAIN environment variable when it is set, including when /etc/resolv.conf does not exist. #2092 added the variable for code that resolves cluster-local URLs from outside the cluster without access to /etc/resolv.conf, and #3283 made it take precedence over /etc/resolv.conf.

Actual behavior

When /etc/resolv.conf cannot be opened, GetClusterDomainName() returns cluster.local even if CLUSTER_DOMAIN is set. The os.Open error path in GetClusterDomainName returns before getClusterDomainName, which is the only place that reads the variable:

once.Do(func() {
	f, err := os.Open(resolverFileName)
	if err != nil {
		return
	}
	defer f.Close()
	domainName = getClusterDomainName(f)
})

Steps to reproduce the problem

On a machine without /etc/resolv.conf, run:

os.Setenv("CLUSTER_DOMAIN", "mesh.net")
fmt.Println(network.GetClusterDomainName()) // prints cluster.local, expected mesh.net

Additional info

Knative version: knative.dev/pkg main (7b6dcbb).

Activity

  1. amarkdotdev commented on Nov 3, 2026

    @amarkdotdev

    Opened #3419 (includes #3195 in the same branch). /assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions