@@ -398,6 +398,8 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, obj *sou
398
398
return sreconcile .ResultEmpty , e
399
399
}
400
400
}
401
+
402
+ // Fetch the repository index from remote.
401
403
checksum , err := newChartRepo .CacheIndex ()
402
404
if err != nil {
403
405
e := & serror.Event {
@@ -410,6 +412,15 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, obj *sou
410
412
}
411
413
* chartRepo = * newChartRepo
412
414
415
+ // Short-circuit based on the fetched index being an exact match to the
416
+ // stored Artifact. This prevents having to unmarshal the YAML to calculate
417
+ // the (stable) revision, which is a memory expensive operation.
418
+ if obj .GetArtifact ().HasChecksum (checksum ) {
419
+ * artifact = * obj .GetArtifact ()
420
+ conditions .Delete (obj , sourcev1 .FetchFailedCondition )
421
+ return sreconcile .ResultSuccess , nil
422
+ }
423
+
413
424
// Load the cached repository index to ensure it passes validation.
414
425
if err := chartRepo .LoadFromCache (); err != nil {
415
426
e := & serror.Event {
@@ -419,23 +430,24 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, obj *sou
419
430
conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Err .Error ())
420
431
return sreconcile .ResultEmpty , e
421
432
}
422
- defer chartRepo .Unload ()
433
+ chartRepo .Unload ()
423
434
424
435
// Mark observations about the revision on the object.
425
- if ! obj .GetArtifact ().HasRevision (checksum ) {
436
+ if ! obj .GetArtifact ().HasRevision (newChartRepo . Checksum ) {
426
437
message := fmt .Sprintf ("new index revision '%s'" , checksum )
427
438
conditions .MarkTrue (obj , sourcev1 .ArtifactOutdatedCondition , "NewRevision" , message )
428
439
conditions .MarkReconciling (obj , "NewRevision" , message )
429
440
}
430
441
431
- conditions .Delete (obj , sourcev1 .FetchFailedCondition )
432
-
433
442
// Create potential new artifact.
434
443
* artifact = r .Storage .NewArtifactFor (obj .Kind ,
435
444
obj .ObjectMeta .GetObjectMeta (),
436
445
chartRepo .Checksum ,
437
446
fmt .Sprintf ("index-%s.yaml" , checksum ))
438
447
448
+ // Delete any stale failure observation
449
+ conditions .Delete (obj , sourcev1 .FetchFailedCondition )
450
+
439
451
return sreconcile .ResultSuccess , nil
440
452
}
441
453
@@ -462,7 +474,7 @@ func (r *HelmRepositoryReconciler) reconcileArtifact(ctx context.Context, obj *s
462
474
}
463
475
}()
464
476
465
- if obj .GetArtifact ().HasRevision (artifact .Revision ) {
477
+ if obj .GetArtifact ().HasRevision (artifact .Revision ) && obj . GetArtifact (). HasChecksum ( artifact . Checksum ) {
466
478
r .eventLogf (ctx , obj , events .EventTypeTrace , sourcev1 .ArtifactUpToDateReason , "artifact up-to-date with remote revision: '%s'" , artifact .Revision )
467
479
return sreconcile .ResultSuccess , nil
468
480
}
0 commit comments