Skip to content

Include account_id job variable in generated pod name#310

Draft
wesleyjellis wants to merge 2 commits into
mainfrom
wesley/pod-name-account-id
Draft

Include account_id job variable in generated pod name#310
wesleyjellis wants to merge 2 commits into
mainfrom
wesley/pod-name-account-id

Conversation

@wesleyjellis

Copy link
Copy Markdown

Summary

  • Adds a getVariable helper to look up a job variable by key from job.Variables
  • Weaves an account_id job variable (if present) into the generated pod/ConfigMap/PDB identifier, so it's easier to tell which OpsLevel account a running job pod belongs to: opslevel-job-<account_id>-<job_id>-<timestamp>
  • Falls back to the existing opslevel-job-<job_id>-<timestamp> format when no account_id variable is set

Test plan

  • go build ./...
  • Added TestGetVariable_ReturnsMatchingValue / TestGetVariable_ReturnsEmptyWhenMissing covering the new helper
  • go test ./pkg passes

🤖 Generated with Claude Code

Jobs that set an account_id variable now get it woven into the
generated k8s object name (opslevel-job-<account_id>-<job_id>-<ts>),
making it easier to identify which account a running job belongs to.
Falls back to the existing naming scheme when account_id is absent.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@wesleyjellis wesleyjellis self-assigned this Jul 7, 2026
Comment thread src/pkg/k8s.go Outdated
}

// getVariable returns the value of the job variable with the given key, if present.
func getVariable(configs []opslevel.RunnerJobVariable, key string) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a need for similar helper for the egress proxies. I don't mean to nitpick but it would be nice to make the name more explicit_

Suggested change
func getVariable(configs []opslevel.RunnerJobVariable, key string) string {
func getRunnerJobVariable(configs []opslevel.RunnerJobVariable, key string) string {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Renamed to getRunnerJobVariable in a0cfb48.

Comment thread src/pkg/k8s.go
// Once we get off "the old API" method of runner we can circle back around to this
// and fix it to generate safe pod names since k8s has limitations.
var identifier string
var jobIdentifier string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand the addition of this jobIdentifier 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the diff makes it look weirder than it is. This block now just gets the job identifier, then line 373 constructs identifier with account id if present

Addresses review feedback: a similar helper will be needed for egress
proxies, so the name should be more explicit about what it operates on.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants