Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: report an error when the node template is not found #4721

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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