This article discusses a common Git Commit issue faced by our customers and the suggested methods to avoid it and mitigate it.
When using Github as Source of Truth for Harness resources creation & management, we usually manage the bulk creation of Applications using Github Integration where the YAML code is pushed to Harness and is rendered in the UI.
Sometimes users will notice that a commit has been skipped when pushed from Git and are unsure of why this is the case.
Here we will discuss what causes this :
- Taking a look at the delegate logs for the Commit ID we will see the below error
GIT_YAML_LOG_ENTRY: Exception in processing GitTask io.harness.exception.YamlException: Git diff failed. End Commit [ad98b4bd2] should be after start commit [664a2975]
This means that the Commit Head did not find the right start commit to be able to process the new changes based on the Git Diff. This happens due to a classic case of race conditions between Git to Harness and Harness to Git.
We cannot have two commits so close to each other when operating from Git to Harness and Harness to Git. The reason for this is because when the user does some changes in the Harness UI it gets queued to be pushed to Git in about 10-20 secs.
Since we were pushing in this repo for the first time we didn’t have any previous commit ID and we went ahead and pushed (otherwise we would have delayed the push to accommodate the Git side changes). By the time webhook came to us were already in a state of the delegate pushing to Git.
We should not make changes in Git and Harness in rapid succession.
A second change on the same App things are handled gracefully already as we delay push in case the commit head is not recorded in Harness.