Skip to content

Commit

Permalink
improve loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksanford committed Sep 5, 2024
1 parent fa90c66 commit 7bd41d3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion services/datamanager/builtin/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (c *Capture) Reconfigure(
defer c.logger.Debug("Reconfigure END")
// Service is disabled, so close all collectors and clear the map so we can instantiate new ones if we enable this service.
if config.CaptureDisabled {
c.logger.Debug("Capture Disabled, flushing & shutting down collectors")
c.logger.Info("Capture Disabled")
c.Close()
return
}
Expand Down
10 changes: 10 additions & 0 deletions services/datamanager/builtin/sync/exponential_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ func (e exponentialRetry) run() error {
return err
}

// If the context was cancelled
// return the error without logging to not spam
if errors.Is(err, context.Canceled) {
return err
}

if e.ctx.Err() != nil {
return e.ctx.Err()
}

// Otherwise, try again after nextWait.
offline := isOfflineGRPCError(err)
nextWait = getNextWait(nextWait, offline)
Expand Down
17 changes: 13 additions & 4 deletions services/datamanager/builtin/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -121,6 +122,7 @@ func (s *Sync) Reconfigure(_ context.Context, config Config, cloudConnSvc cloud.
// to execute, don't stop workers
return
}

// config changed... stop workers
s.configCancelFunc()
s.FileDeletingWorkers.Stop()
Expand All @@ -129,6 +131,12 @@ func (s *Sync) Reconfigure(_ context.Context, config Config, cloudConnSvc cloud.
// wait for workers to stop
s.workersWg.Wait()

oldSyncPaths := strings.Join(s.config.syncPaths(), " ")
newSyncPaths := strings.Join(config.syncPaths(), " ")
if newSyncPaths != oldSyncPaths {
s.logger.Infof("sync_paths: %s", newSyncPaths)
}

// update config
s.configMu.Lock()
s.config = config
Expand All @@ -149,6 +157,8 @@ func (s *Sync) Reconfigure(_ context.Context, config Config, cloudConnSvc cloud.
s.Scheduler = goutils.NewBackgroundStoppableWorkers(func(ctx context.Context) {
s.runScheduler(ctx, tkr, config)
})
} else {
s.logger.Info("Sync Disabled")
}

// if datacapture is enabled, kick off a go routine to handle disk space filling due to
Expand Down Expand Up @@ -261,7 +271,6 @@ func (s *Sync) runCloudConnManager(
s.cloudConn.conn = conn
s.cloudConn.connectivityStateEnabledConn = s.connToConnectivityState(conn)
s.cloudConn.client = s.clientConstructor(conn)
s.logger.Debug("cloud connection ready")
close(s.cloudConn.ready)
// now that we have a connection ...
break
Expand Down Expand Up @@ -490,7 +499,7 @@ func (s *Sync) runScheduler(ctx context.Context, tkr *clock.Ticker, config Confi
return
case <-s.cloudConn.ready:
if !readyLogged {
s.logger.Debug("data sync cloudconn is detected as ready ready!")
s.logger.Info("cloud connection ready")
readyLogged = true
}
}
Expand All @@ -503,13 +512,13 @@ func (s *Sync) runScheduler(ctx context.Context, tkr *clock.Ticker, config Confi
state := s.cloudConn.connectivityStateEnabledConn.GetState()
online := state == connectivity.Ready
if !online {
s.logger.Debugf("data manager: NOT syncing data to the cloud as it's cloud connection is in state: %s"+
s.logger.Infof("data manager: NOT syncing data to the cloud as it's cloud connection is in state: %s"+
"; waiting for it to be in state: %s", state, connectivity.Ready)
continue
}

if !shouldSync {
s.logger.Debug("data manager: NOT syncing data to the cloud as it's selective sync sensor is not ready to sync")
s.logger.Info("data manager: NOT syncing data to the cloud as it's selective sync sensor is not ready to sync")
continue
}

Expand Down

0 comments on commit 7bd41d3

Please sign in to comment.