diff --git a/pkg/cloudprovider/cloudprovider.go b/pkg/cloudprovider/cloudprovider.go index 802ede1d2d4d..64ad849e4776 100644 --- a/pkg/cloudprovider/cloudprovider.go +++ b/pkg/cloudprovider/cloudprovider.go @@ -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) diff --git a/pkg/cloudprovider/machine_test.go b/pkg/cloudprovider/machine_test.go index 0e2007b847e5..7294523ab189 100644 --- a/pkg/cloudprovider/machine_test.go +++ b/pkg/cloudprovider/machine_test.go @@ -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)