Skip to content

Commit

Permalink
fix GetImageID to use ctx for logging (#258)
Browse files Browse the repository at this point in the history
Co-authored-by: Charlie McBride <[email protected]>
  • Loading branch information
charliedmcb and Charlie McBride authored Apr 11, 2024
1 parent 9a4ffe0 commit 1bf08c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cloudprovider/drift.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (c *CloudProvider) isImageVersionDrifted(
return "", err
}

expectedImageID, err := c.imageProvider.GetImageID(communityImageName, publicGalleryURL, nodeClass.Spec.GetImageVersion())
expectedImageID, err := c.imageProvider.GetImageID(ctx, communityImageName, publicGalleryURL, nodeClass.Spec.GetImageVersion())
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/imagefamily/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (p *Provider) Get(ctx context.Context, nodeClass *v1alpha2.AKSNodeClass, in
for _, defaultImage := range defaultImages {
if err := instanceType.Requirements.Compatible(defaultImage.Requirements, v1alpha2.AllowUndefinedLabels); err == nil {
communityImageName, publicGalleryURL := defaultImage.CommunityImage, defaultImage.PublicGalleryURL
return p.GetImageID(communityImageName, publicGalleryURL, nodeClass.Spec.GetImageVersion())
return p.GetImageID(ctx, communityImageName, publicGalleryURL, nodeClass.Spec.GetImageVersion())
}
}

Expand All @@ -92,7 +92,7 @@ func (p *Provider) KubeServerVersion(ctx context.Context) (string, error) {
}

// Input versionName == "" to get the latest version
func (p *Provider) GetImageID(communityImageName, publicGalleryURL, versionName string) (string, error) {
func (p *Provider) GetImageID(ctx context.Context, communityImageName, publicGalleryURL, versionName string) (string, error) {
key := fmt.Sprintf("%s/%s/%s", publicGalleryURL, communityImageName, versionName)
imageID, found := p.imageCache.Get(key)
if found {
Expand All @@ -118,7 +118,7 @@ func (p *Provider) GetImageID(communityImageName, publicGalleryURL, versionName

selectedImageID := BuildImageID(publicGalleryURL, communityImageName, versionName)
if p.cm.HasChanged(key, selectedImageID) {
logging.FromContext(context.Background()).With("image-id", selectedImageID).Info("discovered new image id")
logging.FromContext(ctx).With("image-id", selectedImageID).Info("discovered new image id")
}
p.imageCache.Set(key, selectedImageID, imageExpirationInterval)
return selectedImageID, nil
Expand Down

0 comments on commit 1bf08c1

Please sign in to comment.