15112: Add config option to save list of lost blocks to a file.
[arvados.git] / services / keep-balance / server.go
index 613a2f7d3c3da2e6c466ec8ac9345a9e2e70775e..894056c9f27756c9f452f904568d53f88f433c74 100644 (file)
@@ -57,6 +57,10 @@ type Config struct {
 
        // Timeout for outgoing http request/response cycle.
        RequestTimeout arvados.Duration
+
+       // Destination filename for the list of lost block hashes, one
+       // per line. Updated atomically during each successful run.
+       LostBlocksFile string
 }
 
 // RunOptions controls runtime behavior. The flags/options that belong
@@ -70,8 +74,8 @@ type RunOptions struct {
        Once        bool
        CommitPulls bool
        CommitTrash bool
-       Logger      *logrus.Logger
-       Dumper      *logrus.Logger
+       Logger      logrus.FieldLogger
+       Dumper      logrus.FieldLogger
 
        // SafeRendezvousState from the most recent balance operation,
        // or "" if unknown. If this changes from one run to the next,
@@ -86,8 +90,8 @@ type Server struct {
        metrics    *metrics
        listening  string // for tests
 
-       Logger *logrus.Logger
-       Dumper *logrus.Logger
+       Logger logrus.FieldLogger
+       Dumper logrus.FieldLogger
 }
 
 // NewServer returns a new Server that runs Balancers using the given
@@ -142,9 +146,10 @@ func (srv *Server) start() error {
 
 func (srv *Server) Run() (*Balancer, error) {
        bal := &Balancer{
-               Logger:  srv.Logger,
-               Dumper:  srv.Dumper,
-               Metrics: srv.metrics,
+               Logger:         srv.Logger,
+               Dumper:         srv.Dumper,
+               Metrics:        srv.metrics,
+               LostBlocksFile: srv.config.LostBlocksFile,
        }
        var err error
        srv.runOptions, err = bal.Run(srv.config, srv.runOptions)