-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Add support to enable backoff when rate limited by the Github API #6644
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
Changes from all commits
6c2bc2a
dbf4583
6f37932
f5fc28a
b25f1fe
70ae11e
2210309
c61bdf1
12e1779
0872d8c
ea0fff7
1cf0105
22112c2
32b33e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -792,6 +792,41 @@ func TestNewGitHubRunnerScaler_QueueLength_MultiRepo_PulledRepos_NoRate(t *testi | |
| } | ||
| } | ||
|
|
||
| func TestNewGitHubRunnerScaler_QueueLength_SingleRepo_WithRateLimitBackoff(t *testing.T) { | ||
| // First call will set previous queue length | ||
| apiStub := apiStubHandler(true, false) | ||
| meta := getGitHubTestMetaData(apiStub.URL) | ||
| meta.EnableBackoff = true | ||
|
|
||
| scaler := githubRunnerScaler{ | ||
| metadata: meta, | ||
| httpClient: http.DefaultClient, | ||
| } | ||
| scaler.metadata.Repos = []string{"test"} | ||
| scaler.metadata.Labels = []string{"foo", "bar"} | ||
|
|
||
| if queueLen, err := scaler.GetWorkflowQueueLength(context.Background()); err != nil { | ||
| fmt.Println(err) | ||
| t.Fail() | ||
| } else if queueLen != 1 { | ||
| fmt.Printf("Expected queue length of 1 got %d\n", queueLen) | ||
| t.Fail() | ||
| } | ||
|
Comment on lines
+808
to
+814
|
||
|
|
||
| // Second call simulating that there is a rate limit | ||
| // should return previous queue length | ||
| scaler.rateLimit.Remaining = 0 | ||
| scaler.rateLimit.ResetTime = time.Now().Add(5 * time.Minute) | ||
|
|
||
| if queueLen, err := scaler.GetWorkflowQueueLength(context.Background()); err != nil { | ||
| fmt.Println(err) | ||
| t.Fail() | ||
| } else if queueLen != 1 { | ||
| fmt.Printf("Expected queue length of 1 after rate limit backoff got %d\n", queueLen) | ||
| t.Fail() | ||
| } | ||
|
Comment on lines
+821
to
+827
|
||
| } | ||
|
|
||
| type githubRunnerMetricIdentifier struct { | ||
| metadataTestData *map[string]string | ||
| triggerIndex int | ||
|
|
||
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.
Error handling is ignored when parsing rate limit headers. If these headers contain invalid values, the rate limit logic could behave unexpectedly. Consider handling parsing errors or adding validation.