Skip to content

Commit b66ff92

Browse files
authored
Merge pull request #761 from souleb/fix-cache-regression
Fix repository cache regression
2 parents 9e33041 + 0d4d78f commit b66ff92

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

controllers/helmchart_controller_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) {
159159
return obj.Status.LastHandledReconcileAt == "now"
160160
}, timeout).Should(BeTrue())
161161

162+
// Check if the cache contains the index.
163+
repoKey := client.ObjectKey{Name: repository.Name, Namespace: repository.Namespace}
164+
err = testEnv.Get(ctx, repoKey, repository)
165+
g.Expect(err).ToNot(HaveOccurred())
166+
localPath := testStorage.LocalPath(*repository.GetArtifact())
167+
_, found := testCache.Get(localPath)
168+
g.Expect(found).To(BeTrue())
169+
162170
g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())
163171

164172
// Wait for HelmChart to be deleted

controllers/suite_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ var (
103103

104104
var (
105105
testRegistryServer *registryClientTestServer
106+
testCache *cache.Cache
106107
)
107108

108109
func init() {
@@ -246,15 +247,15 @@ func TestMain(m *testing.M) {
246247
panic(fmt.Sprintf("Failed to start HelmRepositoryOCIReconciler: %v", err))
247248
}
248249

249-
c := cache.New(5, 1*time.Second)
250+
testCache = cache.New(5, 1*time.Second)
250251
cacheRecorder := cache.MustMakeMetrics()
251252
if err := (&HelmChartReconciler{
252253
Client: testEnv,
253254
EventRecorder: record.NewFakeRecorder(32),
254255
Metrics: testMetricsH,
255256
Getters: testGetters,
256257
Storage: testStorage,
257-
Cache: c,
258+
Cache: testCache,
258259
TTL: 1 * time.Second,
259260
CacheRecorder: cacheRecorder,
260261
}).SetupWithManager(testEnv); err != nil {

internal/helm/chart/builder_remote.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ func (b *remoteChartBuilder) downloadFromRepository(remote *repository.ChartRepo
186186
err = fmt.Errorf("could not load repository index for remote chart reference: %w", err)
187187
return nil, &BuildError{Reason: ErrChartPull, Err: err}
188188
}
189-
defer remote.Unload()
190189

191190
// Get the current version for the RemoteReference
192191
cv, err := remote.Get(remoteRef.Name, remoteRef.Version)

0 commit comments

Comments
 (0)