From 5362e8b6cb1ac42356beab84a6ee8db3ccb495b5 Mon Sep 17 00:00:00 2001 From: mattjmcnaughton Date: Sat, 22 Feb 2020 12:06:40 -0500 Subject: [PATCH] Fix initialization bug in `FakeImageService` When adding this functionality in https://github.com/kubernetes/kubernetes/pull/88372, I forgot to allocate a map for the `Errors` field when constructing the object. As a result, trying to actually use the `InjectError` method failed (as I noticed when I started trying to write tests to actually use `InjectError`). Fortunately, `FakeImageService` is only used in tests... but still, we should fix this issue. Fixing in a separate diff from the one which will add additional test coverage (and actually use `InjectError`, because I don't like having non-working code in master.) We could also revert the original commit and then re-merge with this fix, but that seems like unnecessary work given we already have a fix ready to go. --- .../src/k8s.io/cri-api/pkg/apis/testing/fake_image_service.go | 1 + 1 file changed, 1 insertion(+) diff --git a/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_image_service.go b/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_image_service.go index 1add8e27599..fd723d8f4f8 100644 --- a/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_image_service.go +++ b/staging/src/k8s.io/cri-api/pkg/apis/testing/fake_image_service.go @@ -65,6 +65,7 @@ func (r *FakeImageService) SetFakeFilesystemUsage(usage []*runtimeapi.Filesystem func NewFakeImageService() *FakeImageService { return &FakeImageService{ Called: make([]string, 0), + Errors: make(map[string][]error), Images: make(map[string]*runtimeapi.Image), } }