Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Capacity type after node creation #716

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions pkg/cloudprovider/aws/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"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/awslabs/karpenter/pkg/cloudprovider/aws/apis/v1alpha1"
"knative.dev/pkg/logging"

"go.uber.org/multierr"
Expand Down Expand Up @@ -66,11 +66,12 @@ func (p *InstanceProvider) Create(ctx context.Context, constraints *v1alpha1.Con
); err != nil {
return nil, err
}
logging.FromContext(ctx).Infof("Launched instance: %s, type: %s, zone: %s, hostname: %s",
logging.FromContext(ctx).Infof("Launched instance: %s, hostname: %s, type: %s, zone: %s, capacityType: %s",
aws.StringValue(instance.InstanceId),
aws.StringValue(instance.PrivateDnsName),
aws.StringValue(instance.InstanceType),
aws.StringValue(instance.Placement.AvailabilityZone),
aws.StringValue(instance.PrivateDnsName),
getCapacityType(instance),
)
// Convert Instance to Node
node, err := p.instanceToNode(ctx, instance, instanceTypes)
Expand Down Expand Up @@ -223,6 +224,7 @@ func (p *InstanceProvider) instanceToNode(ctx context.Context, instance *ec2.Ins
},
NodeInfo: v1.NodeSystemInfo{
Architecture: aws.StringValue(instance.Architecture),
OSImage: aws.StringValue(instance.ImageId),
OperatingSystem: v1alpha4.OperatingSystemLinux,
},
},
Expand Down Expand Up @@ -250,3 +252,11 @@ func combineFleetErrors(errors []*ec2.CreateFleetError) (errs error) {
}
return fmt.Errorf("with fleet error(s), %w", errs)
}

func getCapacityType(instance *ec2.Instance) string {
capacityType := v1alpha1.CapacityTypeOnDemand
if instance.SpotInstanceRequestId != nil {
capacityType = v1alpha1.CapacityTypeSpot
}
return capacityType
}