Skip to content

Implement exponential backoff with jitter for retry logic in TeamsUtility methods #4896

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

Merged
merged 2 commits into from
May 5, 2025

Conversation

gautamdsheth
Copy link
Collaborator

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

Fixes #4757

What is in this Pull Request ?

Improve retry mechanism for teams provisioning

@gautamdsheth gautamdsheth requested a review from Copilot May 5, 2025 12:34
Copy link

@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 pull request improves the retry mechanism for team provisioning by implementing exponential backoff with jitter in the TeamsUtility methods.

  • Added exponential backoff logic with configurable retry limits and initial backoff durations.
  • Incorporated random jitter into delay calculations to reduce retry collisions.

// Initial backoff time in seconds
const int initialBackoffSeconds = 5;

while (wait && iterations < maxRetries)
Copy link
Preview

Copilot AI May 5, 2025

Choose a reason for hiding this comment

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

[nitpick] The two retry loops use different maxRetries values (12 in the first block, 10 in the second). Verify whether this difference is intended or if a consistent retry limit should be applied.

Copilot uses AI. Check for mistakes.

@gautamdsheth gautamdsheth requested a review from Copilot May 5, 2025 12:43
@gautamdsheth gautamdsheth merged commit a30c9fe into pnp:dev May 5, 2025
3 checks passed
Copy link

@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 improves the retry mechanism for Teams provisioning by implementing exponential backoff with jitter in two retry loops.

  • Implements exponential backoff with configurable initial delay and maximum retries for group creation.
  • Introduces a new retry loop with backoff and jitter for updating team settings.
Comments suppressed due to low confidence (1)

src/Commands/Utilities/TeamsUtility.cs:165

  • [nitpick] Consider using a consistent naming convention for the retry iteration variable across both retry loops (e.g., using 'retryCount' instead of 'iterations') to improve code clarity.
while (wait && iterations < maxRetries)

Comment on lines +227 to 228
catch
{
Copy link
Preview

Copilot AI May 5, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider explicitly catching Exception (e.g., 'catch (Exception ex)') to enhance clarity and facilitate debugging or logging in the future.

Suggested change
catch
{
catch (Exception ex)
{
// Log the exception details for debugging
Console.WriteLine($"Exception occurred: {ex.Message}");
Console.WriteLine($"Stack Trace: {ex.StackTrace}");

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.

[BUG] New-PnPTeamsTeam sporadically returns "Not Found (404): No Team found with Group id"
1 participant