Wrap the dev logs in a sync.Once and deregister first, to eliminate the possibility of emitting the dev output twice in a race. (#10258)

This commit is contained in:
Scott Miller 2020-10-28 10:23:18 -05:00 committed by GitHub
parent a4bcbb84e2
commit dd0ea9a389
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1667,8 +1667,12 @@ CLUSTER_SYNTHESIS_COMPLETE:
} }
var qw *quiescenceSink var qw *quiescenceSink
var qwo sync.Once
qw = &quiescenceSink{ qw = &quiescenceSink{
t: time.AfterFunc(100*time.Millisecond, func() { t: time.AfterFunc(100*time.Millisecond, func() {
qwo.Do(func() {
c.logger.DeregisterSink(qw)
// Print the big dev mode warning! // Print the big dev mode warning!
c.UI.Warn(wrapAtLength( c.UI.Warn(wrapAtLength(
"WARNING! dev mode is enabled! In this mode, Vault runs entirely " + "WARNING! dev mode is enabled! In this mode, Vault runs entirely " +
@ -1732,10 +1736,8 @@ CLUSTER_SYNTHESIS_COMPLETE:
c.UI.Warn(wrapAtLength( c.UI.Warn(wrapAtLength(
"Development mode should NOT be used in production installations!")) "Development mode should NOT be used in production installations!"))
c.UI.Warn("") c.UI.Warn("")
c.logger.DeregisterSink(qw) })
})}
}),
}
c.logger.RegisterSink(qw) c.logger.RegisterSink(qw)
} }