Skip to content
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

CUT-3858: Retry API Call Function #70

Merged
merged 18 commits into from
Feb 27, 2024
Merged

Conversation

gweinjc
Copy link
Contributor

@gweinjc gweinjc commented Feb 26, 2024

Issues

What does this solve?

This fix attempts to alleviate the issue of unexpected 503 errors when making SDK calls in larger scripts which results in errors or incomplete datasets being returned. We have added a do-while loop with a counter to the API call function that will detect if a 503 error is present, wait a period of time and then re-attempt the call until either the call is successful or the max counter is reached.

Is there anything particularly tricky?

503 errors are inherently unreliable and difficult to test for. We can manually test this by replacing the lookup for a 503 error with a more replicable error, such as 400 (Bad Request).

How should this be tested?

  1. Find a SDK function that is suitable for testing, ex: Get-JCSdkUserAssociation
  2. Within the process block, look for the line that contains If ($JCHttpResponse.Result.StatusCode -eq 503) and replace the 503 with 400.
  3. Import the local SDK .psd1
    • Import-Module '/Users/USER/Documents/GitHub/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.V2/JumpCloud.SDK.V2.psd1' -force
  4. Provide the function an incomplete entry to force a 400 error
    • ex: Get-JCSdkUserAssociation -UserID '6120152163f8976f332dafc' -target active_directory
    • The UserID is not the correct length, therefore will always fail

@gweinjc gweinjc requested a review from a team as a code owner February 26, 2024 16:49
@gweinjc gweinjc added SDK SDK Release Label patch Patch SDK Release Version labels Feb 26, 2024
kmaranionjc
kmaranionjc previously approved these changes Feb 27, 2024
Copy link
Contributor

@kmaranionjc kmaranionjc left a comment

Choose a reason for hiding this comment

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

Retry functionality test worked, code looks good. Great work

@gweinjc gweinjc merged commit 78b1366 into master Feb 27, 2024
12 checks passed
@gweinjc gweinjc deleted the CUT-3858_RetryAPICallFunction branch February 27, 2024 22:13
@gweinjc gweinjc temporarily deployed to PublishToPSGallery February 27, 2024 22:14 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Patch SDK Release Version SDK SDK Release Label
Development

Successfully merging this pull request may close these issues.

3 participants