Skip to content

Commit

Permalink
chore: logging touchups (aws#3723)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Innis <[email protected]>
  • Loading branch information
ellistarn and jonathan-innis authored Apr 7, 2023
1 parent 672a832 commit 550ca87
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/providers/amifamily/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (p *Provider) fetchAMIsFromSSM(ctx context.Context, ssmQuery string) (strin
ami := aws.StringValue(output.Parameter.Value)
p.ssmCache.SetDefault(ssmQuery, ami)
if p.cm.HasChanged("ssmquery-"+ssmQuery, ami) {
logging.FromContext(ctx).With("ami", ami, "query", ssmQuery).Debugf("discovered new ami")
logging.FromContext(ctx).With("ami", ami, "query", ssmQuery).Debugf("discovered ami")
}
return ami, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (p *Provider) Create(ctx context.Context, nodeTemplate *v1alpha1.AWSNodeTem
"instance-type", aws.StringValue(instance.InstanceType),
"zone", aws.StringValue(instance.Placement.AvailabilityZone),
"capacity-type", GetCapacityType(instance),
"capacity", capacity).Infof("launched new instance")
"capacity", capacity).Infof("launched instance")

return instance, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/providers/instancetype/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (p *Provider) getInstanceTypeZones(ctx context.Context, nodeTemplate *v1alp
return nil, fmt.Errorf("describing instance type zone offerings, %w", err)
}
if p.cm.HasChanged("zonal-offerings", nodeTemplate.Spec.SubnetSelector) {
logging.FromContext(ctx).With("subnet-selector", pretty.Concise(nodeTemplate.Spec.SubnetSelector)).Debugf("discovered EC2 instance types zonal offerings for subnets")
logging.FromContext(ctx).With("zones", zones.List(), "instance-type-count", len(instanceTypeZones), "node-template", nodeTemplate.Name).Debugf("discovered offerings for instance types")
}
p.cache.SetDefault(cacheKey, instanceTypeZones)
return instanceTypeZones, nil
Expand Down Expand Up @@ -225,7 +225,7 @@ func (p *Provider) GetInstanceTypes(ctx context.Context) ([]*ec2.InstanceTypeInf
}
if p.cm.HasChanged("instance-types", instanceTypes) {
logging.FromContext(ctx).With(
"instance-type-count", len(instanceTypes)).Debugf("discovered EC2 instance types")
"count", len(instanceTypes)).Debugf("discovered instance types")
}
atomic.AddUint64(&p.instanceTypesSeqNum, 1)
p.cache.SetDefault(InstanceTypesCacheKey, instanceTypes)
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/launchtemplate/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ func (p *Provider) volumeSize(quantity *resource.Quantity) *int64 {
func (p *Provider) hydrateCache(ctx context.Context) {
clusterName := settings.FromContext(ctx).ClusterName
ctx = logging.WithLogger(ctx, logging.FromContext(ctx).With("tag-key", karpenterManagedTagKey, "tag-value", clusterName))
logging.FromContext(ctx).Debugf("hydrating the launch template cache")
if err := p.ec2api.DescribeLaunchTemplatesPagesWithContext(ctx, &ec2.DescribeLaunchTemplatesInput{
Filters: []*ec2.Filter{{Name: aws.String(fmt.Sprintf("tag:%s", karpenterManagedTagKey)), Values: []*string{aws.String(clusterName)}}},
}, func(output *ec2.DescribeLaunchTemplatesOutput, _ bool) bool {
Expand All @@ -288,8 +287,9 @@ func (p *Provider) hydrateCache(ctx context.Context) {
return true
}); err != nil {
logging.FromContext(ctx).Errorf(fmt.Sprintf("Unable to hydrate the AWS launch template cache, %s", err))
} else {
logging.FromContext(ctx).With("count", p.cache.ItemCount()).Debugf("hydrated launch template cache")
}
logging.FromContext(ctx).With("item-count", p.cache.ItemCount()).Debugf("finished hydrating the launch template cache")
}

func (p *Provider) cachedEvictedFunc(ctx context.Context) func(string, interface{}) {
Expand All @@ -301,7 +301,7 @@ func (p *Provider) cachedEvictedFunc(ctx context.Context) func(string, interface
}
launchTemplate := lt.(*ec2.LaunchTemplate)
if _, err := p.ec2api.DeleteLaunchTemplate(&ec2.DeleteLaunchTemplateInput{LaunchTemplateId: launchTemplate.LaunchTemplateId}); err != nil {
logging.FromContext(ctx).With("launch-template", launchTemplate.LaunchTemplateName).Errorf("Unable to delete launch template, %v", err)
logging.FromContext(ctx).With("launch-template", launchTemplate.LaunchTemplateName).Errorf("failed to delete launch template, %v", err)
return
}
logging.FromContext(ctx).With("launch-template", launchTemplate.LaunchTemplateName).Debugf("deleted launch template")
Expand Down

0 comments on commit 550ca87

Please sign in to comment.