controllers: truncate temporary cached Helm index
Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
parent
028a85d61a
commit
ad0993e93e
|
@ -416,6 +416,10 @@ func (r *HelmRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *s
|
|||
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason,
|
||||
"stored artifact for revision '%s'", artifact.Revision)
|
||||
}
|
||||
|
||||
if err := chartRepo.RemoveCache(); err != nil {
|
||||
ctrl.LoggerFrom(ctx).Error(err, "failed to remove temporary cached index file")
|
||||
}
|
||||
}()
|
||||
|
||||
if obj.GetArtifact().HasRevision(artifact.Revision) {
|
||||
|
@ -427,10 +431,7 @@ func (r *HelmRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *s
|
|||
// and they have to be reconciled.
|
||||
conditions.MarkReconciling(obj, "NewRevision", "new index revision '%s'", artifact.Revision)
|
||||
|
||||
// Clear cache at the very end.
|
||||
defer chartRepo.RemoveCache()
|
||||
|
||||
// Create artifact dir.
|
||||
// Create artifact dir
|
||||
if err := r.Storage.MkdirAll(*artifact); err != nil {
|
||||
return sreconcile.ResultEmpty, &serror.Event{
|
||||
Err: fmt.Errorf("failed to create artifact directory: %w", err),
|
||||
|
|
|
@ -471,9 +471,9 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
|||
|
||||
var chartRepo repository.ChartRepository
|
||||
var artifact sourcev1.Artifact
|
||||
dlog := log.NewDelegatingLogSink(log.NullLogSink{})
|
||||
nullLogger := logr.New(dlog)
|
||||
got, err := r.reconcileSource(logr.NewContext(ctx, nullLogger), obj, &artifact, &chartRepo)
|
||||
got, err := r.reconcileSource(context.TODO(), obj, &artifact, &chartRepo)
|
||||
defer os.Remove(chartRepo.CachePath)
|
||||
|
||||
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(tt.assertConditions))
|
||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||
g.Expect(got).To(Equal(tt.want))
|
||||
|
|
Loading…
Reference in New Issue