Skip to content

fix(spawner): derive co-location affinity from the pod's username label - #211

Draft
aktech wants to merge 6 commits into
mainfrom
fix/spawn-affinity-label-mismatch
Draft

fix(spawner): derive co-location affinity from the pod's username label#211
aktech wants to merge 6 commits into
mainfrom
fix/spawn-affinity-label-mismatch

Conversation

@aktech

@aktech aktech commented Aug 11, 2026

Copy link
Copy Markdown
Member

Replaces the templated co-location affinity with a modify_pod_hook that copies the pod's rendered hub.jupyter.org/username label into the affinity value.

The templated approach (main, since #213) writes {username} into both extra_labels and extra_pod_config and relies on kubespawner expanding both identically. That is undocumented internal behavior of exactly the kind that caused the original outage: kubespawner 7 renders its username label and {username} through different code paths (the label ignores slug_scheme and truncates at 32; the template follows slug_scheme and truncates at 48), so any two-sided template equality can silently diverge on an upgrade. Copying the rendered label leaves one computation and nothing to disagree.

Also: preserves node affinity instead of overwriting the pod's affinity object, replaces the config-string tests with rendered-manifest tests (real kubespawner, email usernames, both slug schemes) that fail in a version-bump PR if the invariant breaks, and adds a User Pod Scheduling admin doc.

Refs:

also relevant issue to fix for future: #221

aktech added 2 commits August 11, 2026 16:53
kubespawner 7 computes the hub.jupyter.org/username label with a different
slug truncation than {username} template expansion, so templating the value
into the required pod affinity made it unsatisfiable for usernames that get
a hashed slug (emails): every spawn failed with FailedScheduling on all
nodes. Build the affinity in a modify_pod_hook from the pod's own label so
the values match under any slug scheme.
Covers why home volumes are ReadWriteOnce, the co-location pod affinity
that RWO requires, and how to debug spawns that time out unscheduled.
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview for fix/spawn-affinity-label-mismatch:
https://fix-spawn-affinity-label-mis.data-science-pack.pages.dev

aktech and others added 3 commits August 13, 2026 06:13
Resolves the overlap with the templated-label fix that landed on main:
the affinity value is copied from the pod's rendered username label in
modify_pod_hook rather than trusting extra_labels and extra_pod_config
template expansions to render identically, which is undocumented
kubespawner behavior. Keeps main's slug_scheme pin. Replaces the
config-string tests with rendered-manifest tests that assert the
affinity value equals the pod's own label under both slug schemes and
that node affinity survives the hook.
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