Skip to content

Commit

Permalink
Merge pull request #482 from mlycore/fix-check-disk
Browse files Browse the repository at this point in the history
fix: create backup path before checking disk
  • Loading branch information
tristaZero committed Dec 18, 2023
2 parents 7600684 + 05739d0 commit 586c058
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pitr/agent/internal/handler/diskspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func DiskSpace(ctx *fiber.Ctx) error {
return fmt.Errorf("invalid parameter, err wrap: %w", err)
}

if err := os.MkdirAll(in.DiskPath, 0755); err != nil {
return fmt.Errorf("mkdir [%s] failure, err wrap: %w", in.DiskPath, err)
}

// show disk space
cmd := fmt.Sprintf("df -h %s", in.DiskPath)
output, err := cmds.Exec(os.Getenv("SHELL"), cmd)
Expand Down
2 changes: 1 addition & 1 deletion pitr/agent/pkg/cmds/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func Exec(name string, args ...string) (string, error) {

if err = cmd.Wait(); err != nil {
if ee, ok := err.(*exec.ExitError); ok {
return "", fmt.Errorf("exec failure[ee=%s,stdout=%s], wrap:%w", ee, string(reader), cons.CmdOperateFailed)
return "", fmt.Errorf("exec failure[ee=%s,stdout=%s,stderr=%s], wrap:%w", ee, string(reader), string(ereader), cons.CmdOperateFailed)
}
return "", fmt.Errorf("%s err: %s", cmd.String(), string(ereader))
}
Expand Down

0 comments on commit 586c058

Please sign in to comment.