Skip to content

Commit

Permalink
Merge pull request fluxcd#761 from souleb/fix-cache-regression
Browse files Browse the repository at this point in the history
Fix repository cache regression
  • Loading branch information
darkowlzz committed Jun 6, 2022
2 parents 9e33041 + 0d4d78f commit b66ff92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions controllers/helmchart_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ func TestHelmChartReconciler_Reconcile(t *testing.T) {
return obj.Status.LastHandledReconcileAt == "now"
}, timeout).Should(BeTrue())

// Check if the cache contains the index.
repoKey := client.ObjectKey{Name: repository.Name, Namespace: repository.Namespace}
err = testEnv.Get(ctx, repoKey, repository)
g.Expect(err).ToNot(HaveOccurred())
localPath := testStorage.LocalPath(*repository.GetArtifact())
_, found := testCache.Get(localPath)
g.Expect(found).To(BeTrue())

g.Expect(testEnv.Delete(ctx, obj)).To(Succeed())

// Wait for HelmChart to be deleted
Expand Down
5 changes: 3 additions & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var (

var (
testRegistryServer *registryClientTestServer
testCache *cache.Cache
)

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

c := cache.New(5, 1*time.Second)
testCache = cache.New(5, 1*time.Second)
cacheRecorder := cache.MustMakeMetrics()
if err := (&HelmChartReconciler{
Client: testEnv,
EventRecorder: record.NewFakeRecorder(32),
Metrics: testMetricsH,
Getters: testGetters,
Storage: testStorage,
Cache: c,
Cache: testCache,
TTL: 1 * time.Second,
CacheRecorder: cacheRecorder,
}).SetupWithManager(testEnv); err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/helm/chart/builder_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func (b *remoteChartBuilder) downloadFromRepository(remote *repository.ChartRepo
err = fmt.Errorf("could not load repository index for remote chart reference: %w", err)
return nil, &BuildError{Reason: ErrChartPull, Err: err}
}
defer remote.Unload()

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

0 comments on commit b66ff92

Please sign in to comment.