Skip to content

Commit 52643d3

Browse files
committed
temp: more logging
1 parent 28700c3 commit 52643d3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pkg/auth/cred.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package auth
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"time"
2223

2324
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
@@ -49,10 +50,10 @@ func (w *expireEarlyTokenCredential) GetToken(ctx context.Context, options polic
4950
// IMDS may have the MI token already, and have an expiration of less than 2h when we receive the token. We don't want to set that value beyond the ExpiresOn time and potentially miss a refresh
5051
// So we just return earlier here. See discussion here: https://github.com/Azure/karpenter-provider-azure/pull/391/files#r1648633051
5152
if token.ExpiresOn.Before(twoHoursFromNow) {
52-
log.FromContext(ctx).Info(fmt.Sprintf("XPMT: ExpiresOn %s is before two hours from now %s, not adjusting", token.ExpiresOn, twoHoursFromNow))
53+
log.FromContext(ctx).Info(fmt.Sprintf("XPMT: ExpiresOn=%s (RefreshOn=%s) is before two hours from now=%s, not adjusting", token.ExpiresOn, token.RefreshOn, twoHoursFromNow))
5354
return token, nil
5455
}
55-
log.FromContext(ctx).Info(fmt.Sprintf("XPMT: adjusting ExpiresOn from %s to %s", token.ExpiresOn, twoHoursFromNow))
56+
log.FromContext(ctx).Info(fmt.Sprintf("XPMT: adjusting ExpiresOn (RefreshOn=%s) from %s to %s", token.ExpiresOn, token.RefreshOn, twoHoursFromNow))
5657
// If the token expires in more than 2 hours, this means we are taking in a new token with a fresh 24h expiration time or one already in the cache that hasn't been modified by us, so we want to set that to two hours so
5758
// we can refresh it early to avoid the polling bugs mentioned in the above issue
5859
token.ExpiresOn = twoHoursFromNow

pkg/providers/imagefamily/nodeimageversionsclient.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
2828
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
2929
types "github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily/types"
30+
"sigs.k8s.io/controller-runtime/pkg/log"
3031
)
3132

3233
type NodeImageVersionsClient struct {
@@ -51,6 +52,7 @@ func (l *NodeImageVersionsClient) List(ctx context.Context, location, subscripti
5152
if err != nil {
5253
return types.NodeImageVersionsResponse{}, err
5354
}
55+
log.FromContext(ctx).Info(fmt.Sprintf("XPMT: NIV getToken(): ExpiresOn=%s, RefreshOn=%s", token.ExpiresOn, token.RefreshOn))
5456

5557
req, err := http.NewRequestWithContext(context.Background(), "GET", resourceURL, nil)
5658
if err != nil {

0 commit comments

Comments
 (0)