kubernetes/kops · error
MockDNS not set
Error message
MockDNS not set
What it means
The mock OpenStack cloud was asked to perform a DNS operation but its MockDNS field was never populated by the test. It is a sentinel-style guard: the test fixture is incomplete, not a production failure.
Source
Thrown at upup/pkg/fi/cloudup/openstack/mock_cloud.go:151
func (c *MockCloud) DeregisterInstance(i *cloudinstances.CloudInstance) error {
return deregisterInstance(c, i.ID)
}
func (c *MockCloud) DetachInstance(i *cloudinstances.CloudInstance) error {
return detachInstance(c, i)
}
func (c *MockCloud) GetCloudGroups(cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error) {
return getCloudGroups(c, cluster, instancegroups, warnUnmatched, nodes)
}
func (c *MockCloud) ProviderID() kops.CloudProviderID {
return kops.CloudProviderOpenstack
}
func (c *MockCloud) DNS() (dnsprovider.Interface, error) {
if c.MockDNSClient == nil {
return nil, fmt.Errorf("MockDNS not set")
}
return dnsproviderdesignate.New(c.DNSClient()), nil
}
func (c *MockCloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
return findVPCInfo(c, id, c.zones)
}
func (c *MockCloud) Region() string {
return c.region
}
func (c *MockCloud) AppendTag(resource string, id string, tag string) error {
return appendTag(c, resource, id, tag)
}
func (c *MockCloud) AssociateToPool(server *servers.Server, poolID string, opts v2pools.CreateMemberOpts) (association *v2pools.Member, err error) {
return associateToPool(c, server, poolID, opts)View on GitHub (pinned to 4c8573c808)
Example fix
// before cloud := openstack.NewMockCloud(t) _ = cloud.DNS() // after cloud := openstack.NewMockCloud(t) cloud.MockDNSClient = ... // init mock DNS client _ = cloud.DNS()
Defensive patterns
Strategy: validation
Validate before calling
if cloud.MockDNSClient == nil {
t.Fatal("MockDNSClient must be initialized before test")
} Type guard
func hasMockDNS(c *openstack.MockCloud) bool { return c.MockDNSClient != nil } Prevention
- Always construct mocks via test helpers that initialize all clients
- Add a fixture/setup function that sets MockDNSClient before DNS-dependent tests
- When refactoring, run the affected tests to catch new DNS() call paths
When it happens
Trigger: Calling DNS() on a MockCloud built by newMockCloud without first assigning c.MockDNSClient.
Common situations: Unit tests of OpenStack DNS/designate integration using the mock cloud but forgetting to set the designate client; refactors that call DNS() in code paths tests did not previously cover.
Related errors
- failed to list dns zones: %s
- failed to find cluster dns zone
- failed to extract recordsets pages for zone %s: %v
- MockRoute53 not set
- MockAWSCloud DescribeInstance not implemented
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/97dcf43b78250a81.
Report an issue: GitHub.