kubernetes/kops · error

MockAWSCloud DescribeInstance not implemented

Error message

MockAWSCloud DescribeInstance not implemented

What it means

MockAWSCloud.DescribeInstance is an unimplemented stub on the test double; it always returns this error. It exists to satisfy the Cloud interface and indicates the code path under test reached EC2 instance description that the mock does not simulate.

Source

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

func (c *MockAWSCloud) CreateELBV2Tags(ResourceArn string, tags map[string]string) error {
	return createELBV2Tags(c, ResourceArn, tags)
}

func (c *MockAWSCloud) RemoveELBV2Tags(ResourceArn string, tags map[string]string) error {
	return removeELBV2Tags(c, ResourceArn, tags)
}

func (c *MockAWSCloud) DescribeELBV2Tags(loadBalancerArns []string) (map[string][]elbv2types.Tag, error) {
	return describeELBV2Tags(c, loadBalancerArns)
}

func (c *MockAWSCloud) FindELBV2NetworkInterfacesByName(vpcID, loadBalancerName string) ([]ec2types.NetworkInterface, error) {
	return nil, nil
}

func (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2types.Instance, error) {
	return nil, fmt.Errorf("MockAWSCloud DescribeInstance not implemented")
}

func (c *MockAWSCloud) DescribeVPC(vpcID string) (*ec2types.Vpc, error) {
	return describeVPC(c, vpcID)
}

func (c *MockAWSCloud) ResolveImage(name string) (*ec2types.Image, error) {
	return resolveImage(context.TODO(), c.MockSSM, c.MockEC2, name)
}

func (c *MockAWSCloud) WithTags(tags map[string]string) AWSCloud {
	m := &MockAWSCloud{}
	*m = *c
	m.tags = tags
	return m
}

func (c *MockAWSCloud) EC2() awsinterfaces.EC2API {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Implement DescribeInstance in the test by extending the mock to return a canned ec2types.Instance for known instance IDs.
  2. Restructure the test to avoid the code path requiring DescribeInstance, or use a small local stub that embeds MockAWSCloud and overrides DescribeInstance.
  3. If this is newly needed production behavior, add mock support and a unit test covering it.

Example fix

// before
func (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2types.Instance, error) {
	return nil, fmt.Errorf("MockAWSCloud DescribeInstance not implemented")
}
// after
func (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2types.Instance, error) {
	if i, ok := c.instances[instanceID]; ok {
		return i, nil
	}
	return nil, fmt.Errorf("instance %q not found", instanceID)
}
Defensive patterns

Strategy: fallback

Try / catch

inst, err := cloud.DescribeInstance(id)
if err != nil && strings.Contains(err.Error(), "not implemented") {
	// test-double stub hit; skip or use fallback fixture data
	inst = fixtureInstance(id)
}

Prevention

When it happens

Trigger: Any production code path invoked from a test calls DescribeInstance(instanceID) on a MockAWSCloud, e.g. validation or instance lookup logic running against mock clouds.

Common situations: Adding new code that calls cloud.DescribeInstance and running existing unit tests with mocks; tests exercising validation or fitask logic that now touches instance details; copy-pasting a test scenario from real-cloud to mock-cloud.

Related errors


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