After a keys-missing refusal, a worker is withheld tasks whose secrets are stored only for another worker

Open
#78 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, postgresql, python

Research direction

Read server/orcaster_server/task_secrets/gate.py and the three claim picks in server/orcaster_server/api/poll.py (around lines 1404–1455); trace how refusal exclusions differ from the version-floor and busy-poll gates. Start with the tests in server/tests/test_poll_task_secrets_worker_scope.py and server/tests/test_poll_task_secrets.py. Done means the acceptance cases pass, existing tests remain unchanged, and EXPLAIN plans for all three picks show no regression; add a CHANGELOG entry under Unreleased.

Written by the indexing model from the issue text.

Description

bug P1 server

Problem

Task secrets can be stored for the whole workspace or for one worker. A worker never receives another worker's secret; if no row applies to it, it uses its own environment (docs/user-manual.md:3730-3733).

When the server has no encryption keys loaded, a task whose declared name has an applicable row is refused for that worker (TaskSecretsKeysMissing). The refusal itself is worker-aware. What happens next is not:

  • After a refusal, the poll handler retries with exclude_all=True (server/orcaster_server/api/poll.py:1452-1455).
  • While the keys stay missing, the refusal memory sets exclude_all=True at the start of the next polls (server/orcaster_server/api/poll.py:1418-1421).
  • exclude_all is passed as exclude_stored_secrets (server/orcaster_server/api/poll.py:1404), which uses the same predicate as the version-floor gate (server/orcaster_server/api/poll.py:185).
  • That predicate counts task_secrets rows of any scope and never looks at s.worker_id (server/orcaster_server/task_secrets/gate.py:110-139). This is deliberate for the version-floor gate, because snapshot code paths have no polling worker. The poll picks do have one: :worker_id is already bound.

So a task whose name is stored only for worker B is withheld from worker A, even though no row applies to A and A would run it with its own environment.

Steps to reproduce

  1. Start the server without task secret keys (TASK_SECRETS_KEYS_PATH unset). Enroll workers w1 and w2 in one workspace.
  2. Store NAME_A for the whole workspace. Store NAME_B only for w2.
  3. Queue task T1 that declares NAME_A, then task T2 that declares NAME_B, so T1 is ahead.
  4. Poll as w1. T1 is refused (keys missing). The fallback pick excludes T2 as well.
  5. Poll as w1 again, with the refusal memory alive or expired. w1 gets no task, and T2 stays queued.

Expected: w1 receives T2 with an empty secrets field. This is what happens once T1 is cancelled.

The same over-exclusion happens when the name-exclusion picks are exhausted (server/orcaster_server/api/poll.py:1442-1455).

Proposed change

  1. Add a worker-aware variant of the predicate in server/orcaster_server/task_secrets/gate.py that adds AND (s.worker_id IS NULL OR s.worker_id = CAST(:worker_id AS uuid)).
  2. In the three claim picks, use the worker-aware variant for the refusal-driven exclusion, through a separate bind (for example :exclude_applicable_secrets).
  3. Keep the any-scope predicate for the version-floor gate and for a push in a busy poll. Do not change the fairness-yield predicate or housekeeping.
  4. Run EXPLAIN on the three picks before and after, to confirm the plan does not get worse.

Compatibility

No schema, API or setting change. The change only affects polls after a refusal while keys are missing or undecryptable. Version-floor behavior for old workers is unchanged. Workers on existing deployments only receive tasks that they would already receive once the blocking task is gone, and they never receive another worker's secret.

Acceptance criteria

  • Test (keys missing): T1 (applicable row, blocked) ahead of T2 (name stored only for another worker). w1 receives T2 with secrets == {}, both on the poll that hits the refusal and on a later poll with the refusal memory alive.
  • Test: a worker below the version floor is still withheld T2.
  • Test: a busy poll still does not receive a push of a task that uses stored secrets of any scope.
  • Test: w1 never receives the value stored for w2.
  • Existing deployments keep working without config changes. The existing tests in server/tests/test_poll_task_secrets_worker_scope.py and server/tests/test_poll_task_secrets.py pass unchanged.
  • CHANGELOG entry under Unreleased.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.