Skip to content

Commit

Permalink
Fixes after big rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob committed Sep 21, 2021
1 parent b631ee5 commit 4b879b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
12 changes: 8 additions & 4 deletions pkg/cloudprovider/aws/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
Expand Down
31 changes: 4 additions & 27 deletions pkg/cloudprovider/aws/launchtemplate.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 4b879b7

Please sign in to comment.