diff --git a/pkg/apis/provisioning/v1alpha4/register.go b/pkg/apis/provisioning/v1alpha4/register.go index e50e8001f09b..f39caf74fd0e 100644 --- a/pkg/apis/provisioning/v1alpha4/register.go +++ b/pkg/apis/provisioning/v1alpha4/register.go @@ -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 ( diff --git a/pkg/cloudprovider/aws/ami.go b/pkg/cloudprovider/aws/ami.go index 4b0f6bd174b5..fe5c1040f3b0 100644 --- a/pkg/cloudprovider/aws/ami.go +++ b/pkg/cloudprovider/aws/ami.go @@ -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 diff --git a/pkg/cloudprovider/aws/apis/v1alpha1/constraints_defaults.go b/pkg/cloudprovider/aws/apis/v1alpha1/constraints_defaults.go index 99b4d2478420..fca12b22560b 100644 --- a/pkg/cloudprovider/aws/apis/v1alpha1/constraints_defaults.go +++ b/pkg/cloudprovider/aws/apis/v1alpha1/constraints_defaults.go @@ -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) @@ -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 diff --git a/pkg/cloudprovider/aws/cloudprovider.go b/pkg/cloudprovider/aws/cloudprovider.go index 8e6122a85fac..4957b71caae8 100644 --- a/pkg/cloudprovider/aws/cloudprovider.go +++ b/pkg/cloudprovider/aws/cloudprovider.go @@ -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) diff --git a/pkg/cloudprovider/fake/cloudprovider.go b/pkg/cloudprovider/fake/cloudprovider.go index aa9396892aeb..74072b3b5118 100644 --- a/pkg/cloudprovider/fake/cloudprovider.go +++ b/pkg/cloudprovider/fake/cloudprovider.go @@ -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(), }, }, diff --git a/pkg/controllers/allocation/scheduling/scheduler.go b/pkg/controllers/allocation/scheduling/scheduler.go index 3d4d22c82029..49d680200fff 100644 --- a/pkg/controllers/allocation/scheduling/scheduler.go +++ b/pkg/controllers/allocation/scheduling/scheduler.go @@ -65,7 +65,7 @@ func NewScheduler(cloudProvider cloudprovider.CloudProvider, kubeClient client.C return &Scheduler{ KubeClient: kubeClient, Topology: &Topology{ - kubeClient: kubeClient, + kubeClient: kubeClient, }, } } @@ -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