Skip to content

Commit d6e427e

Browse files
committed
runc exec: avoid stuttering in error messages
An error from strconv.Atoi already contains the text it fails to parse. Because of that, errors look way too verbose, e.g.: [root@kir-rhat runc-tst]# ./runc exec --user 1:1:1 2345 true ERRO[0000] exec failed: parsing 1:1 as int for gid failed: strconv.Atoi: parsing "1:1": invalid syntax With this patch, the error looks like this now: [root@kir-rhat runc]# ./runc exec --user 1:1:1 2345 true ERRO[0000] exec failed: bad gid: strconv.Atoi: parsing "1:1": invalid syntax Still not awesome, but better. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent a6d46ed commit d6e427e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
251251
if len(u) > 1 {
252252
gid, err := strconv.Atoi(u[1])
253253
if err != nil {
254-
return nil, fmt.Errorf("parsing %s as int for gid failed: %w", u[1], err)
254+
return nil, fmt.Errorf("bad gid: %w", err)
255255
}
256256
p.User.GID = uint32(gid)
257257
}
258258
uid, err := strconv.Atoi(u[0])
259259
if err != nil {
260-
return nil, fmt.Errorf("parsing %s as int for uid failed: %w", u[0], err)
260+
return nil, fmt.Errorf("bad uid: %w", err)
261261
}
262262
p.User.UID = uint32(uid)
263263
}

0 commit comments

Comments
 (0)