Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ioutil package. #170

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions exec/executor_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ package exec
import (
"context"
"fmt"
"github.com/chaosblade-io/chaosblade-spec-go/log"
"io/ioutil"
"net"
"os"
"path"
"strconv"
"strings"
"time"

"github.com/chaosblade-io/chaosblade-spec-go/log"

"github.com/chaosblade-io/chaosblade-exec-os/version"

"github.com/chaosblade-io/chaosblade-spec-go/spec"
Expand Down Expand Up @@ -284,7 +285,7 @@ func (c *SSHClient) connect() error {
if c.Key == "" {
auth = append(auth, ssh.Password(c.Password))
} else {
pemBytes, err := ioutil.ReadFile(c.Key)
pemBytes, err := os.ReadFile(c.Key)
if err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions exec/mem/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ package mem
import (
"context"
"fmt"
"github.com/chaosblade-io/chaosblade-exec-os/exec"
"github.com/chaosblade-io/chaosblade-spec-go/log"
"io/ioutil"
"math"
"os"
"path"
"strconv"
"time"

"github.com/chaosblade-io/chaosblade-exec-os/exec"
"github.com/chaosblade-io/chaosblade-spec-go/log"

"github.com/chaosblade-io/chaosblade-spec-go/spec"
"github.com/chaosblade-io/chaosblade-spec-go/util"

Expand Down Expand Up @@ -209,7 +209,7 @@ func (ce *memExecutor) Exec(uid string, ctx context.Context, model *spec.ExpMode
var err error
memPercent, err = strconv.Atoi(memPercentStr)
if err != nil {
log.Errorf(ctx,"`%s`: mem-percent must be a positive integer", memPercentStr)
log.Errorf(ctx, "`%s`: mem-percent must be a positive integer", memPercentStr)
return spec.ResponseFailWithFlags(spec.ParameterIllegal, "mem-percent", memPercentStr, "it must be a positive integer")
}
if memPercent > 100 || memPercent < 0 {
Expand Down Expand Up @@ -296,8 +296,8 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat
// adjust process oom_score_adj to avoid being killed
if avoidBeingKilled {
scoreAdjFile := fmt.Sprintf(processOOMAdj, os.Getpid())
if _, err := os.Stat(scoreAdjFile); err == nil || os.IsExist(err) {
if err := ioutil.WriteFile(scoreAdjFile, []byte(oomMinAdj), 0644); err != nil {
if _, err := os.Stat(scoreAdjFile); err == nil || os.IsExist(err) {
if err := os.WriteFile(scoreAdjFile, []byte(oomMinAdj), 0644); err != nil {
log.Errorf(ctx, "run burn memory by %s mode failed, cannot edit the process oom_score_adj, %v", burnMemMode, err)
}
} else {
Expand Down Expand Up @@ -348,6 +348,6 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat

// stop burn mem
func (ce *memExecutor) stop(ctx context.Context, burnMemMode string) *spec.Response {
ctx = context.WithValue(ctx,"bin", BurnMemBin)
ctx = context.WithValue(ctx, "bin", BurnMemBin)
return exec.Destroy(ctx, ce.channel, "mem load")
}