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: handle SkuNotAvailable provisioning error #43

Merged
merged 8 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions pkg/providers/instancetype/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ import (
coretest "github.com/aws/karpenter-core/pkg/test"
. "github.com/aws/karpenter-core/pkg/test/expectations"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
"github.com/Azure/karpenter/pkg/apis"
"github.com/Azure/karpenter/pkg/apis/settings"
"github.com/Azure/karpenter/pkg/apis/v1alpha2"
"github.com/Azure/karpenter/pkg/cloudprovider"
"github.com/Azure/karpenter/pkg/fake"
"github.com/Azure/karpenter/pkg/providers/instance"
"github.com/Azure/karpenter/pkg/providers/instancetype"
"github.com/Azure/karpenter/pkg/providers/loadbalancer"
"github.com/Azure/karpenter/pkg/test"
. "github.com/Azure/karpenter/pkg/test/expectations"
"github.com/Azure/karpenter/pkg/utils"
)

Expand Down Expand Up @@ -374,8 +377,7 @@ var _ = Describe("InstanceType Provider", func() {
Key: v1.LabelInstanceTypeStable,
Operator: v1.NodeSelectorOpIn,
Values: []string{"Standard_D2_v2"},
},
)
})

ExpectApplied(ctx, env.Client, nodePool, nodeClass)
// Try this 100 times to make sure we don't get a node in eastus-1,
Expand Down Expand Up @@ -489,6 +491,34 @@ var _ = Describe("InstanceType Provider", func() {
node := ExpectScheduled(ctx, env.Client, pod)
Expect(node.Labels).To(HaveKeyWithValue(v1.LabelInstanceTypeStable, "Standard_D2_v2"))
})

Context("on SkuNotUnavailable, should cache SKU as unavailable in all zones", func() {
AssertUnavailable := func(sku string, capacityType string) {
// fake a SKU not available error
azureEnv.VirtualMachinesAPI.VirtualMachinesBehavior.VirtualMachineCreateOrUpdateBehavior.Error.Set(
&azcore.ResponseError{ErrorCode: instance.SKUNotAvailableErrorCode},
)
tallaxes marked this conversation as resolved.
Show resolved Hide resolved
coretest.ReplaceRequirements(nodePool,
v1.NodeSelectorRequirement{Key: v1.LabelInstanceTypeStable, Operator: v1.NodeSelectorOpIn, Values: []string{sku}},
v1.NodeSelectorRequirement{Key: corev1beta1.CapacityTypeLabelKey, Operator: v1.NodeSelectorOpIn, Values: []string{capacityType}},
)
ExpectApplied(ctx, env.Client, nodeClass, nodePool)
pod := coretest.UnschedulablePod()
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, coreProvisioner, pod)
ExpectNotScheduled(ctx, env.Client, pod)
for _, zone := range []string{"1", "2", "3"} {
ExpectUnavailable(azureEnv, sku, zone, capacityType)
}
}

It("should mark SKU as unavailable in all zones for Spot", func() {
AssertUnavailable("Standard_D2_v2", corev1beta1.CapacityTypeSpot)
})

It("should mark SKU as unavailable in all zones for OnDemand", func() {
AssertUnavailable("Standard_D2_v2", corev1beta1.CapacityTypeOnDemand)
})
})
})
Context("Provider List", func() {
var instanceTypes corecloudprovider.InstanceTypes
Expand Down