Skip to content

Commit 6581b7a

Browse files
committed
Fix repository cache regression
If implemented this make sure we don't unload an index before caching it during a chart build phase. Signed-off-by: Soule BA <[email protected]>
1 parent 9e33041 commit 6581b7a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

controllers/helmchart_controller_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ 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+
g.Expect(testCache.ItemCount()).To(Equal(1))
164+
162165
g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())
163166

164167
// 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)