• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13236757158

10 Feb 2025 08:39AM UTC coverage: 57.649% (-1.2%) from 58.815%
13236757158

Pull #9493

github

ziggie1984
lncli: for some cmds we don't replace the data of the response.

For some cmds it is not very practical to replace the json output
because we might pipe it into other commands. For example when
creating the route we want to pipe it into sendtoRoute.
Pull Request #9493: For some lncli cmds we should not replace the content with other data

0 of 9 new or added lines in 2 files covered. (0.0%)

19535 existing lines in 252 files now uncovered.

103517 of 179563 relevant lines covered (57.65%)

24878.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lncfg/healthcheck.go
1
package lncfg
2

3
import (
4
        "errors"
5
        "fmt"
6
        "time"
7
)
8

9
var (
10
        // MinHealthCheckInterval is the minimum interval we allow between
11
        // health checks.
12
        MinHealthCheckInterval = time.Minute
13

14
        // MinHealthCheckTimeout is the minimum timeout we allow for health
15
        // check calls.
16
        MinHealthCheckTimeout = time.Second
17

18
        // MinHealthCheckBackoff is the minimum back off we allow between health
19
        // check retries.
20
        MinHealthCheckBackoff = time.Second
21
)
22

23
// HealthCheckConfig contains the configuration for the different health checks
24
// the lnd runs.
25
//
26
//nolint:ll
27
type HealthCheckConfig struct {
28
        ChainCheck *CheckConfig `group:"chainbackend" namespace:"chainbackend"`
29

30
        DiskCheck *DiskCheckConfig `group:"diskspace" namespace:"diskspace"`
31

32
        TLSCheck *CheckConfig `group:"tls" namespace:"tls"`
33

34
        TorConnection *CheckConfig `group:"torconnection" namespace:"torconnection"`
35

36
        RemoteSigner *CheckConfig `group:"remotesigner" namespace:"remotesigner"`
37

38
        LeaderCheck *CheckConfig `group:"leader" namespace:"leader"`
39
}
40

41
// Validate checks the values configured for our health checks.
UNCOV
42
func (h *HealthCheckConfig) Validate() error {
×
UNCOV
43
        if err := h.ChainCheck.validate("chain backend"); err != nil {
×
44
                return err
×
45
        }
×
46

UNCOV
47
        if err := h.DiskCheck.validate("disk space"); err != nil {
×
48
                return err
×
49
        }
×
50

UNCOV
51
        if err := h.TLSCheck.validate("tls"); err != nil {
×
52
                return err
×
53
        }
×
54

UNCOV
55
        if h.DiskCheck.RequiredRemaining < 0 ||
×
UNCOV
56
                h.DiskCheck.RequiredRemaining >= 1 {
×
57

×
58
                return errors.New("disk required ratio must be in [0:1)")
×
59
        }
×
60

UNCOV
61
        if err := h.TorConnection.validate("tor connection"); err != nil {
×
62
                return err
×
63
        }
×
64

UNCOV
65
        return nil
×
66
}
67

68
type CheckConfig struct {
69
        Interval time.Duration `long:"interval" description:"How often to run a health check."`
70

71
        Attempts int `long:"attempts" description:"The number of calls we will make for the check before failing. Set this value to 0 to disable a check."`
72

73
        Timeout time.Duration `long:"timeout" description:"The amount of time we allow the health check to take before failing due to timeout."`
74

75
        Backoff time.Duration `long:"backoff" description:"The amount of time to back-off between failed health checks."`
76
}
77

78
// validate checks the values in a health check config entry if it is enabled.
UNCOV
79
func (c *CheckConfig) validate(name string) error {
×
UNCOV
80
        if c.Attempts == 0 {
×
UNCOV
81
                return nil
×
UNCOV
82
        }
×
83

UNCOV
84
        if c.Backoff < MinHealthCheckBackoff {
×
85
                return fmt.Errorf("%v backoff: %v below minimum: %v", name,
×
86
                        c.Backoff, MinHealthCheckBackoff)
×
87
        }
×
88

UNCOV
89
        if c.Timeout < MinHealthCheckTimeout {
×
90
                return fmt.Errorf("%v timeout: %v below minimum: %v", name,
×
91
                        c.Timeout, MinHealthCheckTimeout)
×
92
        }
×
93

UNCOV
94
        if c.Interval < MinHealthCheckInterval {
×
95
                return fmt.Errorf("%v interval: %v below minimum: %v", name,
×
96
                        c.Interval, MinHealthCheckInterval)
×
97
        }
×
98

UNCOV
99
        return nil
×
100
}
101

102
// DiskCheckConfig contains configuration for ensuring that our node has
103
// sufficient disk space.
104
type DiskCheckConfig struct {
105
        RequiredRemaining float64 `long:"diskrequired" description:"The minimum ratio of free disk space to total capacity that we allow before shutting lnd down safely."`
106

107
        *CheckConfig
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc