-
Notifications
You must be signed in to change notification settings - Fork 25
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 schedulers not getting executed when cache key is not set #3121
Conversation
WalkthroughThe changes involve a tweak in the caching mechanism for a Changes
Poem
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- pkg/policies/flowcontrol/cache.go (2 hunks)
- playground/Tiltfile (2 hunks)
Additional comments: 5
pkg/policies/flowcontrol/cache.go (2)
- 223-227: Initialization of
resultCacheResponse
has been changed to occur within the function body instead of at the point of declaration. This change could potentially affect the logic of howresultCacheResponse
is handled, especially in cases whererequest
isnil
. Ensure that this change is intentional and tested, particularly for thenil
request scenario.Verification successful
I will attempt a different approach to verify the behavior of the
LookupResultNoWait
method whenrequest
isnil
by adjusting the ast-grep pattern.
I will now use ripgrep (rg) to search for the
LookupResultNoWait
method directly in the codebase to understand its behavior whenrequest
isnil
.
I will now display the contents of the
LookupResultNoWait
method to verify its behavior whenrequest
isnil
.
The contents of the
LookupResultNoWait
method in theCache
struct show that whenrequest
isnil
, the method returnsresultCacheResponse
asnil
and a reference towgResult
. The change in the initialization ofresultCacheResponse
within the function body does not affect the behavior whenrequest
isnil
, as it still returns anil
pointer forresultCacheResponse
.Based on the provided code snippet, the behavior when
request
isnil
appears to be correctly handled and consistent with the expected logic.* 233-236: The `resultCacheResponse` is now being initialized inside an `if` block that checks if `request.ResultCacheKey` is not empty. This change seems to be a part of the bug fix to ensure that `resultCacheResponse` is only initialized when there is a valid cache key. This is a logical change that should prevent the creation of unnecessary objects and potentially resolve the issue with schedulers not executing when the cache key is not set.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the change in initialization does not affect the behavior when request is nil. ast-grep --lang go --pattern $'func (c *Cache) LookupResultNoWait($_, $_) ($_ *flowcontrolv1.KeyLookupResponse, $_ *sync.WaitGroup) { $$$ if $_ == nil { $$$ } $$$ }'Length of output: 178
Script:
#!/bin/bash # Attempting a broader pattern match for the LookupResultNoWait method to ensure we capture the relevant code. ast-grep --lang go --pattern $'func (c *Cache) LookupResultNoWait($$$) { $$$ if $_ == nil { $$$ } $$$ }'Length of output: 117
Script:
#!/bin/bash # Using ripgrep to find the LookupResultNoWait method in the Cache struct. rg "func \(c \*Cache\) LookupResultNoWait"Length of output: 231
Script:
#!/bin/bash # Displaying the contents of the LookupResultNoWait method to understand its behavior when request is nil. cat pkg/policies/flowcontrol/cache.go | sed -n '/func (c \*Cache) LookupResultNoWait/,/}/p'Length of output: 422
playground/Tiltfile (3)
- 1308-1320: The renaming of
personal_api_key
topersonal_access_token
is consistent with the PR objectives. Ensure that all references to the old variable name are updated across the entire codebase to maintain consistency.Verification successful
The search results indicate that the variable
personal_api_key
does not appear in the codebase, whilepersonal_access_token
is used in several places withinplayground/Tiltfile
. This suggests that the renaming has been applied consistently in theTiltfile
.
- No instances of
personal_api_key
were found, indicating the old variable name has been removed.- Multiple instances of
personal_access_token
were found, confirming the new variable name is in use.Based on the provided context and the search results, the review comment is consistent with the changes in the codebase.
* 1317-1320: The conditional logic for setting `personal_access_token` only when `cloud_controller` is true aligns with the intended functionality.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the old variable name is no longer used. rg --type starlark 'personal_api_key' # Verify that the new variable name is used consistently. rg --type starlark 'personal_access_token'Length of output: 146
Script:
#!/bin/bash # Search for occurrences of 'personal_api_key' without specifying file type. rg 'personal_api_key' # Search for occurrences of 'personal_access_token' without specifying file type. rg 'personal_access_token'Length of output: 469
- 1332-1339: The logic for populating the
cloud_extension
dictionary withpersonal_access_token
andproject_name
only when they are set is correct and follows best practices for optional configuration.
Checklist
Summary by CodeRabbit
Refactor
Style