GitRepositoryReconciler no-op clone improvements #721
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The no-op git clone implementation introduced some bugs in the GitRepo reconciler due to the way it's currently integrated in the reconciliation loop. Skipping the reconciliation in the middle leaves other critical subreconcilers to not operate on the object. This causes inconsistent behavior and sometimes persistent reconciliation failure.
This change updates the GitRepo reconciler to attempt no-op git clone optimization only when an artifact is already present in the storage. The git packages are also updated to not return error anymore but a partial commit which contains commit hash and reference. On full clone, concrete commit is returned which contains all the commit metadata and content fetched from remote repository. With these, the GitRepo reconciler receives a partial commit when no-op clone takes place. In
reconcileSource()
subreconciler, it then populates the source build directory with the existing artifact content and lets the rest of the reconciliation continue. The other subreconcilers then continue building the source with any changes in the GitRepo attributes, like include, ignore, etc, when attributes related to them change but the remote repository has not changed.Previous logs and events related to no-op clone are no longer present by default because we are doing full reconciliation every time now. When log level is set to debug, the no-op clone is logged:
Failure recovery notification message for no-op clone results in:
as the partial commit doesn't contain the commit message information.
Since it's not ideal to use global flags to set feature gates in the tests, the GitRepositoryReconciler now has a
features
field containing all the enabled features. This makes it easier to configure the feature per test without affecting other tests. All the tests now have the default feature gates enabled.These improvements are based on a series of attempts to find and fix the issues mentioned above, see https://github.com/fluxcd/source-controller/compare/gitrepo-rec-fixes?expand=1 . Some of the ideas from there may be added in the future separately.