@@ -14,6 +14,7 @@ import (
14
14
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
15
15
"github.com/cockroachdb/cockroach/pkg/roachprod/failureinjection/failures"
16
16
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
17
+ "github.com/cockroachdb/errors"
17
18
)
18
19
19
20
// TODO(darryl): Once the failure injection library is a first class citizen of roachtest,
@@ -25,7 +26,7 @@ type DiskStaller interface {
25
26
Stall (ctx context.Context , nodes option.NodeListOption )
26
27
StallCycle (ctx context.Context , nodes option.NodeListOption , stallDuration , unstallDuration time.Duration )
27
28
Slow (ctx context.Context , nodes option.NodeListOption , bytesPerSecond int )
28
- Unstall (ctx context.Context , nodes option.NodeListOption )
29
+ Unstall (ctx context.Context , nodes option.NodeListOption ) error
29
30
DataDir () string
30
31
LogDir () string
31
32
}
@@ -34,16 +35,17 @@ type NoopDiskStaller struct{}
34
35
35
36
var _ DiskStaller = NoopDiskStaller {}
36
37
37
- func (n NoopDiskStaller ) Cleanup (ctx context.Context ) {}
38
- func (n NoopDiskStaller ) DataDir () string { return "{store-dir}" }
39
- func (n NoopDiskStaller ) LogDir () string { return "logs" }
40
- func (n NoopDiskStaller ) Setup (ctx context.Context ) {}
41
- func (n NoopDiskStaller ) Slow (_ context.Context , _ option.NodeListOption , _ int ) {}
42
- func (n NoopDiskStaller ) Stall (_ context.Context , _ option.NodeListOption ) {}
38
+ func (n NoopDiskStaller ) Cleanup (ctx context.Context ) {}
39
+ func (n NoopDiskStaller ) DataDir () string { return "{store-dir}" }
40
+ func (n NoopDiskStaller ) LogDir () string { return "logs" }
41
+ func (n NoopDiskStaller ) Setup (ctx context.Context ) {}
42
+ func (n NoopDiskStaller ) Slow (_ context.Context , _ option.NodeListOption , _ int ) {}
43
+ func (n NoopDiskStaller ) Stall (_ context.Context , _ option.NodeListOption ) {}
43
44
func (n NoopDiskStaller ) StallCycle (
44
45
_ context.Context , _ option.NodeListOption , _ , _ time.Duration ,
45
- ) {}
46
- func (n NoopDiskStaller ) Unstall (_ context.Context , _ option.NodeListOption ) {}
46
+ ) {
47
+ }
48
+ func (n NoopDiskStaller ) Unstall (_ context.Context , _ option.NodeListOption ) error { return nil }
47
49
48
50
type Fataler interface {
49
51
Fatal (args ... interface {})
@@ -140,11 +142,12 @@ func (s *cgroupDiskStaller) Slow(
140
142
}
141
143
}
142
144
143
- func (s * cgroupDiskStaller ) Unstall (ctx context.Context , nodes option.NodeListOption ) {
145
+ func (s * cgroupDiskStaller ) Unstall (ctx context.Context , nodes option.NodeListOption ) error {
144
146
l := newDiskStallLogger (s .f .L (), nodes , "Unstall" )
145
- if err := s .Failer .Recover (ctx , l ); err != nil {
146
- s .f .Fatalf ("failed to unstall disk: %s" , err )
147
- }
147
+ // cgroup may fail when unstalling the disk, usually because the node already
148
+ // fataled and the cgroup is no longer available. Return the error and let
149
+ // the caller decide if a node fatal is expected or not.
150
+ return errors .Wrap (s .Failer .Recover (ctx , l ), "failed to unstall disk" )
148
151
}
149
152
150
153
type dmsetupDiskStaller struct {
@@ -211,11 +214,13 @@ func (s *dmsetupDiskStaller) Slow(
211
214
s .f .Fatal ("Slow is not supported for dmsetupDiskStaller" )
212
215
}
213
216
214
- func (s * dmsetupDiskStaller ) Unstall (ctx context.Context , nodes option.NodeListOption ) {
217
+ func (s * dmsetupDiskStaller ) Unstall (ctx context.Context , nodes option.NodeListOption ) error {
215
218
l := newDiskStallLogger (s .f .L (), nodes , "Unstall" )
219
+ // Any unstall error for dmsetup is unexpected and should fail the test.
216
220
if err := s .Failer .Recover (ctx , l ); err != nil {
217
221
s .f .Fatalf ("failed to unstall disk: %s" , err )
218
222
}
223
+ return nil
219
224
}
220
225
221
226
func (s * dmsetupDiskStaller ) DataDir () string { return "{store-dir}" }
0 commit comments