kubernetes/kops · error

MockRoute53 not set

Error message

MockRoute53 not set

What it means

MockCloud.DNS() implements the awsup Cloud interface for testing. It requires the MockRoute53 field to be populated; if it is nil, the mock cannot construct a Route53 dnsprovider and returns this error. It signals incorrect test setup, not a runtime condition.

Source

Thrown at upup/pkg/fi/cloudup/awsup/mock_aws_cloud.go:114

func (c *MockAWSCloud) DetachInstance(i *cloudinstances.CloudInstance) error {
	ctx := context.TODO()

	return detachInstance(ctx, c, i)
}

func (c *MockAWSCloud) GetCloudGroups(cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error) {
	ctx := context.TODO()
	return getCloudGroups(ctx, c, cluster, instancegroups, warnUnmatched, nodes)
}

func (c *MockCloud) ProviderID() kops.CloudProviderID {
	return kops.CloudProviderAWS
}

func (c *MockCloud) DNS() (dnsprovider.Interface, error) {
	if c.MockRoute53 == nil {
		return nil, fmt.Errorf("MockRoute53 not set")
	}
	return dnsproviderroute53.New(c.MockRoute53), nil
}

func (c *MockAWSCloud) Region() string {
	return c.region
}

func (c *MockAWSCloud) DescribeAvailabilityZones() ([]ec2types.AvailabilityZone, error) {
	return c.zones, nil
}

func (c *MockAWSCloud) AddTags(name *string, tags map[string]string) {
	if name != nil {
		tags["Name"] = *name
	}
	for k, v := range c.tags {
		tags[k] = v

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Initialize MockRoute53 with route53.New(route53.Options{Region: ...}) or use the existing mock constructor that wires it.
  2. Use BuildMockAWSCloud/newMockAWSCloud helper rather than zero-value MockCloud structs.
  3. If DNS is irrelevant to the test, avoid calling DNS() on the mock.

Example fix

// before
c := &MockCloud{}
dns, err := c.DNS() // err: MockRoute53 not set
// after
c := &MockCloud{MockRoute53: route53.New(route53.Options{Region: "us-east-1"})}
dns, err := c.DNS()
Defensive patterns

Strategy: validation

Validate before calling

if c.MockRoute53 == nil {
	c.MockRoute53 = route53.New(route53.Options{Region: "us-east-1"})
}

Try / catch

dns, err := c.DNS()
if err != nil {
	t.Fatalf("mock DNS not wired: %v", err)
}

Prevention

When it happens

Trigger: A test creates a MockCloud/MockAWSCloud (e.g. via newMockAWSCloud or BuildMockAWSCloud) and calls DNS() without assigning MockRoute53, or explicitly sets it to nil.

Common situations: New unit tests reusing a partially initialized mock cloud; refactors that construct MockCloud structs directly instead of via the helper that wires MockRoute53; tests touching DNS functionality with mocks meant only for EC2/ELB.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/f6604ca077e858b4. Report an issue: GitHub.