Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CBR-427] Make NtpCheck non-blocking unless explicitly forced #3586

Merged
merged 1 commit into from
Sep 13, 2018

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Sep 13, 2018

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

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • [ ] CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • [ ] I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

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).
Copy link
Contributor

@akegalj akegalj left a 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)
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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"

@KtorZ KtorZ merged commit c41d61e into develop Sep 13, 2018
@KtorZ KtorZ deleted the KtorZ/CBR-427/non-blocking-ntp-check branch September 17, 2018 08:11
KtorZ added a commit that referenced this pull request Nov 9, 2018
…ing-ntp-check

[CBR-427] Make NtpCheck non-blocking unless explicitly forced
KtorZ added a commit to input-output-hk/cardano-wallet-legacy that referenced this pull request Nov 9, 2018
…hk/KtorZ/CBR-427/non-blocking-ntp-check

[CBR-427] Make NtpCheck non-blocking unless explicitly forced
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants