Skip to content

Commit 92ad053

Browse files
zhanluxianshenMandssS
zhanluxianshen
authored andcommitted
Drop ioutil package.
Signed-off-by: zhanluxianshen <irelandabby883@gmail.com>
1 parent 44ca717 commit 92ad053

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

exec/executor_ssh.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ package exec
1919
import (
2020
"context"
2121
"fmt"
22-
"github.com/chaosblade-io/chaosblade-spec-go/log"
23-
"io/ioutil"
2422
"net"
23+
"os"
2524
"path"
2625
"strconv"
2726
"strings"
2827
"time"
2928

29+
"github.com/chaosblade-io/chaosblade-spec-go/log"
30+
3031
"github.com/chaosblade-io/chaosblade-exec-os/version"
3132

3233
"github.com/chaosblade-io/chaosblade-spec-go/spec"
@@ -284,7 +285,7 @@ func (c *SSHClient) connect() error {
284285
if c.Key == "" {
285286
auth = append(auth, ssh.Password(c.Password))
286287
} else {
287-
pemBytes, err := ioutil.ReadFile(c.Key)
288+
pemBytes, err := os.ReadFile(c.Key)
288289
if err != nil {
289290
return err
290291
}

exec/mem/mem.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ package mem
1919
import (
2020
"context"
2121
"fmt"
22-
"github.com/chaosblade-io/chaosblade-exec-os/exec"
23-
"github.com/chaosblade-io/chaosblade-spec-go/log"
24-
"io/ioutil"
2522
"math"
2623
"os"
2724
"path"
2825
"strconv"
2926
"time"
3027

28+
"github.com/chaosblade-io/chaosblade-exec-os/exec"
29+
"github.com/chaosblade-io/chaosblade-spec-go/log"
30+
3131
"github.com/chaosblade-io/chaosblade-spec-go/spec"
3232
"github.com/chaosblade-io/chaosblade-spec-go/util"
3333

@@ -209,7 +209,7 @@ func (ce *memExecutor) Exec(uid string, ctx context.Context, model *spec.ExpMode
209209
var err error
210210
memPercent, err = strconv.Atoi(memPercentStr)
211211
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)
213213
return spec.ResponseFailWithFlags(spec.ParameterIllegal, "mem-percent", memPercentStr, "it must be a positive integer")
214214
}
215215
if memPercent > 100 || memPercent < 0 {
@@ -296,8 +296,8 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat
296296
// adjust process oom_score_adj to avoid being killed
297297
if avoidBeingKilled {
298298
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 {
301301
log.Errorf(ctx, "run burn memory by %s mode failed, cannot edit the process oom_score_adj, %v", burnMemMode, err)
302302
}
303303
} else {
@@ -348,6 +348,6 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat
348348

349349
// stop burn mem
350350
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)
352352
return exec.Destroy(ctx, ce.channel, "mem load")
353353
}

0 commit comments

Comments
 (0)