HomeClusterLabs Projects

Fix: tools: Handle large timeouts correctly in crm_resource --wait

Description

Fix: tools: Handle large timeouts correctly in crm_resource --wait

Previously, if the --timeout value parsed to a value greater than
(UINT_MAX - 999), the wait timeout would overflow. The effective timeout
would be either 0 seconds or 1 second. This is because 999 was added to
the guint value before passing it to pcmk__timeout_ms2s().

Now, we simply pass the timeout in milliseconds to
pcmk__timeout_ms2s(), without adding 999.

This implies a slight behavior change. Previously, timeouts were always
rounded up to the next greatest second. Now, they're rounded to the
nearest second. For example, previously:

  • timeout values between 1ms and 500ms => wait timeout of 1 second
  • timeout values between 501ms and 1500ms => wait timeout of 2 seconds
  • timeout values between 1501ms and 2500ms => wait timeout of 3 seconds
  • and so on

Now:

  • timeout values between 1ms and 1499ms => wait timeout of 1 second
  • timeout values between 1500ms and 2499ms => wait timeout of 2 seconds
  • timeout values between 2500ms and 3499ms => wait timeout of 3 seconds
  • and so on

The previous rounding behavior has existed since crm_resource --wait was
added by 424afcdf.

Update the help text to note the granularity and rounding behavior. The
exact behavior of the restart command is confusing, and its logic should
be cleaned up in the future.

Fixes RHEL-45869
Fixes RHEL-86148
Closes T841

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Fri, Sep 5, 11:35 PM
Parents
rPeb15ad55628c: Merge pull request #3956 from nrwahl2/nrwahl2-refactors
Branches
Unknown
Tags
Unknown
Tasks
T841: Reject too-large --timeout values in crm_resource