-
Notifications
You must be signed in to change notification settings - Fork 631
[CBR-427] Make NtpCheck non-blocking unless explicitly forced #3586
Conversation
When implementing the new data-layer 'node-info' handler, we've made the choice to have the underlying check for NtpStatus blocking / synchronous. This choices is usually fine as the check normally takes around ~100ms. However, when running on CI, we do not connect to the Internet and therefore, will always timeout for those check. This could be the cause for the integration tests bootstrap not syncing properly (not telling us about it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
getNtpOffset :: MonadIO m => (NtpStatus -> STM (Maybe NtpOffset)) -> m (Maybe NtpOffset) | ||
getNtpOffset lookupNtpOffset = | ||
atomically $ (readTVar tvar >>= lookupNtpOffset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: $ (...)
- either function application of parens are unecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True this. The parens are useful here but not the $
application.
-> m V1.TimeInfo | ||
defaultGetNtpDrift tvar ntpCheckBehavior = liftIO $ mkTimeInfo <$> | ||
if (ntpCheckBehavior == V1.ForceNtpCheck) then | ||
forceNtpCheck >> getNtpOffset blockingLookupNtpOffset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KtorZ wouldn't be better to have atomically
at the boundary but keep forceNtpCheck
and getNtpOffset
running in STM, so that they compose better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we can't 🙃 ... We need to force the check first, commit the transaction, and then, get the offset :)
On the other side, there's also a process watching this TVar which is triggered by the forceNtpCheck
. Then, we just wait for that process to update the var to something that isn't "Pending"
…ing-ntp-check [CBR-427] Make NtpCheck non-blocking unless explicitly forced
…hk/KtorZ/CBR-427/non-blocking-ntp-check [CBR-427] Make NtpCheck non-blocking unless explicitly forced
Description
When implementing the new data-layer 'node-info' handler, we've made the
choice to have the underlying check for NtpStatus blocking /
synchronous. This choices is usually fine as the check normally takes
around ~100ms. However, when running on CI, we do not connect to the
Internet and therefore, will always timeout for those check. This could
be the cause for the integration tests bootstrap not syncing properly
(not telling us about it).
Linked issue
[CBR-427]
Type of change
Developer checklist
[ ] CHANGELOG entry has been added and is linked to the correct PR on GitHub.Testing checklist
[ ] I have added tests to cover my changes.QA Steps
Screenshots (if available)