Skip to content

fix: align hash calculation between SandboxSet and Sandbox controllers#124

Open
ongdisheng wants to merge 3 commits intoopenkruise:masterfrom
ongdisheng:issue-37
Open

fix: align hash calculation between SandboxSet and Sandbox controllers#124
ongdisheng wants to merge 3 commits intoopenkruise:masterfrom
ongdisheng:issue-37

Conversation

@ongdisheng
Copy link
Contributor

Ⅰ. Describe what this PR does

This PR fixes the hash calculation inconsistency between SandboxSet and Sandbox controllers by aligning both to use the same HashSandbox() method. Previously, SandboxSet used HashControllerRevision() method while Sandbox used HashSandbox(), causing different revision hashes for identical templates.

Ⅱ. Does this pull request fix one issue?

Fixes #37

Ⅲ. Describe how to verify it

Run the unit tests to verify:

go test ./pkg/controller/sandboxset -v
image

Ⅳ. Special notes for reviews

I have also manually verify by deploying a SandboxSet and verify that both the SandboxSet and its created Sandboxes produce identical revision hashes for the same template.

Before fix
disheng@LAPTOP-UPFH5KC9:/mnt/c/Users/disheng/Desktop/OSS/agents$ kubectl get sandbox test-hash-xts8l -o yaml
apiVersion: agents.kruise.io/v1alpha1
kind: Sandbox
metadata:
  annotations:
    sandbox.agents.kruise.io/hash-without-image-resources: 6z46wcfw8
  creationTimestamp: "2026-01-31T18:06:24Z"
  finalizers:
  - agents.kruise.io/sandbox
  generateName: test-hash-
  generation: 1
  labels:
    agents.kruise.io/sandbox-claimed: "false"
    agents.kruise.io/sandbox-pool: test-hash
    agents.kruise.io/template-hash: 7b677d6cb7
  name: test-hash-xts8l
  namespace: default
  ownerReferences:
  - apiVersion: agents.kruise.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: SandboxSet
    name: test-hash
    uid: 2b375cfc-1d64-4712-88db-e24cb46a51bb
  resourceVersion: "25293"
  uid: 6c6a3dbc-5288-41d9-8798-f01d48f0b358
spec:
  template:
    metadata:
      creationTimestamp: null
    spec:
      automountServiceAccountToken: false
      containers:
      - image: nginx:1.19
        imagePullPolicy: IfNotPresent
        name: sandbox
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  conditions:
  - lastTransitionTime: "2026-01-31T18:06:39Z"
    message: ""
    reason: PodReady
    status: "True"
    type: Ready
  - lastTransitionTime: "2026-01-31T18:06:39Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: InplaceUpdate
  nodeName: agents-dev-control-plane
  observedGeneration: 1
  phase: Running
  podInfo:
    nodeName: agents-dev-control-plane
    podIP: 10.244.0.9
    podUID: 05fe9e06-9426-4c1a-b75b-8f3e0cbaf849
  sandboxIp: 10.244.0.9
  updateRevision: 2zd247bx4
After fix
disheng@LAPTOP-UPFH5KC9:/mnt/c/Users/disheng/Desktop/OSS/agents$ kubectl get sandbox test-hash-m5qc8 -o yaml
apiVersion: agents.kruise.io/v1alpha1
kind: Sandbox
metadata:
  annotations:
    sandbox.agents.kruise.io/hash-without-image-resources: 6z46wcfw8
  creationTimestamp: "2026-01-31T18:30:00Z"
  finalizers:
  - agents.kruise.io/sandbox
  generateName: test-hash-
  generation: 1
  labels:
    agents.kruise.io/sandbox-claimed: "false"
    agents.kruise.io/sandbox-pool: test-hash
    agents.kruise.io/template-hash: 2zd247bx4
  name: test-hash-m5qc8
  namespace: default
  ownerReferences:
  - apiVersion: agents.kruise.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: SandboxSet
    name: test-hash
    uid: 499b54f1-2f18-492d-be9e-eef8257d217f
  resourceVersion: "27723"
  uid: e67821f0-0160-40f7-833a-de887a26e9e5
spec:
  template:
    metadata:
      creationTimestamp: null
    spec:
      automountServiceAccountToken: false
      containers:
      - image: nginx:1.19
        imagePullPolicy: IfNotPresent
        name: sandbox
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  conditions:
  - lastTransitionTime: "2026-01-31T18:30:01Z"
    message: ""
    reason: PodReady
    status: "True"
    type: Ready
  - lastTransitionTime: "2026-01-31T18:30:01Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: InplaceUpdate
  nodeName: agents-dev-control-plane
  observedGeneration: 1
  phase: Running
  podInfo:
    nodeName: agents-dev-control-plane
    podIP: 10.244.0.11
    podUID: 7fd2b31f-4851-4aa1-893a-a54a1adf965c
  sandboxIp: 10.244.0.11
  updateRevision: 2zd247bx4

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found 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

@kruise-bot
Copy link

Welcome @ongdisheng! It looks like this is your first PR to openkruise/agents 🎉

@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.09%. Comparing base (dbe13c8) to head (2c34f27).
⚠️ Report is 57 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
- Coverage   52.26%   52.09%   -0.18%     
==========================================
  Files          91       90       -1     
  Lines        5221     5158      -63     
==========================================
- Hits         2729     2687      -42     
+ Misses       2268     2256      -12     
+ Partials      224      215       -9     
Flag Coverage Δ
unittests 52.09% <100.00%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ongdisheng ongdisheng marked this pull request as draft January 31, 2026 23:46
@ongdisheng ongdisheng marked this pull request as ready for review February 1, 2026 01:26
@kruise-bot
Copy link

@ongdisheng: PR needs rebase.

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] SandboxSet aligns with Sandbox in revision calculation method

2 participants