Skip to content

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

Description

@vharseko

Summary

The update CLI command accepts --maxUpdateWaitTimeMs ("Timeout value to wait for update process to complete. Defaults to 30000 ms.", RemoteCommandScope.java:233-237) and carries it into UpdateCommandConfig.maxUpdateWaitTimeMs (:24, :261), but nothing ever reads it: getMaxUpdateWaitTimeMs() is referenced only from a Javadoc @see (UpdateCommand.java:710). WaitForInstallDoneStepExecutor polls the update log until a terminal status with no time limit at all, so the option is a silent no-op and the CLI can wait forever.

Found while analysing #219 (fixed by #221); kept separate because it is a different loop and a different decision.

Root cause

WaitForInstallDoneStepExecutor.execute (UpdateCommand.java:737-759):

while (!TERMINAL_STATE.contains(status)) {
    log("Update procedure is still processing...");
    Thread.sleep(config.getCheckCompleteFrequency());
    ...
    status = response.getContent().get("status").defaultTo(UPDATE_STATUS_IN_PROGRESS).asString().toUpperCase();
}
if (TERMINAL_STATE.contains(status)) {
    ...
    return ExecutorStatus.SUCCESS;
} else {
    log("The update process failed to complete within the allotted time.  " +
            "Please verify the state of OpenIDM.");
    return ExecutorStatus.FAIL;
}

The else branch is unreachable: the loop only exits when status is terminal. The startTime read from state.getStartInstallTime() (:728) is validated (startTime <= 0IllegalStateException) but never used for anything else.

This is not a regression on our side: upstream commit 9cc8612fd (OPENIDM-5529, 2016-04-06) removed the timeout = (System.currentTimeMillis() - startTime > config.getMaxUpdateWaitTimeMs()) evaluation from the loop when it added PENDING_REPO_UPDATES to TERMINAL_STATE, and in the same commit disabled the test that covered the timeout — UpdateCommandTest.testTimeoutInstallUpdateArchive is still there with //@Test (UpdateCommandTest.java:271). The CLI parameter, config setter, Javadoc and dead branch were left behind, so the tool still advertises a timeout it does not honour.

Suggested fix

Two consistent outcomes; either is better than the current state:

  1. Honour the parameter. Check elapsed time (monotonic, via the WaitClock introduced in [#219] Make UpdateCommand job-wait loop verdict fresh and its test clock-independent #221) before each sleep and stop polling once maxUpdateWaitTimeMs is exceeded, then re-enable testTimeoutInstallUpdateArchive with the fake clock so it is deterministic. Note the current failure path is unsafe for this case: a FAIL from WAIT_FOR_INSTALL_DONE runs the recovery sequence (EXIT_MAINTENANCE_MODE, ENABLE_SCHEDULER, FORCE_RESTART) while the server-side install may still be in progress. A timeout should therefore stop waiting, print the update id and last status and exit non-zero, without running recovery — or the parameter should be documented as "give up waiting; the update continues on the server".
  2. Drop the parameter. Remove --maxUpdateWaitTimeMs, UpdateCommandConfig.maxUpdateWaitTimeMs, the @see, the unreachable else branch and the dead test, and document that the CLI waits until the update reaches a terminal state.

Given that repo migrations can legitimately take longer than any fixed default and that upstream apparently removed the timeout on purpose, option 2 (or option 1 with the "stop waiting, do not recover" semantics) seems the safer direction; a 30 s default that triggers recovery mid-install would be worse than today's behaviour.

Environment

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationDocumentation, javadoc, adoc, README, wikijavaPull requests that update Java codetestTests and test infrastructure (unit, e2e, smoke)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions