multi: add minimum disk space check
This commit is contained in:
9 files changed
+142
-2
No files matched your search
+26
-1
@@ -1,6 +1,7 @@
|
||||
package lncfg
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
@@ -23,11 +24,27 @@ var (
|
||||
// the lnd runs.
|
||||
type HealthCheckConfig struct {
|
||||
ChainCheck *CheckConfig `group:"chainbackend" namespace:"chainbackend"`
|
||||
|
||||
DiskCheck *DiskCheckConfig `group:"diskspace" namespace:"diskspace"`
|
||||
}
|
||||
|
||||
// Validate checks the values configured for our health checks.
|
||||
func (h *HealthCheckConfig) Validate() error {
|
||||
return h.ChainCheck.validate("chain backend")
|
||||
if err := h.ChainCheck.validate("chain backend"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := h.DiskCheck.validate("disk space"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if h.DiskCheck.RequiredRemaining < 0 ||
|
||||
h.DiskCheck.RequiredRemaining >= 1 {
|
||||
|
||||
return errors.New("disk required ratio must be in [0:1)")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type CheckConfig struct {
|
||||
@@ -63,3 +80,11 @@ func (c *CheckConfig) validate(name string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DiskCheckConfig contains configuration for ensuring that our node has
|
||||
// sufficient disk space.
|
||||
type DiskCheckConfig struct {
|
||||
RequiredRemaining float64 `long:"diskrequired" description:"The minimum ratio of free disk space to total capacity that we allow before shutting lnd down safely."`
|
||||
|
||||
*CheckConfig
|
||||
}
|
||||
Reference in new issue
Block a user