Skip to content

Commit

Permalink
default to amd64 (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Gabrielson authored Sep 25, 2021
1 parent 6989466 commit 47863e1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/apis/provisioning/v1alpha4/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ var (
v1.LabelTopologyZone: {},
v1.LabelInstanceTypeStable: {},
}
DefaultHook = func(ctx context.Context, constraints *Constraints) {}
ValidateHook = func(ctx context.Context, constraints *Constraints) *apis.FieldError { return nil }
ConstrainHook = func(ctx context.Context, constraints *Constraints, pods ...*v1.Pod) error { return nil }
DefaultHook = func(ctx context.Context, constraints *Constraints) {}
ValidateHook = func(ctx context.Context, constraints *Constraints) *apis.FieldError { return nil }
ConstrainHook = func(ctx context.Context, constraints *Constraints, pods ...*v1.Pod) error { return nil }
)

var (
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/aws/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *AMIProvider) getSSMParameter(ctx context.Context, constraints *v1alpha1
return "", fmt.Errorf("no amazon-linux-2 ami available for both nvidia/neuron gpus and arm64 cpus")
}
amiNameSuffix = "-gpu"
} else if functional.ContainsString(constraints.Architectures, v1alpha4.ArchitectureArm64) {
} else if functional.ContainsString(constraints.Architectures, v1alpha4.ArchitectureArm64) {
amiNameSuffix = "-arm64"
}
return fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2%s/recommended/image_id", version, amiNameSuffix), nil
Expand Down
11 changes: 11 additions & 0 deletions pkg/cloudprovider/aws/apis/v1alpha1/constraints_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var ClusterDiscoveryTagKeyFormat = "kubernetes.io/cluster/%s"

// Default the constraints.
func (c *Constraints) Default(ctx context.Context) {
c.defaultArchitectures(ctx)
c.defaultCapacityTypes(ctx)
c.defaultSubnets(ctx)
c.defaultSecurityGroups(ctx)
Expand All @@ -39,6 +40,16 @@ func (c *Constraints) defaultCapacityTypes(ctx context.Context) {
c.CapacityTypes = []string{CapacityTypeOnDemand}
}

func (c *Constraints) defaultArchitectures(ctx context.Context) {
if len(c.Architectures) != 0 {
return
}
// In practice it is rare to be able to support both amd64 and
// arm64 at the same time, so we default to just amd64; this could
// change over time as tooling and techniques improve, etc.
c.Architectures = []string{v1alpha4.ArchitectureAmd64}
}

func (c *Constraints) defaultSubnets(ctx context.Context) {
if c.SubnetSelector != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/aws/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (c *CloudProvider) Constrain(ctx context.Context, constraints *v1alpha4.Con
if err != nil {
return fmt.Errorf("failed to deserialize provider, %w", err)
}
if err:= vendorConstraints.Constrain(ctx, pods...); err != nil {
if err := vendorConstraints.Constrain(ctx, pods...); err != nil {
return err
}
constraints.Provider.Raw, err = json.Marshal(vendorConstraints.AWS)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudprovider/fake/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func (c *CloudProvider) Create(ctx context.Context, constraints *v1alpha4.Constr
go func() {
err <- bind(&v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Labels: map[string]string{
v1.LabelTopologyZone: zone,
v1.LabelTopologyZone: zone,
v1.LabelInstanceTypeStable: instance.Name(),
},
},
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/allocation/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewScheduler(cloudProvider cloudprovider.CloudProvider, kubeClient client.C
return &Scheduler{
KubeClient: kubeClient,
Topology: &Topology{
kubeClient: kubeClient,
kubeClient: kubeClient,
},
}
}
Expand Down Expand Up @@ -178,7 +178,6 @@ func (s *Scheduler) getDaemons(ctx context.Context, constraints *v1alpha4.Constr
return pods, nil
}


// IsSchedulable returns true if the pod can schedule to the node
func DaemonWillSchedule(constraints *v1alpha4.Constraints, pod *v1.Pod) bool {
// Tolerate Taints
Expand Down

0 comments on commit 47863e1

Please sign in to comment.