Don't display an overlay in case the time sync check fails. (#6164)

* Small improvements to time estimation.

* Temporarily disable NTP time check by default.
This commit is contained in:
Tomasz Drwięga 2017-07-27 17:36:23 +02:00 committed by Arkadiy Paronyan
parent 0209c6e0ff
commit 9902714fb4
8 changed files with 21 additions and 14 deletions

View File

@ -100,6 +100,10 @@ impl SimpleNtp {
impl Ntp for SimpleNtp { impl Ntp for SimpleNtp {
fn drift(&self) -> BoxFuture<Duration, Error> { fn drift(&self) -> BoxFuture<Duration, Error> {
let address = self.address.clone(); let address = self.address.clone();
if &*address == "none" {
return futures::future::err(Error::Ntp("NTP server is not provided.".into())).boxed();
}
self.pool.spawn_fn(move || { self.pool.spawn_fn(move || {
let packet = ntp::request(&*address)?; let packet = ntp::request(&*address)?;
let dest_time = ::time::now_utc().to_timespec(); let dest_time = ::time::now_utc().to_timespec();
@ -114,7 +118,9 @@ impl Ntp for SimpleNtp {
} }
} }
const MAX_RESULTS: usize = 4; // NOTE In a positive scenario first results will be seen after:
// MAX_RESULTS * UPDATE_TIMEOUT_OK_SECS seconds.
const MAX_RESULTS: usize = 7;
const UPDATE_TIMEOUT_OK_SECS: u64 = 30; const UPDATE_TIMEOUT_OK_SECS: u64 = 30;
const UPDATE_TIMEOUT_ERR_SECS: u64 = 2; const UPDATE_TIMEOUT_ERR_SECS: u64 = 2;
@ -225,7 +231,7 @@ mod tests {
fn time_checker() -> TimeChecker<FakeNtp> { fn time_checker() -> TimeChecker<FakeNtp> {
let last_result = Arc::new(RwLock::new( let last_result = Arc::new(RwLock::new(
(Instant::now(), vec![Err(Error::Ntp("NTP server unavailable.".into()))].into()) (Instant::now(), vec![Err(Error::Ntp("NTP server unavailable".into()))].into())
)); ));
TimeChecker { TimeChecker {

View File

@ -228,9 +228,10 @@ export default class Status {
_overallStatus = (health) => { _overallStatus = (health) => {
const all = [health.peers, health.sync, health.time].filter(x => x); const all = [health.peers, health.sync, health.time].filter(x => x);
const allNoTime = [health.peers, health.sync].filter(x => x);
const statuses = all.map(x => x.status); const statuses = all.map(x => x.status);
const bad = statuses.find(x => x === STATUS_BAD); const bad = statuses.find(x => x === STATUS_BAD);
const needsAttention = statuses.find(x => x === STATUS_WARN); const needsAttention = allNoTime.map(x => x.status).find(x => x === STATUS_WARN);
const message = all.map(x => x.message).filter(x => x); const message = all.map(x => x.message).filter(x => x);
if (all.length) { if (all.length) {

View File

@ -35,7 +35,7 @@ const initialState = {
status: DEFAULT_STATUS status: DEFAULT_STATUS
}, },
overall: { overall: {
isReady: false, isNotReady: true,
status: DEFAULT_STATUS, status: DEFAULT_STATUS,
message: [] message: []
} }

View File

@ -116,7 +116,7 @@ class SyncWarning extends Component {
function mapStateToProps (state) { function mapStateToProps (state) {
const { health } = state.nodeStatus; const { health } = state.nodeStatus;
const isNotAvailableYet = health.overall.isReady; const isNotAvailableYet = health.overall.isNotReady;
const isOk = isNotAvailableYet || health.overall.status === 'ok'; const isOk = isNotAvailableYet || health.overall.status === 'ok';
return { return {

View File

@ -359,7 +359,7 @@ usage! {
or |c: &Config| otry!(c.vm).jit.clone(), or |c: &Config| otry!(c.vm).jit.clone(),
// -- Miscellaneous Options // -- Miscellaneous Options
flag_ntp_server: String = "pool.ntp.org:123", flag_ntp_server: String = "none",
or |c: &Config| otry!(c.misc).ntp_server.clone(), or |c: &Config| otry!(c.misc).ntp_server.clone(),
flag_logging: Option<String> = None, flag_logging: Option<String> = None,
or |c: &Config| otry!(c.misc).logging.clone().map(Some), or |c: &Config| otry!(c.misc).logging.clone().map(Some),
@ -919,7 +919,7 @@ mod tests {
flag_dapps_apis_all: None, flag_dapps_apis_all: None,
// -- Miscellaneous Options // -- Miscellaneous Options
flag_ntp_server: "pool.ntp.org:123".into(), flag_ntp_server: "none".into(),
flag_version: false, flag_version: false,
flag_logging: Some("own_tx=trace".into()), flag_logging: Some("own_tx=trace".into()),
flag_log_file: Some("/var/log/parity.log".into()), flag_log_file: Some("/var/log/parity.log".into()),

View File

@ -1277,7 +1277,7 @@ mod tests {
support_token_api: true support_token_api: true
}, UiConfiguration { }, UiConfiguration {
enabled: true, enabled: true,
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
interface: "127.0.0.1".into(), interface: "127.0.0.1".into(),
port: 8180, port: 8180,
hosts: Some(vec![]), hosts: Some(vec![]),
@ -1519,7 +1519,7 @@ mod tests {
assert_eq!(conf0.directories().signer, "signer".to_owned()); assert_eq!(conf0.directories().signer, "signer".to_owned());
assert_eq!(conf0.ui_config(), UiConfiguration { assert_eq!(conf0.ui_config(), UiConfiguration {
enabled: true, enabled: true,
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
interface: "127.0.0.1".into(), interface: "127.0.0.1".into(),
port: 8180, port: 8180,
hosts: Some(vec![]), hosts: Some(vec![]),
@ -1528,7 +1528,7 @@ mod tests {
assert_eq!(conf1.directories().signer, "signer".to_owned()); assert_eq!(conf1.directories().signer, "signer".to_owned());
assert_eq!(conf1.ui_config(), UiConfiguration { assert_eq!(conf1.ui_config(), UiConfiguration {
enabled: true, enabled: true,
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
interface: "127.0.0.1".into(), interface: "127.0.0.1".into(),
port: 8180, port: 8180,
hosts: Some(vec![]), hosts: Some(vec![]),
@ -1538,7 +1538,7 @@ mod tests {
assert_eq!(conf2.directories().signer, "signer".to_owned()); assert_eq!(conf2.directories().signer, "signer".to_owned());
assert_eq!(conf2.ui_config(), UiConfiguration { assert_eq!(conf2.ui_config(), UiConfiguration {
enabled: true, enabled: true,
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
interface: "127.0.0.1".into(), interface: "127.0.0.1".into(),
port: 3123, port: 3123,
hosts: Some(vec![]), hosts: Some(vec![]),
@ -1547,7 +1547,7 @@ mod tests {
assert_eq!(conf3.directories().signer, "signer".to_owned()); assert_eq!(conf3.directories().signer, "signer".to_owned());
assert_eq!(conf3.ui_config(), UiConfiguration { assert_eq!(conf3.ui_config(), UiConfiguration {
enabled: true, enabled: true,
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
interface: "test".into(), interface: "test".into(),
port: 8180, port: 8180,
hosts: Some(vec![]), hosts: Some(vec![]),

View File

@ -47,7 +47,7 @@ impl Default for Configuration {
let data_dir = default_data_path(); let data_dir = default_data_path();
Configuration { Configuration {
enabled: true, enabled: true,
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
dapps_path: replace_home(&data_dir, "$BASE/dapps").into(), dapps_path: replace_home(&data_dir, "$BASE/dapps").into(),
extra_dapps: vec![], extra_dapps: vec![],
extra_embed_on: vec![], extra_embed_on: vec![],

View File

@ -107,7 +107,7 @@ impl Default for UiConfiguration {
fn default() -> Self { fn default() -> Self {
UiConfiguration { UiConfiguration {
enabled: true && cfg!(feature = "ui-enabled"), enabled: true && cfg!(feature = "ui-enabled"),
ntp_server: "pool.ntp.org:123".into(), ntp_server: "none".into(),
port: 8180, port: 8180,
interface: "127.0.0.1".into(), interface: "127.0.0.1".into(),
hosts: Some(vec![]), hosts: Some(vec![]),