Skip to content

HTCondor monitor: a failed schedd query is not an empty answer - #321

Merged
mightqxc merged 3 commits into
HSF:masterfrom
wenaus:htcondor-query-failure-keeps-workers
Nov 6, 2026
Merged

mightqxc merged 3 commits into
HSF:masterfrom
wenaus:htcondor-query-failure-keeps-workers

Conversation

@wenaus

@wenaus wenaus commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

When the schedd query raises, HTCondorMonitor.check_workers continues with an empty result, so every worker of the batch reads as missing. A failed condor_q or condor_history command is logged and treated the same way. The repeated unknown results reach checkTimeout, and the monitor kills the workers although they are running. After a schedd outage on an OSG queue at BNL, live workers were cancelled this way while PanDA kept giving them jobs.

A failed query now returns a failure, and a failed command raises. The monitor keeps the status of the batch's workers, marks them unchecked and records WORKER_STATE_UNVERIFIED. Before, it passed a status of None, which stopped the update of the whole chunk. A new HTCondorMonitor option, preserveUnknownWorkers (default false), keeps a worker whose scheduler state is unknown past checkTimeout instead of killing it; without it the timeout behaves as before.

A worker Harvester has already ordered killed is not kept: when its kill is due and its scheduler state is unknown past checkTimeout, it is ended as cancelled, keeping any pilot error already recorded. A worker killed for queuing longer than workerQueueTimeLimit leaves the schedd, and the history query skips it once its submission is older than useCondorHistoryMaxAge, so without this it kept its status indefinitely and counted against the queue's worker limits while the sweeper repeated the kill. On the BNL OSG queue 421 such workers held its waiting limit until they were ended by hand.

Running on the ePIC OSG harvester at BNL since 2026-10-25, with the option's behaviour always on, and the ending of killed workers since 2026-11-04.

🤖 Generated with Claude Code

wenaus and others added 2 commits October 30, 2026 06:43
When the schedd query raised, the HTCondor monitor went on with an
empty result, so every worker of the batch read as missing; a failed
condor_q or condor_history command was logged and treated the same way.
Repeated unknown results then reached checkTimeout and the monitor
killed the workers, though they were running. After a schedd outage on
an OSG queue, live workers were cancelled this way and PanDA kept
dispatching jobs to them.

A failed query now returns a failure, and a failed command raises. The
monitor keeps the status of the batch's workers, marks them unchecked
and records WORKER_STATE_UNVERIFIED, instead of passing a status of
None. A new HTCondorMonitor option, preserveUnknownWorkers (default
false), keeps a worker whose scheduler state is unknown past
checkTimeout instead of killing it; without it the timeout behaves as
before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 10:45
wenaus added a commit to BNLNPPS/distcomp-services that referenced this pull request Oct 30, 2026
…afety change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

🟡 Changes recommended

On schedd query failures, clearing workersToCheck skips messenger processing, delaying live-worker requests and updates and potentially leaving Event Service workers running without event ranges.

1 open issue
What changed in this PR

This PR distinguishes HTCondor query failures from empty scheduler results to prevent live workers from being cancelled during schedd outages.

Changes:

  • Propagates query and command failures instead of treating them as missing workers.
  • Preserves worker status and records unchecked-state diagnostics after batch failures.
  • Adds preserveUnknownWorkers, defaulting to false, to retain unknown workers beyond checkTimeout.
File Description
pandaharvester/​harvestermonitor/​htcondor_monitor.py Returns query failures and adds the preservation option.
pandaharvester/​harvestermisc/​htcondor_utils.py Raises an exception when a Condor query command fails.
pandaharvester/​harvesterbody/​monitor.py Handles failed batches and conditionally preserves unknown workers past timeout.

Review effort: Balanced

Comment on lines +640 to 649
for unchecked in workersToCheck:
retMap[unchecked.workerID].update(
newStatus=unchecked.status,
monStatus=unchecked.status,
isChecked=False,
workAttributes=unchecked.workAttributes or {},
diagMessage=f"WORKER_STATE_UNVERIFIED: monitor query failed: {tmpOut}",
)
workersToCheck = []
tmpOut = []
@mightqxc

Copy link
Copy Markdown
Collaborator

Is this PR finalized yet? I still see open suggested change from Copilot.
BTW, I'm fine with the change.

With preserveUnknownWorkers, a worker whose scheduler state is unknown past
checkTimeout was kept even when Harvester had already ordered its kill. A
worker killed for queuing too long is removed from the schedd, and once its
submission is older than useCondorHistoryMaxAge the history query skips it,
so it stayed unknown and kept its status indefinitely, counting against the
queue's worker limits while the sweeper repeated the kill every cycle.

A worker of unknown state past checkTimeout whose kill is due is now ended
as cancelled, keeping any pilot error already recorded. A worker without a
kill order, or with a delayed kill not yet due, is kept as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wenaus added a commit to BNLNPPS/distcomp-services that referenced this pull request Nov 4, 2026
…; host-install.py --prefix

edits.json for the osgsub01 monitor: a worker of unknown state past
checkTimeout whose kill is due is ended as cancelled instead of kept
(HSF/harvester#321). host-install.py takes --prefix so it installs under
/opt/harvester as well as /opt/panda.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wenaus

wenaus commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Yes, this is ready from our side.

On the open Copilot suggestion: clearing workersToCheck when a plugin's check fails is master's existing path for every monitor plugin (harvesterbody/monitor.py). This PR only sends HTCondor query failures down that path, instead of the empty answer that cancelled live workers. Changing that path for all plugins would be a separate PR, so I've left the suggestion out of this one.

@mightqxc
mightqxc merged commit 2b6cc2f into HSF:master Nov 6, 2026
1 check passed
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.

3 participants