Skip to content

internal: move the user-agent engine tag to the callers of PullResourcesState - #6808

Merged
denik merged 2 commits into
mainfrom
denik/ua-tag-process
Sep 23, 2026
Merged

denik merged 2 commits into
mainfrom
denik/ua-tag-process

Conversation

@denik

@denik denik commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Changes

The user-agent engine dimension used to be set inside PullResourcesState. Move it to the callers (bundle deploy/plan in process.go and the two bundle generate resource paths), so the engine tag lives next to where the resolved engine is known.

Follow-on cleanups from that move:

  • PullResourcesState no longer mutates the context, so it now returns only *StateDesc instead of (context.Context, *StateDesc).
  • generate dashboard and generate genie-space had byte-identical state-loading blocks (initialize, resolve engine, pull state, tag engine, load). Extracted into one loadStateForGenerate helper so the tag is set in a single place.

Why

Prep for #6749 (move terraform→direct state migration before deploy): that PR needs the engine tag set from the resolved (post-migration) engine, so consolidating the tagging off main keeps its diff focused on the behavior change.

Tests

Behavior-preserving. acceptance/bundle/user_agent asserts the engine/ tag on every recorded request for both engines; it plus the generate and state suites and the generate unit tests pass with no golden changes.

This pull request and its description were written by Isaac.

…rcesState

Move the `useragent.InContext(ctx, "engine", ...)` call out of
`PullResourcesState` and into each of its three callers — `process.go`,
`dashboard.go`, and `genie_space.go` — where it now runs immediately after
the function returns and its error check passes.

The placement is behavior-preserving: `PullResourcesState` makes no outgoing
API calls after setting the tag (only a local `atomicfile.Write`), so the same
requests that carried the engine dimension before still carry it, and the same
early requests that predate state resolution still lack it.  The
`acceptance/bundle/user_agent` suite confirms this: all goldens are unchanged.

`PullResourcesState` was the wrong home for this concern — it is a
state-reading helper, not the right place to decide what tags future API calls
should carry.  The callers own the context lifecycle and are the natural place
to annotate it.

No new acceptance tests are added for the generate commands: both
`dashboard --resource` and `genie-space --resource` require a previously
deployed state to record meaningful requests, which demands heavy cloud
setup and is out of scope for a local-only regression test.  Deploy UA
coverage already exists in `acceptance/bundle/user_agent/simple`.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik requested review from a team as code owners September 23, 2026 09:37
@github-actions github-actions Bot added the DABs DABs related issues label Sep 23, 2026
…rom PullResourcesState

PullResourcesState no longer mutates the context (the engine user-agent tag moved to its callers), so it returns only *StateDesc now.
The dashboard and genie-space generate commands had byte-identical state-loading blocks; extract them into one helper so the engine tag is set in a single place.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik denik changed the title internal: set the user-agent engine tag in the callers, not PullResourcesState internal: move the user-agent engine tag to the callers of PullResourcesState Sep 23, 2026
@denik
denik enabled auto-merge September 23, 2026 10:09
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 097f400

Run: 35845617661

Env ✅​pass 🙈​skip Time
✅​ aws linux 276 15 6:02
✅​ aws windows 278 13 5:07
✅​ azure linux 275 15 6:30
✅​ azure windows 277 13 5:29
✅​ gcp linux 276 15 5:45
✅​ gcp windows 278 13 5:23
Top 3 slowest tests (at least 2 minutes):
duration env testname
5:25 azure windows TestAccept
4:09 aws windows TestAccept
3:31 gcp windows TestAccept

@denik
denik added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit a137b89 Sep 23, 2026
30 checks passed
@denik
denik deleted the denik/ua-tag-process branch September 23, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants