pt-galera-log-explainer: fixed nitpicks from review

This commit is contained in:
Yoann La Cancellera
2024-03-21 19:52:25 +01:00
parent 4f44d1a504
commit 9dbed00bee
2 changed files with 6 additions and 5 deletions

View File

@@ -70,7 +70,7 @@ func AddHashToIP(hash, ip string, ts time.Time) {
db.rwlock.Lock() db.rwlock.Lock()
defer db.rwlock.Unlock() defer db.rwlock.Unlock()
latestValue, ok := db.HashToIP[hash] latestValue, ok := db.HashToIP[hash]
if !ok { if !ok || latestValue == nil {
db.HashToIP[hash] = &translationUnit{Value: ip, Timestamp: ts} db.HashToIP[hash] = &translationUnit{Value: ip, Timestamp: ts}
} else { } else {
latestValue.UpdateTimestamp(ts) latestValue.UpdateTimestamp(ts)

View File

@@ -33,14 +33,15 @@ Regarding UUIDs (wsrep_gcomm_uuid), different format can be found in logs depend
func (w *whois) Run() error { func (w *whois) Run() error {
if w.SearchType == "auto" { if w.SearchType == "auto" {
if regex.IsNodeUUID(w.Search) { switch {
case regex.IsNodeUUID(w.Search):
w.Search = utils.UUIDToShortUUID(w.Search) w.Search = utils.UUIDToShortUUID(w.Search)
w.SearchType = "uuid" w.SearchType = "uuid"
} else if regex.IsNodeIP(w.Search) { case regex.IsNodeIP(w.Search):
w.SearchType = "ip" w.SearchType = "ip"
} else if len(w.Search) != 8 { // at this point it's only a doubt between names and legacy node uuid, where only the first part of the uuid was shown in log case len(w.Search) != 8:
w.SearchType = "nodename" w.SearchType = "nodename"
} else { default:
log.Info().Msg("input information's type is ambiguous, scanning files to discover the type. You can also provide --type to avoid auto-detection") log.Info().Msg("input information's type is ambiguous, scanning files to discover the type. You can also provide --type to avoid auto-detection")
} }
} }