Skip to content

Commit

Permalink
criu: do not add log file into error message
Browse files Browse the repository at this point in the history
As we now log the log file name in logCriuErrors.

While at it, there is no need to use var.String() with %s as it is done
by the runtime.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Aug 3, 2023
1 parent c77aaa3 commit 3867693
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions libcontainer/criu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,6 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
return err
}

var logPath string
if opts != nil {
logPath = filepath.Join(opts.WorkDirectory, req.GetOpts().GetLogFile())
} else {
// For the VERSION RPC 'opts' is set to 'nil' and therefore
// opts.WorkDirectory does not exist. Set logPath to "".
logPath = ""
}
criuClient := os.NewFile(uintptr(fds[0]), "criu-transport-client")
criuClientFileCon, err := net.FileConn(criuClient)
criuClient.Close()
Expand Down Expand Up @@ -1027,12 +1019,11 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
if err != nil {
return err
}
t := resp.GetType()
if !resp.GetSuccess() {
typeString := req.GetType().String()
return fmt.Errorf("criu failed: type %s errno %d\nlog file: %s", typeString, resp.GetCrErrno(), logPath)
return fmt.Errorf("criu failed: type %s errno %d", t, resp.GetCrErrno())
}

t := resp.GetType()
switch t {
case criurpc.CriuReqType_FEATURE_CHECK:
logrus.Debugf("Feature check says: %s", resp)
Expand Down Expand Up @@ -1080,7 +1071,7 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
// If we got the message CriuReqType_PRE_DUMP it means
// CRIU was successful and we need to forcefully stop CRIU
if !criuProcessState.Success() && *req.Type != criurpc.CriuReqType_PRE_DUMP {
return fmt.Errorf("criu failed: %s\nlog file: %s", criuProcessState.String(), logPath)
return fmt.Errorf("criu failed: %s", criuProcessState)
}
return nil
}
Expand Down

0 comments on commit 3867693

Please sign in to comment.