Skip to content

[#222] Honour --maxUpdateWaitTimeMs and detach instead of recovering mid-install - #227

Open
vharseko wants to merge 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:issues/222
Open

vharseko wants to merge 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:issues/222

Conversation

@vharseko

Copy link
Copy Markdown
Member

Fixes #222

Stacked on #221. This branch contains the #221 commit (feb1f96ee) because it uses the WaitClock introduced there; the head branch of #221 lives in a fork, so the PR cannot target it. Please review only the last commit (f04dec3aa) until #221 is merged, after which the diff shrinks to it.

Problem

--maxUpdateWaitTimeMs was a silent no-op: WaitForInstallDoneStepExecutor polled the update log until a terminal status with no time limit, and its "failed to complete within the allotted time" branch was unreachable (upstream 9cc8612fd removed the check and disabled testTimeoutInstallUpdateArchive). Simply re-enabling a 30 s timeout would have run the recovery steps (maintenance/disable, scheduler/resumeJobs) while the server-side install was still in progress. The same happened already today on a polling error.

Change

  • The wait uses WaitClock and checks the budget before each sleep, as WaitForJobsStepExecutor does after [#219] Make UpdateCommand job-wait loop verdict fresh and its test clock-independent #221.
  • On budget expiry, interrupt or polling error the command detaches: UpdateExecutionState.detached is set, the recovery steps EXIT_MAINTENANCE_MODE, ENABLE_SCHEDULER and FORCE_RESTART are skipped, and the log names the update id, the last known status, maintenance/update/log/{id}, and — for restartRequired=false — the manual maintenance/disable + scheduler/resumeJobs follow-up. The step returns FAIL.
  • Interrupts are no longer swallowed: the flag is restored and the wait ends.
  • Default maxUpdateWaitTimeMs → 0 (wait until a terminal status), matching the effective behaviour so far. CLI @Descriptor, UpdateCommandConfig Javadoc and chap-update.adoc updated.
  • The CLI exit code is unchanged (point 4 of the issue discussion — separate problem).

Tests

  • testTimeoutInstallUpdateArchive re-enabled on FakeWaitClock; asserts detached, no recovery step, no maintenance/disable / resumeJobs calls.
  • New testPollingErrorDetachesFromInstall (restartRequired=true, asserts no restart either).
  • New testDefaultWaitsForInstallWithoutLimit: four polls stalling 40 s each still reach COMPLETE with the default.
  • testSuccessfulInstall, testSuccessfulInstallWithRestart, testFailedInstallUpdateArchive moved to FakeWaitClock, so the now enforced budget cannot make them wall-clock dependent (the UpdateCommandTest.testEnterMaintenanceMode is wall-clock dependent and flakes on macos-latest / JDK 26 #219 failure mode).

mvn -pl openidm-shell -am test -Dtest=UpdateCommandTest: 12 tests, 0 failures.

…resh and its test clock-independent

WaitForJobsStepExecutor evaluated the timeout after sleeping and then
returned the stale "still running" result of the poll made before the
sleep, so a stalled runner (or a job finishing during the last sleep)
produced "Running jobs did not finish" even though the next poll would
have found no jobs. This is what made testEnterMaintenanceMode flake on
macos-latest / JDK 26 with its 100ms budget.

Check the timeout before each sleep so the verdict is always based on
the latest poll, measure elapsed time with the monotonic nanoTime, and
route time and sleeping through an injectable WaitClock so the loop can
be driven deterministically in tests. testEnterMaintenanceMode now uses
the fake clock; a new test reproduces the CI stall and asserts that the
step succeeds when the next poll finds no running jobs.

Fixes OpenIdentityPlatform#219
…stead of recovering mid-install

WaitForInstallDoneStepExecutor polled the update log with no time limit,
so --maxUpdateWaitTimeMs was a silent no-op. The wait now uses the
WaitClock from OpenIdentityPlatform#221 and checks the budget before each sleep.

When the budget is exceeded, the thread is interrupted or the status
cannot be read, the update may still be running on the server. The
command then marks the execution state as detached: the recovery steps
(exit maintenance mode, resume scheduler, force restart) are skipped and
the log names the update id, the last status and how to follow up.

The default becomes 0 (wait until a terminal status), which matches the
effective behaviour so far; CLI descriptor, config Javadoc and
chap-update.adoc are updated accordingly.

testTimeoutInstallUpdateArchive is re-enabled on FakeWaitClock, tests for
a polling error and for the unlimited default are added, and the install
tests move to FakeWaitClock so the enforced budget cannot make them flaky.

Fixes OpenIdentityPlatform#222
@vharseko vharseko added bug Something isn't working java Pull requests that update Java code documentation Documentation, javadoc, adoc, README, wiki test Tests and test infrastructure (unit, e2e, smoke) labels Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Documentation, javadoc, adoc, README, wiki java Pull requests that update Java code test Tests and test infrastructure (unit, e2e, smoke)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update CLI: --maxUpdateWaitTimeMs is never applied, WaitForInstallDoneStepExecutor has no timeout and testTimeoutInstallUpdateArchive is disabled

1 participant