Skip to content

Add V2 flow for runner deletion #3954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Samirat
Copy link

@Samirat Samirat commented Jul 25, 2025

This PR implements the V2 flow for runner deletion (going through the monolith)

@Copilot Copilot AI review requested due to automatic review settings July 25, 2025 13:42
@Samirat Samirat requested a review from a team as a code owner July 25, 2025 13:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a V2 flow for runner deletion by adding methods to handle runner deletion through the monolith rather than directly. The changes introduce a new deletion API method and refactor URL construction logic for better code reuse.

  • Adds DeleteRunnerAsync method to support V2 runner deletion flow
  • Refactors URL construction logic into a reusable GetEntityUrl helper method
  • Updates existing methods to use the new helper for consistent URL generation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Runner.Listener/Configuration/ConfigurationManager.cs Adds V2 flow logic for runner configuration with conditional branching
src/Runner.Common/RunnerDotcomServer.cs Implements DeleteRunnerAsync method and refactors URL construction into GetEntityUrl helper


if (runnerSettings.UseV2Flow)
{
await _dotcomServer.
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line appears to be incomplete - it has an incomplete method call with no method name after '_dotcomServer.'

Suggested change
await _dotcomServer.

Copilot uses AI. Check for mistakes.

@@ -204,6 +103,12 @@ public async Task<List<TaskAgentPool>> GetRunnerGroupsAsync(string githubUrl, st
return await RetryRequest<DistributedTask.WebApi.Runner>(githubApiUrl, githubToken, RequestType.Post, 3, "Failed to add agent", body);
}

private async Task<DistributedTask.WebApi.Runner> DeleteRunnerAsync(string githubUrl, string githubToken, ulong runnerId)
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DeleteRunnerAsync method is declared as private but should be public to match the interface declaration on line 22. This will cause a compilation error.

Suggested change
private async Task<DistributedTask.WebApi.Runner> DeleteRunnerAsync(string githubUrl, string githubToken, ulong runnerId)
public async Task<DistributedTask.WebApi.Runner> DeleteRunnerAsync(string githubUrl, string githubToken, ulong runnerId)

Copilot uses AI. Check for mistakes.

private async Task<DistributedTask.WebApi.Runner> DeleteRunnerAsync(string githubUrl, string githubToken, ulong runnerId)
{
var githubApiUrl = $"{GetEntityUrl(githubUrl)}/runners/{runnerId}";
return await RetryRequest<DistributedTask.WebApi.Runner>(githubApiUrl, githubToken, RequestType.Delete, 3, "Failed to add agent");
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message 'Failed to add agent' is incorrect for a delete operation. It should be 'Failed to delete runner' or similar.

Suggested change
return await RetryRequest<DistributedTask.WebApi.Runner>(githubApiUrl, githubToken, RequestType.Delete, 3, "Failed to add agent");
return await RetryRequest<DistributedTask.WebApi.Runner>(githubApiUrl, githubToken, RequestType.Delete, 3, "Failed to delete runner");

Copilot uses AI. Check for mistakes.

private async Task<DistributedTask.WebApi.Runner> DeleteRunnerAsync(string githubUrl, string githubToken, ulong runnerId)
{
var githubApiUrl = $"{GetEntityUrl(githubUrl)}/runners/{runnerId}";
return await RetryRequest<DistributedTask.WebApi.Runner>(githubApiUrl, githubToken, RequestType.Delete, 3, "Failed to add agent");
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Delete operations typically don't return the deleted entity. Consider changing the return type to Task or Task to indicate success/failure instead of returning the Runner object.

Suggested change
return await RetryRequest<DistributedTask.WebApi.Runner>(githubApiUrl, githubToken, RequestType.Delete, 3, "Failed to add agent");
private async Task<bool> DeleteRunnerAsync(string githubUrl, string githubToken, ulong runnerId)
{
var githubApiUrl = $"{GetEntityUrl(githubUrl)}/runners/{runnerId}";
try
{
await RetryRequest<object>(githubApiUrl, githubToken, RequestType.Delete, 3, "Failed to delete runner");
return true;
}
catch
{
return false;
}

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant