Skip to content

Commit 19a1572

Browse files
Andrewmatildecwen0
andauthored
Fix issue about disk attack cannot work well in chaos-mesh:physical machine chaos (#236)
* add default value of PayloadProcessNum&FillByFAllocate Signed-off-by: andrewmatilde <[email protected]> * recover unit-test Signed-off-by: andrewmatilde <[email protected]> * recover unit-test Signed-off-by: andrewmatilde <[email protected]> * Enable fill | write in dir. Signed-off-by: andrewmatilde <[email protected]> * Enable fill | write in dir. Signed-off-by: andrewmatilde <[email protected]> * Enable fill | write in dir. Signed-off-by: andrewmatilde <[email protected]> * fix lint Signed-off-by: andrewmatilde <[email protected]> * fix log Signed-off-by: andrewmatilde <[email protected]> * ignore some unhandled errors & fix unexported returned value in exported function Signed-off-by: andrewmatilde <[email protected]> * fix deprecated function Signed-off-by: andrewmatilde <[email protected]> * complete async disk attack in server side Signed-off-by: andrewmatilde <[email protected]> * better input args type in command pool Signed-off-by: andrewmatilde <[email protected]> * complete test for command pool Signed-off-by: andrewmatilde <[email protected]> * add license Signed-off-by: andrewmatilde <[email protected]> * add license Signed-off-by: andrewmatilde <[email protected]> * fix comment Signed-off-by: andrewmatilde <[email protected]> * add output channel to pools Signed-off-by: andrewmatilde <[email protected]> * manually test & fix disk attack Signed-off-by: andrewmatilde <[email protected]> * fix ut in disk attack Signed-off-by: andrewmatilde <[email protected]> * fix Boilerplate header Signed-off-by: andrewmatilde <[email protected]> --------- Signed-off-by: andrewmatilde <[email protected]> Co-authored-by: Cwen Yin <[email protected]>
1 parent e7715f7 commit 19a1572

19 files changed

+540
-127
lines changed

go.mod

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/chaos-mesh/chaosd
22

33
require (
4+
github.com/Jeffail/tunny v0.1.4
45
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
56
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a
67
github.com/chaos-mesh/chaos-mesh v0.9.1-0.20220812140450-4bc7ef589c13
@@ -24,11 +25,13 @@ require (
2425
github.com/pkg/errors v0.9.1
2526
github.com/prometheus/client_golang v1.11.0
2627
github.com/robfig/cron/v3 v3.0.1
28+
github.com/samber/lo v1.37.0
29+
github.com/samber/mo v1.8.0
2730
github.com/segmentio/kafka-go v0.4.31
2831
github.com/shirou/gopsutil v3.21.11+incompatible
2932
github.com/spf13/cobra v1.4.0
3033
github.com/spf13/pflag v1.0.5
31-
github.com/stretchr/testify v1.7.2
34+
github.com/stretchr/testify v1.8.1
3235
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe
3336
github.com/swaggo/gin-swagger v1.5.0
3437
github.com/swaggo/swag v1.8.3
@@ -135,9 +138,10 @@ require (
135138
go.uber.org/dig v1.14.1 // indirect
136139
go.uber.org/multierr v1.8.0 // indirect
137140
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
141+
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
138142
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
139143
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
140-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
144+
golang.org/x/sync v0.1.0 // indirect
141145
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
142146
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
143147
golang.org/x/text v0.3.7 // indirect

go.sum

+16-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
7070
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
7171
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
7272
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
73+
github.com/Jeffail/tunny v0.1.4 h1:chtpdz+nUtaYQeCKlNBg6GycFF/kGVHOr6A3cmzTJXs=
74+
github.com/Jeffail/tunny v0.1.4/go.mod h1:P8xAx4XQl0xsuhjX1DtfaMDCSuavzdb2rwbd0lk+fvo=
7375
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
7476
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
7577
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
@@ -947,6 +949,10 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
947949
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
948950
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
949951
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
952+
github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw=
953+
github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA=
954+
github.com/samber/mo v1.8.0 h1:vYjHTfg14JF9tD2NLhpoUsRi9bjyRoYwa4+do0nvbVw=
955+
github.com/samber/mo v1.8.0/go.mod h1:BfkrCPuYzVG3ZljnZB783WIJIGk1mcZr9c9CPf8tAxs=
950956
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
951957
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
952958
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
@@ -1005,6 +1011,8 @@ github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag
10051011
github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10061012
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10071013
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1014+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
1015+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
10081016
github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
10091017
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
10101018
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
@@ -1013,8 +1021,11 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
10131021
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
10141022
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
10151023
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1016-
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
1024+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
10171025
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
1026+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1027+
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
1028+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
10181029
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
10191030
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc=
10201031
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w=
@@ -1169,6 +1180,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
11691180
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
11701181
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
11711182
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
1183+
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
1184+
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
11721185
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
11731186
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
11741187
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
@@ -1281,8 +1294,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
12811294
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
12821295
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
12831296
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1284-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
12851297
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1298+
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
1299+
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
12861300
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
12871301
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
12881302
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

pkg/core/disk.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package core
1616
import (
1717
"encoding/json"
1818
"fmt"
19-
"io/ioutil"
2019
"os"
2120
"path/filepath"
2221
"strconv"
@@ -90,6 +89,16 @@ func NewDiskOption() *DiskOption {
9089
}
9190
}
9291

92+
func NewDiskOptionForServer() *DiskOption {
93+
return &DiskOption{
94+
CommonAttackConfig: CommonAttackConfig{
95+
Kind: DiskServerAttack,
96+
},
97+
PayloadProcessNum: 1,
98+
FillByFallocate: true,
99+
}
100+
}
101+
93102
func (opt *DiskOption) PreProcess() (*DiskAttackConfig, error) {
94103
if err := opt.CommonAttackConfig.Validate(); err != nil {
95104
return nil, err
@@ -191,7 +200,7 @@ func initPath(opt *DiskOption) (string, error) {
191200
// check if Path of file is valid when Path is not empty
192201
if os.IsNotExist(err) {
193202
var b []byte
194-
if err := ioutil.WriteFile(opt.Path, b, 0600); err != nil {
203+
if err := os.WriteFile(opt.Path, b, 0600); err != nil {
195204
return "", err
196205
}
197206
if err := os.Remove(opt.Path); err != nil {

pkg/core/disk_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Chaos Mesh Authors.
1+
// Copyright 2023 Chaos Mesh Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -10,6 +10,7 @@
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
13+
1314
package core
1415

1516
import (

pkg/core/experiment.go

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const (
3535
NetworkAttack = "network"
3636
StressAttack = "stress"
3737
DiskAttack = "disk"
38+
DiskServerAttack = "disk-server"
3839
ClockAttack = "clock"
3940
HostAttack = "host"
4041
JVMAttack = "jvm"
@@ -109,6 +110,8 @@ func GetAttackByKind(kind string) *AttackConfig {
109110
attackConfig = &StressCommand{}
110111
case DiskAttack:
111112
attackConfig = &DiskAttackConfig{}
113+
case DiskServerAttack:
114+
attackConfig = &DiskAttackConfig{}
112115
case JVMAttack:
113116
attackConfig = &JVMCommand{}
114117
case ClockAttack:

pkg/core/jvm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ type JVMStressSpec struct {
141141
// only when SQL match the Database, Table and SQLType, chaosd will inject fault
142142
// for example:
143143
//
144-
// SQL is "select * from test.t1",
145-
// only when ((Database == "test" || Database == "") && (Table == "t1" || Table == "") && (SQLType == "select" || SQLType == "")) is true, chaosd will inject fault
144+
// SQL is "select * from test.t1",
145+
// only when ((Database == "test" || Database == "") && (Table == "t1" || Table == "") && (SQLType == "select" || SQLType == "")) is true, chaosd will inject fault
146146
type JVMMySQLSpec struct {
147147
// the version of mysql-connector-java, only support 5.X.X(set to 5) and 8.X.X(set to 8) now
148148
MySQLConnectorVersion string `json:"mysql-connector-version,omitempty"`

pkg/server/chaosd/disk.go

+57-71
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414
package chaosd
1515

1616
import (
17+
"context"
1718
"fmt"
1819
"os"
19-
"os/exec"
20-
"sync"
21-
"time"
2220

2321
"github.com/hashicorp/go-multierror"
2422
"github.com/pingcap/log"
2523
"go.uber.org/zap"
2624

27-
"github.com/chaos-mesh/chaosd/pkg/server/utils"
25+
pkgUtils "github.com/chaos-mesh/chaosd/pkg/utils"
2826

2927
"github.com/chaos-mesh/chaosd/pkg/core"
3028
)
@@ -33,88 +31,71 @@ type diskAttack struct{}
3331

3432
var DiskAttack AttackType = diskAttack{}
3533

36-
func (disk diskAttack) Attack(options core.AttackConfig, env Environment) error {
34+
func handleDiskAttackOutput(output []byte, err error, c chan interface{}) {
35+
if err != nil {
36+
log.Error(string(output), zap.Error(err))
37+
c <- err
38+
}
39+
log.Info(string(output))
40+
}
41+
42+
func (diskAttack) Attack(options core.AttackConfig, env Environment) error {
43+
err := ApplyDiskAttack(options, env)
44+
if err != nil {
45+
return err
46+
}
47+
return nil
48+
}
49+
50+
func handleOutputChannelError(c chan interface{}) error {
51+
close(c)
52+
var multiErrs error
53+
for i := range c {
54+
if err, ok := i.(error); ok {
55+
multiErrs = multierror.Append(multiErrs, err)
56+
}
57+
}
58+
if multiErrs != nil {
59+
return multiErrs
60+
}
61+
return nil
62+
}
63+
64+
func ApplyDiskAttack(options core.AttackConfig, env Environment) error {
3765
var attackConf *core.DiskAttackConfig
3866
var ok bool
3967
if attackConf, ok = options.(*core.DiskAttackConfig); !ok {
4068
return fmt.Errorf("AttackConfig -> *DiskAttackConfig meet error")
4169
}
70+
poolSize := getPoolSize(attackConf)
71+
outputChan := make(chan interface{}, poolSize+1)
4272
if attackConf.Action == core.DiskFillAction {
43-
if attackConf.FAllocateOption != nil {
44-
cmd := core.FAllocateCommand.Unmarshal(*attackConf.FAllocateOption)
45-
output, err := cmd.CombinedOutput()
46-
47-
if err != nil {
48-
log.Error(string(output), zap.Error(err))
49-
return err
50-
}
51-
log.Info(string(output))
52-
return nil
53-
}
54-
55-
for _, DdOption := range *attackConf.DdOptions {
56-
cmd := core.DdCommand.Unmarshal(DdOption)
57-
output, err := cmd.CombinedOutput()
58-
59-
if err != nil {
60-
log.Error(string(output), zap.Error(err))
61-
return err
62-
}
63-
log.Info(string(output))
64-
}
65-
return nil
73+
cmdPool := pkgUtils.NewCommandPools(context.Background(), nil, poolSize)
74+
env.Chaos.CmdPools[env.AttackUid] = cmdPool
75+
fillDisk(attackConf, cmdPool, NewOutputHandler(handleDiskAttackOutput, outputChan))
76+
cmdPool.Wait()
77+
cmdPool.Close()
78+
return handleOutputChannelError(outputChan)
6679
}
6780

6881
if attackConf.DdOptions != nil {
69-
duration, _ := options.ScheduleDuration()
70-
var deadline <-chan time.Time
71-
if duration != nil {
72-
deadline = time.After(*duration)
73-
}
74-
75-
if len(*attackConf.DdOptions) == 0 {
76-
return nil
77-
}
78-
rest := (*attackConf.DdOptions)[len(*attackConf.DdOptions)-1]
79-
*attackConf.DdOptions = (*attackConf.DdOptions)[:len(*attackConf.DdOptions)-1]
80-
81-
cmd := core.DdCommand.Unmarshal(rest)
82-
err := utils.ExecWithDeadline(deadline, cmd)
83-
if err != nil {
84-
return err
82+
var cmdPool *pkgUtils.CommandPools
83+
deadline := getDeadline(options)
84+
if deadline != nil {
85+
cmdPool = pkgUtils.NewCommandPools(context.Background(), deadline, poolSize)
8586
}
87+
cmdPool = pkgUtils.NewCommandPools(context.Background(), nil, poolSize)
88+
env.Chaos.CmdPools[env.AttackUid] = cmdPool
8689

87-
var wg sync.WaitGroup
88-
var mu sync.Mutex
89-
var errs error
90-
wg.Add(len(*attackConf.DdOptions))
91-
for _, ddOpt := range *attackConf.DdOptions {
92-
cmd := core.DdCommand.Unmarshal(ddOpt)
93-
94-
go func(cmd *exec.Cmd) {
95-
defer wg.Done()
96-
err := utils.ExecWithDeadline(deadline, cmd)
97-
if err != nil {
98-
log.Error(cmd.String(), zap.Error(err))
99-
mu.Lock()
100-
defer mu.Unlock()
101-
errs = multierror.Append(errs, err)
102-
return
103-
}
104-
}(cmd)
105-
}
106-
107-
wg.Wait()
108-
109-
if errs != nil {
110-
return errs
111-
}
90+
applyPayload(attackConf, cmdPool, NewOutputHandler(handleDiskAttackOutput, outputChan))
91+
cmdPool.Wait()
92+
cmdPool.Close()
93+
return handleOutputChannelError(outputChan)
11294
}
11395
return nil
114-
11596
}
11697

117-
func (diskAttack) Recover(exp core.Experiment, _ Environment) error {
98+
func (diskAttack) Recover(exp core.Experiment, env Environment) error {
11899
attackConfig, err := exp.GetRequestCommand()
119100
if err != nil {
120101
return err
@@ -127,5 +108,10 @@ func (diskAttack) Recover(exp core.Experiment, _ Environment) error {
127108
log.Warn(fmt.Sprintf("recover disk: remove %s failed", config.Path), zap.Error(err))
128109
}
129110
}
111+
112+
if cmdPool, ok := env.Chaos.CmdPools[exp.Uid]; ok {
113+
cmdPool.Close()
114+
}
115+
130116
return nil
131117
}

0 commit comments

Comments
 (0)