GeezerVison is showing github.com — fix/batch-changes: ignore per-job env vars in cache key by taras-yemets · Pull Request #1326 · sourcegraph/src-cli
Conversation
With sourcegraph/sourcegraph#12503, Sourcegraph desugars v3 codingAgent steps server-side and declares per-job env-var forwards on step.Env. Their resolved values change every dequeue, so including them in cache-key inputs would invalidate the cache on every run.
Strip them before hashing:
SRC_EXECUTOR_JOB_TOKEN — per-job bearer token
SRC_EXECUTOR_JOB_ID — numeric job ID
SRC_EXECUTOR_NAME — dequeueing executor's hostname
The bare-string declarations still influence the key via the serialized step.Env, so spec-change invalidation still works. The list is mirrored in sourcegraph/sourcegraph; a comment on each side points at the other.
End-to-end test plan: see sourcegraph/sourcegraph#12503.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The two SRC_BATCHES_* env vars declared by codingAgent steps
(see sourcegraph/sourcegraph#12503) resolve to different values on
every dequeue. Strip them from cache-key inputs so the key stays
stable across runs.
…p SRC_EXECUTOR_NAME
The per-job env vars declared by codingAgent steps were renamed in
sourcegraph/sourcegraph#12503 (review feedback) from SRC_BATCHES_* to
SRC_EXECUTOR_*, and a third var SRC_EXECUTOR_NAME was added so the
in-sandbox coding-agent CLI can pass X-Sourcegraph-Executor-Name to
the model-provider proxy (lets the server reuse jobAuthMiddleware
instead of a bespoke auth path).
Mirror those changes in src-cli's cache-key stripping list so cached
runs aren't invalidated by the per-dequeue token/ID/executor-name
values that get injected onto step.Env.
One of the three stripped env vars (SRC_EXECUTOR_NAME) is per-executor,
not per-job, so the perJob name is technically wrong. Renaming to
perRunEnvVars accurately captures that all three change on every
dequeue (job-token + job-ID per job, executor-name per executor).
Comment on lines
+50
to
+53
|
|
// perRunEnvVars resolve to per-job or per-executor values that change on
|
|
|
// every dequeue and must be stripped from cache keys. Mirrored in
|
|
|
// sourcegraph/sourcegraph/lib/batches/execution/cache/cache.go.
|
|
|
var perRunEnvVars = []string{
|
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
taras-yemets reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@taras-yemets how do we pull this into the src-cli version used by executor? Do we need a release?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
@taras-yemets how do we pull this into the src-cli version used by executor? Do we need a release?
I think we need a release first, then set the minimum expected src-cli version in the Sourcegraph repo.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.