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

Fix: "all_teams" data resource causes 429 status code requests #988

Merged
merged 4 commits into from
Dec 8, 2024

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

fixes #987

Solution

Added memorization to the get teams call.
This caches results between terraform executions.

The downside is that the results will be stale during the execution.

@TomerHeber
Copy link
Collaborator Author

/review

@bot-env0 bot-env0 requested a review from a team December 8, 2024 12:48
@@ -309,7 +308,7 @@ func TestConfigurationVariableMarshelling(t *testing.T) {

b, err := json.Marshal(&variable)
if assert.NoError(t, err) {
assert.False(t, strings.Contains(string(b), str))
assert.NotContains(t, string(b), str)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

linter complaints...

@@ -0,0 +1,22 @@
package client
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

generic memoization function.

@@ -11,6 +11,7 @@ import (
func dataTeams() *schema.Resource {
return &schema.Resource{
ReadContext: dataTeamsRead,
Description: "Note: this data source is cached, once fetched it will not be updated until the next plan/apply",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added this note so users understand limitations.

Copy link
Contributor

@sagilaufer1992 sagilaufer1992 left a comment

Choose a reason for hiding this comment

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

some tests are in order I believe. the implementation looks great, but let's make sure stuff are tested properly

@TomerHeber
Copy link
Collaborator Author

some tests are in order I believe. the implementation looks great, but let's make sure stuff are tested properly

@sagilaufer1992

It's already covered by some tests (acceptance and harness).
Any specific use cases you had in mind?

@sagilaufer1992
Copy link
Contributor

some tests are in order I believe. the implementation looks great, but let's make sure stuff are tested properly

@sagilaufer1992

It's already covered by some tests (acceptance and harness). Any specific use cases you had in mind?

@TomerHeber I'd like the memoization to be tested at least. to see it doesn't invoke the same call twice for the same parameters, does call for different parameters

@TomerHeber
Copy link
Collaborator Author

Got it. Makes sense.

@TomerHeber
Copy link
Collaborator Author

@sagilaufer1992 - added the unit tests for memoization.

Copy link
Contributor

@sagilaufer1992 sagilaufer1992 left a comment

Choose a reason for hiding this comment

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

LGTM, my comments were addressed

@github-actions github-actions bot added the ready to merge PR approved - can be merged once the PR owner is ready label Dec 8, 2024
@TomerHeber TomerHeber merged commit b871818 into main Dec 8, 2024
5 checks passed
@TomerHeber TomerHeber deleted the fix-all-team-429-#987 branch December 8, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-client fix provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"all_teams" data resource causes 429 status code requests
2 participants