X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d75bcd1e8bb8c5b312ccd6c86136d0c1e1d7b904..06c2c19bfe18a52348b72d93db59df4b03a4fcaa:/lib/controller/localdb/conn.go diff --git a/lib/controller/localdb/conn.go b/lib/controller/localdb/conn.go index 86e3f37148..104cfe28f5 100644 --- a/lib/controller/localdb/conn.go +++ b/lib/controller/localdb/conn.go @@ -18,6 +18,7 @@ import ( "git.arvados.org/arvados.git/sdk/go/arvados" "git.arvados.org/arvados.git/sdk/go/ctxlog" "git.arvados.org/arvados.git/sdk/go/httpserver" + "github.com/sirupsen/logrus" ) type railsProxy = rpc.Conn @@ -70,7 +71,7 @@ func (conn *Conn) checkProperties(ctx context.Context, properties interface{}) e return nil } -func (conn *Conn) maybeRefreshVocabularyCache() error { +func (conn *Conn) maybeRefreshVocabularyCache(logger logrus.FieldLogger) error { if conn.lastVocabularyRefreshCheck.Add(time.Second).After(time.Now()) { // Throttle the access to disk to at most once per second. return nil @@ -90,6 +91,7 @@ func (conn *Conn) maybeRefreshVocabularyCache() error { } conn.vocabularyFileModTime = fi.ModTime() conn.lastVocabularyError = nil + logger.Info("vocabulary file reloaded successfully") } return nil } @@ -97,7 +99,7 @@ func (conn *Conn) maybeRefreshVocabularyCache() error { func (conn *Conn) loadVocabularyFile() error { vf, err := os.ReadFile(conn.cluster.API.VocabularyPath) if err != nil { - return fmt.Errorf("couldn't reading the vocabulary file: %v", err) + return fmt.Errorf("while reading the vocabulary file: %v", err) } mk := make([]string, 0, len(conn.cluster.Collections.ManagedProperties)) for k := range conn.cluster.Collections.ManagedProperties { @@ -113,8 +115,9 @@ func (conn *Conn) loadVocabularyFile() error { // LastVocabularyError returns the last error encountered while loading the // vocabulary file. +// Implements health.Func func (conn *Conn) LastVocabularyError() error { - conn.maybeRefreshVocabularyCache() + conn.maybeRefreshVocabularyCache(ctxlog.FromContext(context.Background())) return conn.lastVocabularyError } @@ -134,11 +137,9 @@ func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error) return arvados.Vocabulary{}, err } } - err := conn.maybeRefreshVocabularyCache() + err := conn.maybeRefreshVocabularyCache(logger) if err != nil { logger.WithError(err).Error("error reloading vocabulary file - ignoring") - } else { - logger.Info("vocabulary file reloaded successfully") } return *conn.vocabularyCache, nil }