Skip to content

Commit

Permalink
Convert preferred anti-affinity to required:
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Mar 6, 2023
1 parent fd8c9cf commit 162ce3f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion charts/karpenter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ affinity:
- key: karpenter.sh/provisioner-name
operator: DoesNotExist
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
requiredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/avast/retry-go v3.0.0+incompatible
github.com/aws/aws-sdk-go v1.44.195
github.com/aws/karpenter-core v0.26.1
github.com/aws/karpenter-core v0.26.2-0.20230306163515-7d58c3cee0fa
github.com/go-playground/validator/v10 v10.11.2
github.com/imdario/mergo v0.3.13
github.com/mitchellh/hashstructure/v2 v2.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHS
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.44.195 h1:d5xFL0N83Fpsq2LFiHgtBUHknCRUPGHdOlCWt/jtOJs=
github.com/aws/aws-sdk-go v1.44.195/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/karpenter-core v0.26.1 h1:eZezm/Ibv+EbZ5sC3xNsaSAR4eJozWKJOEMI5nA/cTw=
github.com/aws/karpenter-core v0.26.1/go.mod h1:szIXYuMzg8kAwAbMIoB1VJBjAM+AdX+cIwsINkmWnpI=
github.com/aws/karpenter-core v0.26.2-0.20230306163515-7d58c3cee0fa h1:M83SgTjtd50xPEklIDgUIjoBvb65ftpsJUQ1nWlqNto=
github.com/aws/karpenter-core v0.26.2-0.20230306163515-7d58c3cee0fa/go.mod h1:szIXYuMzg8kAwAbMIoB1VJBjAM+AdX+cIwsINkmWnpI=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ var (
AMIFamilyUbuntu,
AMIFamilyCustom,
}
SupportedContainerRuntimesByAMIFamily = map[string]sets.String{
AMIFamilyBottlerocket: sets.NewString("containerd"),
AMIFamilyAL2: sets.NewString("dockerd", "containerd"),
AMIFamilyUbuntu: sets.NewString("dockerd", "containerd"),
SupportedContainerRuntimesByAMIFamily = map[string]sets.Set[string]{
AMIFamilyBottlerocket: sets.New[string]("containerd"),
AMIFamilyAL2: sets.New[string]("dockerd", "containerd"),
AMIFamilyUbuntu: sets.New[string]("dockerd", "containerd"),
}
ResourceNVIDIAGPU v1.ResourceName = "nvidia.com/gpu"
ResourceAMDGPU v1.ResourceName = "amd.com/gpu"
Expand Down
12 changes: 6 additions & 6 deletions pkg/providers/instancetype/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (p *Provider) LivenessProbe(req *http.Request) error {
return nil
}

func (p *Provider) createOfferings(ctx context.Context, instanceType *ec2.InstanceTypeInfo, zones sets.String) []cloudprovider.Offering {
func (p *Provider) createOfferings(ctx context.Context, instanceType *ec2.InstanceTypeInfo, zones sets.Set[string]) []cloudprovider.Offering {
var offerings []cloudprovider.Offering
for zone := range zones {
// while usage classes should be a distinct set, there's no guarantee of that
Expand Down Expand Up @@ -147,14 +147,14 @@ func (p *Provider) createOfferings(ctx context.Context, instanceType *ec2.Instan
return offerings
}

func (p *Provider) getInstanceTypeZones(ctx context.Context, nodeTemplate *v1alpha1.AWSNodeTemplate) (map[string]sets.String, error) {
func (p *Provider) getInstanceTypeZones(ctx context.Context, nodeTemplate *v1alpha1.AWSNodeTemplate) (map[string]sets.Set[string], error) {
subnetSelectorHash, err := hashstructure.Hash(nodeTemplate.Spec.SubnetSelector, hashstructure.FormatV2, nil)
if err != nil {
return nil, fmt.Errorf("failed to hash the subnet selector: %w", err)
}
cacheKey := fmt.Sprintf("%s%016x", InstanceTypeZonesCacheKeyPrefix, subnetSelectorHash)
if cached, ok := p.cache.Get(cacheKey); ok {
return cached.(map[string]sets.String), nil
return cached.(map[string]sets.Set[string]), nil
}

// Constrain AZs from subnets
Expand All @@ -170,13 +170,13 @@ func (p *Provider) getInstanceTypeZones(ctx context.Context, nodeTemplate *v1alp
})...)

// Get offerings from EC2
instanceTypeZones := map[string]sets.String{}
instanceTypeZones := map[string]sets.Set[string]{}
if err := p.ec2api.DescribeInstanceTypeOfferingsPagesWithContext(ctx, &ec2.DescribeInstanceTypeOfferingsInput{LocationType: aws.String("availability-zone")},
func(output *ec2.DescribeInstanceTypeOfferingsOutput, lastPage bool) bool {
for _, offering := range output.InstanceTypeOfferings {
if zones.Has(aws.StringValue(offering.Location)) {
if _, ok := instanceTypeZones[aws.StringValue(offering.InstanceType)]; !ok {
instanceTypeZones[aws.StringValue(offering.InstanceType)] = sets.NewString()
instanceTypeZones[aws.StringValue(offering.InstanceType)] = sets.New[string]()
}
instanceTypeZones[aws.StringValue(offering.InstanceType)].Insert(aws.StringValue(offering.Location))
}
Expand All @@ -192,7 +192,7 @@ func (p *Provider) getInstanceTypeZones(ctx context.Context, nodeTemplate *v1alp
return instanceTypeZones, nil
}

// getInstanceTypes retrieves all instance types from the ec2 DescribeInstanceTypes API using some opinionated filters
// GetInstanceTypes retrieves all instance types from the ec2 DescribeInstanceTypes API using some opinionated filters
func (p *Provider) GetInstanceTypes(ctx context.Context) ([]*ec2.InstanceTypeInfo, error) {
// DO NOT REMOVE THIS LOCK ----------------------------------------------------------------------------
// We lock here so that multiple callers to GetInstanceTypes do not result in cache misses and multiple
Expand Down
2 changes: 1 addition & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/aws/aws-sdk-go v1.44.212
github.com/aws/aws-sdk-go-v2/config v1.18.13
github.com/aws/karpenter v0.22.0
github.com/aws/karpenter-core v0.26.1
github.com/aws/karpenter-core v0.26.2-0.20230306163515-7d58c3cee0fa
github.com/onsi/ginkgo/v2 v2.8.1
github.com/onsi/gomega v1.27.1
github.com/samber/lo v1.37.0
Expand Down
4 changes: 2 additions & 2 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.2/go.mod h1:O1YSOg3aekZibh2Sn
github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiOVVG8uVjGI6HaZ8WBHdgDgU=
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5 h1:L1600eLr0YvTT7gNh3Ni24yGI7NSHkq9Gp62vijPRCs=
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5/go.mod h1:1mKZHLLpDMHTNSYPJ7qrcnCQdHCWsNQaT0xRvq2u80s=
github.com/aws/karpenter-core v0.26.1 h1:eZezm/Ibv+EbZ5sC3xNsaSAR4eJozWKJOEMI5nA/cTw=
github.com/aws/karpenter-core v0.26.1/go.mod h1:szIXYuMzg8kAwAbMIoB1VJBjAM+AdX+cIwsINkmWnpI=
github.com/aws/karpenter-core v0.26.2-0.20230306163515-7d58c3cee0fa h1:M83SgTjtd50xPEklIDgUIjoBvb65ftpsJUQ1nWlqNto=
github.com/aws/karpenter-core v0.26.2-0.20230306163515-7d58c3cee0fa/go.mod h1:szIXYuMzg8kAwAbMIoB1VJBjAM+AdX+cIwsINkmWnpI=
github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8=
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
Expand Down

0 comments on commit 162ce3f

Please sign in to comment.