Skip to content

Encode user IDs in labels without loss #119

Closed

Description

@uniqueg

TESK API stores the ID of the user who created a task (the OIDC sub) in the Kubernetes label creator-user-id of the task's objects, after replacing @ with _ (User#getUsername). This encoding loses information and doesn't cover all valid IDs:

  • Different IDs can end up with the same label value (e.g. a@b and a_b), so the label doesn't identify the creator exactly.
  • OIDC allows arbitrary strings as sub, while Kubernetes label values allow at most 63 characters from [A-Za-z0-9._-], starting and ending with an alphanumeric character. A sub with other characters, or a longer one, can't be stored, so creating a task fails.
  • logs[0].metadata.USER_ID shows the encoded value instead of the ID.

Proposal

  • Store a fixed-length hash of the full ID (truncated SHA-256, hex) in a new label, e.g. creator-user-hash, which turns any ID into a valid label value, and the full ID in an annotation (creator-user-id), on the taskmaster's job, its ConfigMap and the executors' jobs.
  • Select a user's tasks by the hash label, then compare the annotation with the user's ID, so that only exact matches count.
  • Show the full ID in logs[0].metadata.USER_ID.
  • Tasks created before the change only have the old label. Provide a transition: a setting that makes TESK API also match the old label for tasks without the new one (off by default), and upgrade notes on what operators need to do.
  • Behaviour for admins and group managers stays the same.
  • Document the labels, the setting and the upgrade.

Whether the taskmaster (tesk-core) reads these labels is checked as part of the work.

This issue was written by Claude Code Opus 5.5 on behalf of @uniqueg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions