Skip to content

Create a shared utility for generating hash of a sandbox's TemplateRef name#763

Merged
k8s-ci-robot merged 5 commits into
kubernetes-sigs:mainfrom
lauragalbraith:sandbox-hash
May 14, 2026
Merged

Create a shared utility for generating hash of a sandbox's TemplateRef name#763
k8s-ci-robot merged 5 commits into
kubernetes-sigs:mainfrom
lauragalbraith:sandbox-hash

Conversation

@lauragalbraith

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Create a shared utility for generating hash of a sandbox's TemplateRef name

The code was modified with the help of https://antigravity.google/.

The next step will be creating a new utility which uses the namespace in addition to name

Which issue(s) this PR is related to:

This is part of the fix for issue #703.

Release Note

NONE

…name

This is part of the fix for issue kubernetes-sigs#703.
The next step will be creating a new utility which uses the namespace in addition to name
…name

This is part of the fix for issue kubernetes-sigs#703.
The next step will be creating a new utility which uses the namespace in addition to name
@netlify

netlify Bot commented May 8, 2026

Copy link
Copy Markdown

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 96af0fa
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/6a062aa6b6205a0008b2006a
@k8s-ci-robot k8s-ci-robot requested review from barney-s and justinsb May 8, 2026 20:24
@linux-foundation-easycla

linux-foundation-easycla Bot commented May 8, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @lauragalbraith!

It looks like this is your first PR to kubernetes-sigs/agent-sandbox 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/agent-sandbox has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @lauragalbraith. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 8, 2026
@lauragalbraith

Copy link
Copy Markdown
Contributor Author

/check-cla

1 similar comment
@lauragalbraith

Copy link
Copy Markdown
Contributor Author

/check-cla

@vicentefb

Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 13, 2026
"sigs.k8s.io/controller-runtime/pkg/log"

sandboxcontrollers "sigs.k8s.io/agent-sandbox/controllers"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

gofmt changed the content here - let me know if there's any more specific action desired here!

Comment thread extensions/controllers/utils.go
Comment thread extensions/controllers/utils.go Outdated
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors hash generation for sandbox template references into a shared utility in extensions/controllers, replacing direct calls to sandboxcontrollers.NameHash(template.Name) across the extension controllers. This is preparatory work toward issue #703, which will introduce a namespace-aware hash to avoid cross-namespace collisions in the warm-pool/claim queues.

Changes:

  • Adds SandboxTemplateRefHash and HashUsingSandboxTemplateRefName helpers in extensions/controllers/utils.go, with a TODO to deprecate the latter once #703 is fixed.
  • Replaces all in-package call sites (sandboxclaim, sandboxtemplate, sandboxwarmpool controllers) with the new helper.
  • Adds a unit test asserting hash length, determinism, and distinctness across inputs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
extensions/controllers/utils.go Introduces shared SandboxTemplateRefHash and legacy HashUsingSandboxTemplateRefName helpers.
extensions/controllers/utils_test.go New unit test covering determinism, length, and uniqueness of the hash.
extensions/controllers/sandboxclaim_controller.go Routes all template-name hashing through the new helper.
extensions/controllers/sandboxtemplate_controller.go Same refactor; drops now-unused sandboxcontrollers import.
extensions/controllers/sandboxwarmpool_controller.go Replaces direct NameHash calls in label construction and stale-check with the helper.
Comment thread extensions/controllers/utils_test.go
Comment thread extensions/controllers/utils_test.go Outdated
}

// Check that different inputs produce different hashes
if results["simple template ref name"] == results["a different template ref name"] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would it be better to iterate over all unique pairs in results to ensure there are no collisions among any of the different test inputs?

Comment thread extensions/controllers/sandboxclaim_controller.go
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 14, 2026

@vicentefb vicentefb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 14, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lauragalbraith, vicentefb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2026
@k8s-ci-robot k8s-ci-robot merged commit 4fffef6 into kubernetes-sigs:main May 14, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Agent Sandbox May 14, 2026
@lauragalbraith lauragalbraith deleted the sandbox-hash branch May 14, 2026 20:58
khirotaka pushed a commit to khirotaka/agent-sandbox that referenced this pull request Jun 12, 2026
…f name (kubernetes-sigs#763)

* Create shared utility for generating hash of a sandbox's TemplateRef name

This is part of the fix for issue kubernetes-sigs#703.
The next step will be creating a new utility which uses the namespace in addition to name

* Create shared utility for generating hash of a sandbox's TemplateRef name

This is part of the fix for issue kubernetes-sigs#703.
The next step will be creating a new utility which uses the namespace in addition to name

* gofmt and fix typo

* add extensions/controllers/utils_test.go

* test results more robustly
alexatakvelon pushed a commit to volatilemolotov/agent-sandbox that referenced this pull request Jun 24, 2026
…f name (kubernetes-sigs#763)

* Create shared utility for generating hash of a sandbox's TemplateRef name

This is part of the fix for issue kubernetes-sigs#703.
The next step will be creating a new utility which uses the namespace in addition to name

* Create shared utility for generating hash of a sandbox's TemplateRef name

This is part of the fix for issue kubernetes-sigs#703.
The next step will be creating a new utility which uses the namespace in addition to name

* gofmt and fix typo

* add extensions/controllers/utils_test.go

* test results more robustly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. ready-for-review size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

5 participants