mirror of
https://github.com/actions/runner.git
synced 2025-12-11 12:57:05 +00:00
better error when runner removed from service. (#441)
This commit is contained in:
@@ -150,6 +150,20 @@ namespace GitHub.Runner.Listener
|
|||||||
Trace.Error("Catch exception during create session.");
|
Trace.Error("Catch exception during create session.");
|
||||||
Trace.Error(ex);
|
Trace.Error(ex);
|
||||||
|
|
||||||
|
if (ex is VssOAuthTokenRequestException && creds.Federated is VssOAuthCredential vssOAuthCred)
|
||||||
|
{
|
||||||
|
// Check whether we get 401 because the runner registration already removed by the service.
|
||||||
|
// If the runner registration get deleted, we can't exchange oauth token.
|
||||||
|
Trace.Error("Test oauth app registration.");
|
||||||
|
var oauthTokenProvider = new VssOAuthTokenProvider(vssOAuthCred, new Uri(serverUrl));
|
||||||
|
var authError = await oauthTokenProvider.ValidateCredentialAsync(token);
|
||||||
|
if (string.Equals(authError, "invalid_client", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_term.WriteError("Failed to create a session. The runner registration has been deleted from the server, please re-configure.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsSessionCreationExceptionRetriable(ex))
|
if (!IsSessionCreationExceptionRetriable(ex))
|
||||||
{
|
{
|
||||||
if (_useMigratedCredentials)
|
if (_useMigratedCredentials)
|
||||||
|
|||||||
@@ -119,6 +119,15 @@ namespace GitHub.Services.OAuth
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<string> ValidateCredentialAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var tokenHttpClient = new VssOAuthTokenHttpClient(this.SignInUrl);
|
||||||
|
var tokenResponse = await tokenHttpClient.GetTokenAsync(this.Grant, this.ClientCredential, this.TokenParameters, cancellationToken);
|
||||||
|
|
||||||
|
// return the underlying authentication error
|
||||||
|
return tokenResponse.Error;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Issues a token request to the configured secure token service. On success, the access token issued by the
|
/// Issues a token request to the configured secure token service. On success, the access token issued by the
|
||||||
/// token service is returned to the caller
|
/// token service is returned to the caller
|
||||||
|
|||||||
Reference in New Issue
Block a user