Skip to content

Commit b06dcfb

Browse files
committed
Reduce logs for failed nsenter file descriptor transfer from error to warning.
We have tests that will trigger such a condition by purposely killing the nsenter agent. The error logging would cause the test to fail. Reduce to a warning instead. Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
1 parent 67de6f8 commit b06dcfb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

nsenter/event.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,19 @@ func (e *NSenterEvent) getRespFileDescriptors(pipe *os.File) ([]int, error) {
149149
oob := make([]byte, getOobBufferSize())
150150

151151
// Recvmsg will unblock when the nsenter agent sends the file descriptor(s),
152-
// if it dies, or if the timeout expires.
152+
// if it dies, or if the timeout expires. If the nsenter agent has no file
153+
// descriptors to send, it will send a zero-length SCM_RIGHTS message.
153154
_, oobn, _, _, err := unix.Recvmsg(int(pipe.Fd()), nil, oob, 0)
154155
if err != nil {
155-
logrus.Warnf("Error receiving fd via SCM_RIGHTS: %v", err)
156+
logrus.Warnf("failed to receive fd(s) via SCM_RIGHTS: %v", err)
156157
return nil, fmt.Errorf("error receiving fd via SCM_RIGHTS: %v", err)
157158
}
158159

159160
// Parse the control message to extract the file descriptors
160161
oob = oob[:oobn]
161162
msgs, err := unix.ParseSocketControlMessage(oob)
162163
if err != nil {
163-
logrus.Errorf("Error parsing socket control message (oobn=%d): %v", oobn, err)
164+
logrus.Warnf("failed to parse socket control message (oobn=%d): %v", oobn, err)
164165
return nil, fmt.Errorf("error parsing socket control message: %v", err)
165166
}
166167

@@ -170,7 +171,7 @@ func (e *NSenterEvent) getRespFileDescriptors(pipe *os.File) ([]int, error) {
170171
if msg.Header.Level == unix.SOL_SOCKET && msg.Header.Type == unix.SCM_RIGHTS {
171172
fds, err = unix.ParseUnixRights(&msg)
172173
if err != nil {
173-
logrus.Errorf("Error parsing Unix rights: %v", err)
174+
logrus.Warnf("failed to parse Unix rights: %v", err)
174175
return nil, fmt.Errorf("error parsing Unix rights: %v", err)
175176
}
176177
break

0 commit comments

Comments
 (0)