@@ -19,15 +19,15 @@ package mem
19
19
import (
20
20
"context"
21
21
"fmt"
22
- "github.com/chaosblade-io/chaosblade-exec-os/exec"
23
- "github.com/chaosblade-io/chaosblade-spec-go/log"
24
- "io/ioutil"
25
22
"math"
26
23
"os"
27
24
"path"
28
25
"strconv"
29
26
"time"
30
27
28
+ "github.com/chaosblade-io/chaosblade-exec-os/exec"
29
+ "github.com/chaosblade-io/chaosblade-spec-go/log"
30
+
31
31
"github.com/chaosblade-io/chaosblade-spec-go/spec"
32
32
"github.com/chaosblade-io/chaosblade-spec-go/util"
33
33
@@ -209,7 +209,7 @@ func (ce *memExecutor) Exec(uid string, ctx context.Context, model *spec.ExpMode
209
209
var err error
210
210
memPercent , err = strconv .Atoi (memPercentStr )
211
211
if err != nil {
212
- log .Errorf (ctx ,"`%s`: mem-percent must be a positive integer" , memPercentStr )
212
+ log .Errorf (ctx , "`%s`: mem-percent must be a positive integer" , memPercentStr )
213
213
return spec .ResponseFailWithFlags (spec .ParameterIllegal , "mem-percent" , memPercentStr , "it must be a positive integer" )
214
214
}
215
215
if memPercent > 100 || memPercent < 0 {
@@ -296,8 +296,8 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat
296
296
// adjust process oom_score_adj to avoid being killed
297
297
if avoidBeingKilled {
298
298
scoreAdjFile := fmt .Sprintf (processOOMAdj , os .Getpid ())
299
- if _ , err := os .Stat (scoreAdjFile ); err == nil || os .IsExist (err ) {
300
- if err := ioutil .WriteFile (scoreAdjFile , []byte (oomMinAdj ), 0644 ); err != nil {
299
+ if _ , err := os .Stat (scoreAdjFile ); err == nil || os .IsExist (err ) {
300
+ if err := os .WriteFile (scoreAdjFile , []byte (oomMinAdj ), 0644 ); err != nil {
301
301
log .Errorf (ctx , "run burn memory by %s mode failed, cannot edit the process oom_score_adj, %v" , burnMemMode , err )
302
302
}
303
303
} else {
@@ -348,6 +348,6 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat
348
348
349
349
// stop burn mem
350
350
func (ce * memExecutor ) stop (ctx context.Context , burnMemMode string ) * spec.Response {
351
- ctx = context .WithValue (ctx ,"bin" , BurnMemBin )
351
+ ctx = context .WithValue (ctx , "bin" , BurnMemBin )
352
352
return exec .Destroy (ctx , ce .channel , "mem load" )
353
353
}
0 commit comments