From 4b879b78b9808a05b33cef1d5f2b48aa3d0bdd5b Mon Sep 17 00:00:00 2001 From: jacob Date: Sat, 18 Sep 2021 19:42:16 -0700 Subject: [PATCH] Fixes after big rebase --- pkg/cloudprovider/aws/ami.go | 12 ++++++---- pkg/cloudprovider/aws/launchtemplate.go | 31 ++++--------------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/pkg/cloudprovider/aws/ami.go b/pkg/cloudprovider/aws/ami.go index 97f52f4fed00..232c7095c82b 100644 --- a/pkg/cloudprovider/aws/ami.go +++ b/pkg/cloudprovider/aws/ami.go @@ -23,6 +23,7 @@ import ( "github.com/aws/aws-sdk-go/service/ssm" "github.com/aws/aws-sdk-go/service/ssm/ssmiface" "github.com/awslabs/karpenter/pkg/apis/provisioning/v1alpha4" + "github.com/awslabs/karpenter/pkg/cloudprovider" v1alpha1 "github.com/awslabs/karpenter/pkg/cloudprovider/aws/apis/v1alpha1" "github.com/patrickmn/go-cache" "k8s.io/client-go/kubernetes" @@ -45,18 +46,21 @@ func NewAMIProvider(ssm ssmiface.SSMAPI, clientSet *kubernetes.Clientset) *AMIPr } } -func (p *AMIProvider) getSSMParameter(ctx context.Context, constraints *Constraints, instanceTypes []cloudprovider.InstanceType) (string, error) { +func (p *AMIProvider) getSSMParameter(ctx context.Context, constraints *v1alpha1.Constraints, instanceTypes []cloudprovider.InstanceType) (string, error) { version, err := p.kubeServerVersion(ctx) if err != nil { return "", fmt.Errorf("kube server version, %w", err) } var amiNameSuffix string - if *constraints.Architecture == v1alpha3.ArchitectureArm64 { - amiNameSuffix = "-arm64" + if len(constraints.Architectures) > 0 { + // select the first one if multiple supported + if constraints.Architectures[0] == v1alpha4.ArchitectureArm64 { + amiNameSuffix = "-arm64" + } } if needsGPUAmi(instanceTypes) { if amiNameSuffix != "" { - return "", fmt.Errorf("no amazon-linux-2 ami available for both nvidia gpus and arm64 cpus") + return "", fmt.Errorf("no amazon-linux-2 ami available for both nvidia/neuron gpus and arm64 cpus") } amiNameSuffix = "-gpu" } diff --git a/pkg/cloudprovider/aws/launchtemplate.go b/pkg/cloudprovider/aws/launchtemplate.go index 64ffe840632d..582ac7af0525 100644 --- a/pkg/cloudprovider/aws/launchtemplate.go +++ b/pkg/cloudprovider/aws/launchtemplate.go @@ -1,7 +1,6 @@ /* Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. +you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -26,6 +25,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/awslabs/karpenter/pkg/cloudprovider" v1alpha1 "github.com/awslabs/karpenter/pkg/cloudprovider/aws/apis/v1alpha1" "github.com/awslabs/karpenter/pkg/utils/restconfig" "github.com/mitchellh/hashstructure/v2" @@ -203,43 +203,20 @@ func (p *LaunchTemplateProvider) createLaunchTemplate(ctx context.Context, optio return output.LaunchTemplate, nil } -<<<<<<< HEAD -func (p *LaunchTemplateProvider) getUserData(ctx context.Context, constraints *v1alpha1.Constraints) (string, error) { -======= -func (p *LaunchTemplateProvider) getSecurityGroupIds(ctx context.Context, provisioner *v1alpha3.Provisioner, constraints *Constraints) ([]string, error) { - securityGroupIds := []string{} - securityGroups, err := p.securityGroupProvider.Get(ctx, provisioner, constraints) - if err != nil { - return nil, fmt.Errorf("getting security group ids, %w", err) - } - for _, securityGroup := range securityGroups { - securityGroupIds = append(securityGroupIds, aws.StringValue(securityGroup.GroupId)) - } - return securityGroupIds, nil -} - -func (p *LaunchTemplateProvider) getUserData(ctx context.Context, provisioner *v1alpha3.Provisioner, constraints *Constraints, instanceTypes []cloudprovider.InstanceType) (string, error) { +func (p *LaunchTemplateProvider) getUserData(ctx context.Context, constraints *v1alpha1.Constraints, instanceTypes []cloudprovider.InstanceType) (string, error) { var containerRuntimeArg string if !needsDocker(instanceTypes) { containerRuntimeArg = "--container-runtime containerd" } ->>>>>>> support for neuron var userData bytes.Buffer userData.WriteString(fmt.Sprintf(`#!/bin/bash /etc/eks/bootstrap.sh '%s' %s \ --apiserver-endpoint '%s'`, -<<<<<<< HEAD constraints.Cluster.Name, + containerRuntimeArg, constraints.Cluster.Endpoint)) caBundle, err := p.GetCABundle(ctx) -======= - *provisioner.Spec.Cluster.Name, - containerRuntimeArg, - provisioner.Spec.Cluster.Endpoint)) - - caBundle, err := provisioner.Spec.Cluster.GetCABundle(ctx) ->>>>>>> support for neuron if err != nil { return "", fmt.Errorf("getting ca bundle for user data, %w", err) }