-
Notifications
You must be signed in to change notification settings - Fork 887
Handle TimeoutException During Agent Replacement in agent configuration #5210
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
Handle TimeoutException During Agent Replacement in agent configuration #5210
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the changes as suggested
Update the PR description. Select a risk assessment - Low/Medium/High |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Azure Pipelines successfully started running 1 pipeline(s). |
Updated risk section with reason |
…ithub.com/microsoft/azure-pipelines-agent into users/rishabhalikMS/agentConfigTimeoutFix
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rishabhmalikMS
these changes looks good, could you please add when this is used with VMSS script these exceptions are handled properly
Tested with script as well for unattended configuration Here is the sample diagnostic logs generated with error information |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this 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 enhances the agent replacement process by adding retry logic for TimeoutException and related cancellations, ensuring failures are handled gracefully in both attended and unattended modes.
- Added a localized retry message for agent replacement attempts.
- Introduced
UpdateAgentWithRetryAsync
with exponential backoff and retry limits. - Refactored agent update calls in both configure and re-auth flows to use the new retry wrapper.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/Misc/layoutbin/en-US/strings.json | Added a new "RetryingReplaceAgent" string for retry attempts notification. |
src/Agent.Listener/Configuration/ConfigurationManager.cs | Added retry helper, constants, and updated update calls to handle timeouts. |
Comments suppressed due to low confidence (1)
src/Agent.Listener/Configuration/ConfigurationManager.cs:49
- [nitpick] Private constants typically use PascalCase (e.g.,
MaxRetries
) or ans_
prefix according to C# naming conventions; consider renaming_maxRetries
accordingly.
private const int _maxRetries = 3;
these logs are going into Agent log, this will not fail the original script |
Context
This PR addresses an issue where TimeoutException thrown during agent replacement was not being caught in unattended mode, causing unhandled exceptions and unclear error reporting. The change ensures that timeouts are always handled gracefully, regardless of the configuration mode.
ICM: https://portal.microsofticm.com/imp/v5/incidents/details/614374419/summary
Work Item
AB#2277929
Description
Updated the exception handling logic in ConfigurationManager to always catch timeout exception during agent replacement, even in unattended mode.
Risk Assessment (Low / Medium / High)
Low
Reason: Adding retrying mechanism for agent update call in unattended agent config process. This does not harm the current process, code update is to make unattended agent configuration more resilient.
Unit Tests Added or Updated (Yes / No)
No new unit tests were added. The change is in error handling and user messaging.
Additional Testing Performed
Manual testing done by configuring agent with delayed call to updateAgent