Skip to content

Commit 52b79f3

Browse files
committed
Update CRIAPIV1Alpha2 warning lastOccurrence every call
This helps gather more accurate API usage data that informs efforts on how to safely migrate containerd clients to 2.0. Signed-off-by: Chris Henzie <[email protected]>
1 parent 90367cc commit 52b79f3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pkg/cri/instrument/instrumented_service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ func (in *instrumentedAlphaService) checkInitialized(ctx context.Context) error
105105

106106
// emitUsageWarning emits a warning when v1alpha2 cri-api is called.
107107
func (in *instrumentedAlphaService) emitUsageWarning(ctx context.Context) {
108-
// Only emit the warning the first time an v1alpha2 api is called
108+
// Only log the warning the first time an v1alpha2 api is called
109109
in.emitWarning.Do(func() {
110110
log.G(ctx).Warning("CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.")
111-
if in.warn != nil {
112-
in.warn.Emit(ctx, deprecation.CRIAPIV1Alpha2)
113-
}
114111
})
112+
if in.warn != nil {
113+
in.warn.Emit(ctx, deprecation.CRIAPIV1Alpha2)
114+
}
115115
}
116116

117117
func (in *instrumentedService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandboxRequest) (res *runtime.RunPodSandboxResponse, err error) {

pkg/cri/server/service_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ func TestAlphaCRIWarning(t *testing.T) {
101101
c.Version(ctx, &v1alpha2.VersionRequest{})
102102
c.Status(ctx, &v1alpha2.StatusRequest{})
103103

104-
// Only emit the warning the first time an v1alpha2 api is called.
104+
// Emit warnings both times an v1alpha2 api is called.
105105
expectedWarnings := []deprecation.Warning{
106106
deprecation.CRIAPIV1Alpha2,
107+
deprecation.CRIAPIV1Alpha2,
107108
}
108109
assert.Equal(t, expectedWarnings, ws.GetWarnings())
109110
}

0 commit comments

Comments
 (0)