Skip to content

Installer: adopt existing tracebloc-data-plane PriorityClass when workspace name changes #165

Description

@saadqbal

Symptom

Re-running the installer with a different workspace name than a previous install fails at helm upgrade --install with:

Error: unable to continue with install: PriorityClass "tracebloc-data-plane" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-name" must equal "ap-workspace": current value is "arturo-local"; annotation validation error: key "meta.helm.sh/release-namespace" must equal "ap-workspace": current value is "arturo-local"

Reported by an operator (Arturo) on 2026-05-26 — first install used workspace arturo-local, second install used ap-workspace.

Root cause

PriorityClass is cluster-scoped. The chart correctly annotates it with helm.sh/resource-policy: keep (client/templates/priority-class.yaml:11) so helm uninstall doesn't yank it out from under sibling releases. But Helm's other side of that coin is: when a release with a different name tries to render the same cluster-scoped resource, Helm refuses to "adopt" it because the stored ownership annotations (meta.helm.sh/release-name, meta.helm.sh/release-namespace) don't match.

Result: a perfectly normal "I want to rename my workspace" flow becomes a hard failure with a Helm-shaped error message that the target user (an ML operator running a one-line installer) has no realistic way to diagnose.

Current workaround

Three manual options, none discoverable from the installer output:

  1. Re-use the same workspace name as the previous install.
  2. Re-stamp the PriorityClass ownership annotations to match the new release name + namespace, then re-run.
  3. helm uninstall <old-release> + kubectl delete priorityclass tracebloc-data-plane, then re-run.

Proposed fix

Have install-client-helm.sh detect the case before helm upgrade --install and adopt the existing PriorityClass automatically:

# In install-client-helm.sh, before the helm upgrade --install call:
if kubectl get priorityclass tracebloc-data-plane -o json 2>/dev/null \
   | jq -e '.metadata.annotations["meta.helm.sh/release-name"]' >/dev/null; then
  existing_release=$(kubectl get priorityclass tracebloc-data-plane \
    -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-name}')
  if [[ "$existing_release" != "$TB_NAMESPACE" ]]; then
    log "Adopting existing tracebloc-data-plane PriorityClass (was owned by '$existing_release')"
    kubectl annotate --overwrite priorityclass tracebloc-data-plane \
      "meta.helm.sh/release-name=$TB_NAMESPACE" \
      "meta.helm.sh/release-namespace=$TB_NAMESPACE"
    kubectl label --overwrite priorityclass tracebloc-data-plane \
      app.kubernetes.io/managed-by=Helm
  fi
fi

Safe because the chart re-renders identical PriorityClass content regardless of which release "owns" it — only the ownership annotations differ, and Helm only inspects those.

Acceptance criteria

  • Re-running install-k8s.sh (or install.sh) with a new workspace name when a previous workspace exists succeeds without manual kubectl intervention.
  • Adoption is logged so operators can see what happened.
  • No regression in the green-field case (no pre-existing PriorityClass).
  • Same logic added to install.ps1 / install-k8s.ps1 if PowerShell installer follows the same flow.
  • Helm chart test covers the "PriorityClass already exists, owned by a different release" path (probably via a helm template + manual kubectl apply setup, since helm-unittest can't simulate cluster state).

Notes

  • Same problem will recur for any other cluster-scoped resource the chart introduces in the future (ClusterRole, StorageClass with helm.sh/resource-policy: keep, etc.). Worth factoring the adoption logic into a small helper that takes (kind, name) as args so future cluster-scoped resources can be added to the list without re-implementing it.
  • The chart's helm.sh/resource-policy: keep choice is correct and should stay — this is purely an installer-side fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions