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] = vView on GitHub (pinned to 4c8573c808)
Solutions
- Initialize MockRoute53 with route53.New(route53.Options{Region: ...}) or use the existing mock constructor that wires it.
- Use BuildMockAWSCloud/newMockAWSCloud helper rather than zero-value MockCloud structs.
- 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
- Always construct mocks via helper constructors (BuildMockAWSCloud) that wire all fields
- Add a test-setup assertion that MockRoute53 is non-nil when DNS paths are exercised
- Avoid zero-value MockCloud structs in new tests
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
- error applying DNS changeset for zone %s: %v
- failed to load default aws config for IMDS client: %w
- failed to load default aws config for STS client: %w
- failed to load default aws config: %w
- error listing resource record sets: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/f6604ca077e858b4.
Report an issue: GitHub.