Remove the fallback to the legacy coherency algorithm.#2266
Remove the fallback to the legacy coherency algorithm.#2266andriipatsula merged 14 commits intodotnet:mainfrom
Conversation
|
We need to implement an alert mechanism when this fails. Right now, Legacy coherency is probably filling some gaps where repos are failing the strict coherency update. Whether it gets it right is unknown, but they're getting updates rather than failing silently. We should implement this part: #2687 in this PR:
This behavior would not be implemented in local darc, just the subscription actor service. The check, if it could not get info on which dependencies fail coherency, would tell the user to go and run local darc to resolve. |
|
I am going to introduce a new merge policy class like: public class ValidateCoherencyMergePolicy : MergePolicy
{
public override string DisplayName => "TODO";
/// overrides `IMergePolicy.EvaluateAsync`
public override async Task<MergePolicyEvaluationResult> EvaluateAsync(IPullRequest pr, IRemote darc)
{
string prBranch = "";
string repoUrl = "";
List<DependencyDetail> existingDependencies = (await darc.GetDependenciesAsync(repoUrl, prBranch)).ToList();
List<DependencyUpdate> coherencyUpdates = new List<DependencyUpdate>();
try
{
// remoteFactory ???
coherencyUpdates = await darc.GetRequiredCoherencyUpdatesAsync(existingDependencies, remoteFactory, CoherencyMode.Strict);
}
catch (DarcCoherencyException)
{
return Fail("Is not coherent");
}
if (coherencyUpdates.Any())
{
return Fail("Is not coherent");
}
return Succeed("Is coherent.");
}
}and utilize the [!] But we don't have access to public interface IMergePolicy : IMergePolicyInfo
{
- Task<MergePolicyEvaluationResult> EvaluateAsync(IPullRequest pr, IRemote darc);
+ Task<MergePolicyEvaluationResult> EvaluateAsync(IPullRequest pr, IRemoteFactory remoteFactory);
}/cc @riarenas , @mmitche |
|
I don't think you need to redo the coherency calculation. Instead, GetRequiredUpdates would return whether the coherency update failed: https://github.com/dotnet/arcade-services/blob/main/src/Maestro/SubscriptionActorService/PullRequestActor.cs#L1083-L1088 Then, you modify the IPullRequest interface to include a bit that indicates whether the last coherency update failed or not. It currently just knows about the set of updates in the PR. The new merge policy would check this bit and let the user know. |
|
As one of the results of this work, could you please log an issue with proposal to improve our testing capabilities for these scenarios? This might involve anything that you found missing while working on this issue, such as having a local BAR database or resources for integration testing. |
|
@riarenas , @mmitche could you please short feedback about the latest changes in the PR. @riarenas , we can have a call and discuss next steps.
|
Yay! a check! Is it possible to add instructions to the error message on how to fix the coherency issue? I believe the Exception can capture some more details that would be helpful to add. I'll see if I can track which ones I'm talking about.
Sounds good
We could add the check to the standard merge policy, which is already an aggregation of policies that we suggest everyone should have: https://github.com/dotnet/arcade-services/blob/main/src/Maestro/Maestro.MergePolicies/StandardMergePolicy.cs For subscriptions not using the standard policy I see a few options:
|
bb0f578 to
0ed4b8f
Compare
|
PR has been updated. Here are a few examples:
I did refactor/rewrite the ScenarioTests_GitHubFlow::Darc_GitHubFlow_NonBatched_WithCoherency test, since the Strick algorithm consistently failed and it always fall back to the Legacy algorithm. |
src/Maestro/Maestro.MergePolicies/ValidateCoherencyMergePolicy.cs
Outdated
Show resolved
Hide resolved
mmitche
left a comment
There was a problem hiding this comment.
Looking generally good. I haven't taken a very close look at the tests yet.
The only downside to the approach taken is that if a repo doesn't enable a merge policy, either using standard or including this specifically, they won't the direct feedback that there is an issue. IMO this isn't a blocker as standard is heavily used.
It would be good to eventually divide the merge policies into optional ones that enable auto-merge, and ones that are required to evaluate the dependency update.
Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
| StringBuilder description = new StringBuilder("Coherency update failed for the following dependencies:"); | ||
| foreach (CoherencyErrorDetails error in pr.CoherencyErrors) | ||
| { | ||
| description.Append("\n * ").Append(error.Error); |
There was a problem hiding this comment.
You can use AppendLine instead of Append so you can save yourself adding the \n manually
ghost
left a comment
There was a problem hiding this comment.
LGTM pretty much. Just make sure to run all of the scenario test suite to make sure there are no problems there, and to keep in mind the necessary followups described in the issue.
Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
#2687