-
Notifications
You must be signed in to change notification settings - Fork 358
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
do not log error in the syscall crate #1973
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a72c615
do not log error for mount in specific cases
yihuaf 085f951
fix the review
yihuaf da5ccb3
fix review
yihuaf ecf9f8d
clean up the logs in the syscall module
yihuaf e86ae4d
update toolchain to rust 1.70
yihuaf 15c7c56
fix new lint
yihuaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,14 +349,10 @@ impl Syscall for LinuxSyscall { | |
/// Disassociate parts of execution context | ||
// see https://man7.org/linux/man-pages/man2/unshare.2.html for more information | ||
fn unshare(&self, flags: CloneFlags) -> Result<()> { | ||
unshare(flags).map_err(|err| { | ||
tracing::error!(?err, ?flags, "failed to unshare"); | ||
err | ||
})?; | ||
unshare(flags)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Set capabilities for container process | ||
fn set_capability(&self, cset: CapSet, value: &CapsHashSet) -> Result<()> { | ||
match cset { | ||
|
@@ -382,10 +378,7 @@ impl Syscall for LinuxSyscall { | |
|
||
/// Sets hostname for process | ||
fn set_hostname(&self, hostname: &str) -> Result<()> { | ||
sethostname(hostname).map_err(|err| { | ||
tracing::error!(?hostname, "failed to set hostname"); | ||
err | ||
})?; | ||
sethostname(hostname)?; | ||
Ok(()) | ||
} | ||
|
||
|
@@ -396,15 +389,9 @@ impl Syscall for LinuxSyscall { | |
let len = domainname.len(); | ||
match unsafe { setdomainname(ptr, len) } { | ||
0 => Ok(()), | ||
-1 => { | ||
tracing::error!(?domainname, "failed to set domainname"); | ||
Err(nix::Error::last()) | ||
} | ||
-1 => Err(nix::Error::last()), | ||
|
||
_ => { | ||
tracing::error!(?domainname, "failed to set domainname for unknown reason"); | ||
Err(nix::Error::UnknownErrno) | ||
} | ||
_ => Err(nix::Error::UnknownErrno), | ||
}?; | ||
|
||
Ok(()) | ||
|
@@ -425,14 +412,8 @@ impl Syscall for LinuxSyscall { | |
|
||
match res { | ||
0 => Ok(()), | ||
-1 => { | ||
tracing::error!(?res, rlimit = ?rlimit.typ(), "failed to set rlimit"); | ||
Err(SyscallError::Nix(nix::Error::last())) | ||
} | ||
_ => { | ||
tracing::error!(?res, rlimit = ?rlimit.typ(), "failed to set rlimit for unknown reason"); | ||
Err(SyscallError::Nix(nix::Error::UnknownErrno)) | ||
} | ||
-1 => Err(SyscallError::Nix(nix::Error::last())), | ||
_ => Err(SyscallError::Nix(nix::Error::UnknownErrno)), | ||
}?; | ||
|
||
Ok(()) | ||
|
@@ -473,10 +454,7 @@ impl Syscall for LinuxSyscall { | |
} | ||
|
||
fn chroot(&self, path: &Path) -> Result<()> { | ||
unistd::chroot(path).map_err(|err| { | ||
tracing::error!(?err, ?path, "failed to chroot"); | ||
err | ||
})?; | ||
unistd::chroot(path)?; | ||
|
||
Ok(()) | ||
} | ||
|
@@ -489,41 +467,24 @@ impl Syscall for LinuxSyscall { | |
flags: MsFlags, | ||
data: Option<&str>, | ||
) -> Result<()> { | ||
mount(source, target, fstype, flags, data).map_err(|err| { | ||
tracing::error!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any need to bring this tracing to the callers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, 47bc859 |
||
"failed to mount {source:?} to {target:?} with fstype {fstype:?}, flags {flags:?}, data {data:?}: {err}", | ||
); | ||
err | ||
})?; | ||
|
||
mount(source, target, fstype, flags, data)?; | ||
Ok(()) | ||
} | ||
|
||
fn symlink(&self, original: &Path, link: &Path) -> Result<()> { | ||
symlink(original, link).map_err(|err| { | ||
tracing::error!("failed to create symlink from {original:?} to {link:?}: {err}"); | ||
err | ||
})?; | ||
symlink(original, link)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn mknod(&self, path: &Path, kind: SFlag, perm: Mode, dev: u64) -> Result<()> { | ||
mknod(path, kind, perm, dev).map_err(|errno| { | ||
tracing::error!( | ||
"failed to mknod {path:?}, kind {kind:?}, perm {perm:?}, dev {dev:?}: {errno}" | ||
); | ||
errno | ||
})?; | ||
mknod(path, kind, perm, dev)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn chown(&self, path: &Path, owner: Option<Uid>, group: Option<Gid>) -> Result<()> { | ||
chown(path, owner, group).map_err(|errno| { | ||
tracing::error!("failed to chown {path:?} to {owner:?}:{group:?}: {errno}"); | ||
errno | ||
})?; | ||
chown(path, owner, group)?; | ||
|
||
Ok(()) | ||
} | ||
|
@@ -552,16 +513,10 @@ impl Syscall for LinuxSyscall { | |
// kernel 5.11. If the kernel is older we emulate close_range in userspace. | ||
Self::emulate_close_range(preserve_fds) | ||
} | ||
e => { | ||
tracing::error!(errno = ?e, "failed to close_range"); | ||
Err(SyscallError::Nix(e)) | ||
} | ||
e => Err(SyscallError::Nix(e)), | ||
} | ||
} | ||
_ => { | ||
tracing::error!("failed to close_range unknown failure"); | ||
Err(SyscallError::Nix(nix::errno::Errno::UnknownErrno)) | ||
} | ||
_ => Err(SyscallError::Nix(nix::errno::Errno::UnknownErrno)), | ||
}?; | ||
|
||
Ok(()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[toolchain] | ||
profile="default" | ||
channel="1.69.0" | ||
channel="1.70.0" |
4 changes: 2 additions & 2 deletions
4
tests/rust-integration-tests/integration_test/src/utils/test_utils.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/rust-integration-tests/test_framework/src/conditional_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/rust-integration-tests/test_framework/src/test_manager.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, this call to
syscall::mount
is inside therootfs
module. Here, mount call failure indicates an actual failure, so we log the error here.