Skip to content

Sandbox-owned Services are not reconciled when selector or sandbox label drifts #560

@rayowang

Description

@rayowang

Problem

reconcileService currently repairs unowned Services before adoption, but Services that are already owned by the Sandbox are treated as up-to-date.

This means critical fields can drift and remain incorrect, including:

  • metadata.labels[agents.x-k8s.io/sandbox-name-hash]
  • spec.selector

Why this matters

If an owned Service keeps a stale selector or loses the sandbox label, traffic can be routed incorrectly and the Service state no longer reflects the Sandbox's desired state.

Expected behavior

Services owned by the Sandbox should also be reconciled back to the desired selector and sandbox label.

Proposed fix

Update reconcileService so that when a Service is already owned by the Sandbox, it:

  • restores metadata.labels[agents.x-k8s.io/sandbox-name-hash]
  • restores spec.selector to the expected sandbox selector
  • preserves unrelated labels
  • only updates the Service when drift is detected

Test plan

Add a regression test covering an owned Service whose selector and sandbox label have drifted, and verify reconcile restores them without removing unrelated labels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions