Be consistent about choice of TTLCache keys in Director stat utilities#3171
Open
jhiemstrawisc wants to merge 2 commits intoPelicanPlatform:mainfrom
Open
Be consistent about choice of TTLCache keys in Director stat utilities#3171jhiemstrawisc wants to merge 2 commits intoPelicanPlatform:mainfrom
jhiemstrawisc wants to merge 2 commits intoPelicanPlatform:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How did I discover this subtle issue? I asked Claude "Please explain the stat utility's TTLCache model as though it were being whiteboarded out amongst colleagues" and its response was "I confirmed your bug!" and then spat out this issue.
The bug is that we use a different values for keys to instantiate TTLCache entries than we do to access the values we've stored. Compare how we (previously) set these TTLCache keys with where we use the keys for lookups:
pelican/director/sort_algorithms.go
Line 292 in 135bafc
Not at all what I asked the AI to do, but helpful none the less.
P.S. I'll note that I don't love the unit tests here --> they're narrow in scope and don't actually test that multiple pieces of code are correctly strung together (they merely assert we're using a specific key in the TTLCache). However, they're better than nothing and I wanted to have something since we're hoping to test this stat future in the coming week. As @patrickbrophy noted, this bug is actually a solid argument for a strong type system in this area of code, but I'm okay with the quick-and-dirty fix for now.
If you'd like check that these tests would have failed with the previous bug, I recommend: