Skip to content

fix(cluster_management): clean up leaked status records - #3738

Merged
mkoura merged 3 commits into
masterfrom
cm_flag_leaks
Oct 5, 2026
Merged

mkoura merged 3 commits into
masterfrom
cm_flag_leaks

Conversation

@mkoura

@mkoura mkoura commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Fix cluster management bugs that could leave status records behind, or give a test fewer resources than it asked for. The stale records cleanup ignores records of live workers, so a leaked record stayed for the rest of the testrun.

  • Clean up records when obtaining a cluster instance fails. When get_cluster_instance raised (timeout, dead clusters check, an error during respin):

    • a "prio" record of a priority test kept all other workers waiting until they timed out
    • a "respin in progress" record of a claimed respin kept all workers away from the cluster instance

    Remove both records, and hand back the claimed respin as "needs respin" so other workers perform it once the instance is idle. When _respin itself raises, mark the cluster instance dead, same as when the cluster fails to start - the failure can be permanent (e.g. FORBID_RESPIN), so the respin is not handed back in that case.

  • Call on_test_stop even when the log files check fails, so the resources locked by the test are released.

  • Make OneOf filters in lock_resources and use_resources of the same request select distinct resources. Previously the "use" filter could select the resource the "lock" filter had just selected, and the test got one resource instead of two. No current fixture mixes the two, so this was latent.

  • Return the directory of cached custom startup scripts instead of the start-cluster file. The fixtures returned the file when the scripts were already generated by another worker, so the respin with such scriptsdir failed and the cluster instance was marked dead. Also fix the epoch length in the epoch_length_start_cluster docstring and lock name (1500, not 1200).

Unit tests were added for the record cleanup and the distinct OneOf picks; all framework_tests pass.

mkoura added 3 commits October 5, 2026 17:30
Status records of a worker that fails while obtaining a cluster
instance were left behind. The stale records cleanup ignores records
of live workers, so they stayed for the rest of the testrun:

- a "prio" record kept all other workers waiting for the priority
  test until they timed out
- a "respin in progress" record of a claimed respin, or of a respin
  that raised instead of returning, kept all workers away from the
  cluster instance

Remove the "prio" record and the "respin in progress" record when
`get_cluster_instance` raises, and hand back the claimed respin as
"needs respin". Mark the cluster instance dead when `_respin` raises,
same as when the cluster fails to start - the failure can be
permanent, so the respin is not handed back in that case.

Also call `on_test_stop` even when the log files check fails, so the
resources locked by the test are released.
The fixtures preparing custom startup scripts returned the
`start-cluster` file instead of its directory when the scripts were
already generated by another worker. The respin with such
`scriptsdir` fails and the cluster instance is marked dead.

Also fix the epoch length in the `epoch_length_start_cluster`
docstring and lock name - the fixture sets 1500, not 1200.
A `OneOf` filter in `use_resources` could select the same resource
that a `OneOf` filter in `lock_resources` of the same request had
just selected for locking. The test would then get one resource
instead of two distinct ones.

Pass the resources selected for locking to the selection of the
resources for use, so the filters don't select them again.
@mkoura
mkoura requested a balanced review from Copilot October 5, 2026 15:34
@mkoura
mkoura requested a review from saratomaz as a code owner October 5, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The cleanup and allocation fixes are consistent with existing coordination semantics and have focused unit coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Improves cluster-management cleanup and resource allocation reliability.

Changes:

  • Cleans priority, respin, and resource records on failure paths.
  • Ensures OneOf filters select distinct resources.
  • Corrects cached startup-script paths and epoch-length naming.
File Description
cluster_getter.py Adds failure cleanup and distinct resource selection.
resources_management.py Supports excluding previously selected resources.
tests/​conftest.py Guarantees test-stop cleanup after log-check failures.
tests/​test_configuration.py Fixes cached script paths and epoch naming.
tests/​test_kes.py Returns the cached scripts directory.
framework_tests/​test_cluster_getter.py Tests cleanup and resource-selection behavior.
framework_tests/​test_resources_management.py Tests previously selected resource exclusion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mkoura
mkoura merged commit 94c4210 into master Oct 5, 2026
4 checks passed
@mkoura
mkoura deleted the cm_flag_leaks branch October 5, 2026 15:37
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