Skip to content

Commit

Permalink
fix: report an error when the node template is not found
Browse files Browse the repository at this point in the history
Without this change, no instance types are found and the resulting
behavior is a generic error regarding not finding instance types.
  • Loading branch information
tzneal committed Sep 28, 2023
1 parent d71c265 commit 5268d2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ func (c *CloudProvider) GetInstanceTypes(ctx context.Context, nodePool *corev1be
if errors.IsNotFound(err) {
c.recorder.Publish(cloudproviderevents.NodePoolFailedToResolveNodeClass(nodePool))
}
return nil, client.IgnoreNotFound(fmt.Errorf("resolving node class, %w", err))
// We must return an error here in the event of the node class not being found. Otherwise users just get
// no instance types and a failure to schedule with no indicator pointing to a bad configuration
// as the cause.
return nil, fmt.Errorf("resolving node class, %w", err)
}
// TODO, break this coupling
instanceTypes, err := c.instanceTypeProvider.List(ctx, nodePool.Spec.Template.Spec.Kubelet, nodeClass)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudprovider/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,12 @@ var _ = Describe("Machine/CloudProvider", func() {
// select nothing!
AMISelector: map[string]string{"Name": "nothing"},
})
misconfiguredNodeTemplate.Name = "misconfigured"
prov2 := test.Provisioner(coretest.ProvisionerOptions{
ProviderRef: &v1alpha5.MachineTemplateRef{
APIVersion: misconfiguredNodeTemplate.APIVersion,
Kind: misconfiguredNodeTemplate.Kind,
// select nothing!
Name: "nothing",
Name: "misconfigured",
},
})
ExpectApplied(ctx, env.Client, provisioner, prov2, nodeTemplate, misconfiguredNodeTemplate)
Expand Down

0 comments on commit 5268d2f

Please sign in to comment.