Skip to content
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 6 commits into from
Jun 5, 2023

Conversation

yihuaf
Copy link
Collaborator

@yihuaf yihuaf commented May 27, 2023

Related to #1974. The integration tests uses stderr to check if there are any errors. However, there are a number of cases where we want to mount with ENOTDIR or ENOENT error but we ignore these errors. Therefore, we do not want to log these errors. Otherwise the integration tests would be broken.

tag along: Bump rust version to 1.70 and fix some comments lint in integration test. As a side effect, this will trigger the integration validation test, so we can test the fix is actually working in CI.

@codecov-commenter
Copy link

codecov-commenter commented May 27, 2023

Codecov Report

Merging #1973 (15c7c56) into main (cb75d26) will decrease coverage by 0.02%.
The diff coverage is 21.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1973      +/-   ##
==========================================
- Coverage   65.28%   65.26%   -0.02%     
==========================================
  Files         129      129              
  Lines       14784    14800      +16     
==========================================
+ Hits         9651     9659       +8     
- Misses       5133     5141       +8     

@yihuaf yihuaf force-pushed the yihuaf/mount_error branch from 50d0306 to 4dbf3c0 Compare May 27, 2023 04:22
@yihuaf yihuaf requested review from utam0k, YJDoc2 and a team May 27, 2023 04:24
Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about tracing at the caller? It is beyond the role of the syscall mod to determine the type of error.

@yihuaf yihuaf force-pushed the yihuaf/mount_error branch from 4dbf3c0 to 802ae7a Compare May 30, 2023 17:10
@yihuaf
Copy link
Collaborator Author

yihuaf commented May 30, 2023

What about tracing at the caller? It is beyond the role of the syscall mod to determine the type of error.

I made the change for mount only in this PR to unblock the CI. We can extend this to all syscalls in this mod, but I'd like to do this in another PR.

@yihuaf yihuaf requested a review from utam0k May 30, 2023 17:11
@utam0k
Copy link
Member

utam0k commented May 31, 2023

We can extend this to all syscalls in this mod, but I'd like to do this in another PR.

I agree with you. we should do it.

@@ -489,13 +490,7 @@ impl Syscall for LinuxSyscall {
flags: MsFlags,
data: Option<&str>,
) -> Result<()> {
mount(source, target, fstype, flags, data).map_err(|err| {
tracing::error!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any need to bring this tracing to the callers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 47bc859

@yihuaf yihuaf force-pushed the yihuaf/mount_error branch from c50e0ef to 47bc859 Compare May 31, 2023 16:13
@yihuaf yihuaf requested a review from utam0k May 31, 2023 16:14
@yihuaf yihuaf self-assigned this May 31, 2023
@yihuaf yihuaf force-pushed the yihuaf/mount_error branch from 47bc859 to ecf9f8d Compare June 1, 2023 18:02
@yihuaf yihuaf changed the title do not log error for mount in specific cases do not log error in the syscall crate Jun 1, 2023
@yihuaf
Copy link
Collaborator Author

yihuaf commented Jun 1, 2023

@utam0k since this PR hasn't been merged, I went ahead and clean up the syscall crate as well. All the simpler wrappers no longer log error and logs only at the caller site. I kept the other more complex functions such as pivot_root and close_range alone, since it makes sense to log the error there.

@yihuaf yihuaf mentioned this pull request Jun 2, 2023
yihuaf added 2 commits June 3, 2023 18:30
@yihuaf
Copy link
Collaborator Author

yihuaf commented Jun 5, 2023

@utam0k Can we get a review if you have some time? I would like to merge this since this will unblock the integration validation test. I would also ask if it is possible to merge this in as is and address any reviews in a follow up PR since the integration validation CI is failing.

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Jun 5, 2023

Hey @yihuaf I think utam0k is unwell, so I'll take a look at this instead. The changes look ok, and as you said, if there are any issues, we can fix them in follow up PR. The only question I have is that this was opened because we logged errors in mount calls which makes the tests fail. However, I still see that we are doing tracing::error in the mount calls' map_err . I think you had removed it in one of the commits, but it got re-added for some reason. Can you please correct me if I'm wrong? Otherwise this is fine, I'll approve this then so it can unblock rest of the work.

@yihuaf
Copy link
Collaborator Author

yihuaf commented Jun 5, 2023

Hey @yihuaf I think utam0k is unwell, so I'll take a look at this instead. The changes look ok, and as you said, if there are any issues, we can fix them in follow up PR. The only question I have is that this was opened because we logged errors in mount calls which makes the tests fail. However, I still see that we are doing tracing::error in the mount calls' map_err . I think you had removed it in one of the commits, but it got re-added for some reason. Can you please correct me if I'm wrong? Otherwise this is fine, I'll approve this then so it can unblock rest of the work.

@YJDoc2 Thank you for taking a look. So issue that caused the integration failure is the syscall::mount logging error. It is removed in this PR (https://github.com/containers/youki/pull/1973/files#diff-b7916a1b6e425d0953faba26141b604a4b71e65782a58c78dd6f59f620916dccR470). The right thing to do is logging at the caller of the syscall::mount. There are a few places where the syscall::mount will return ENOTDIR or ENOENT, but the caller ignores these error because it is expected. This happens for example in the masked_path (https://github.com/containers/youki/pull/1973/files#diff-9773882fbf80be1f21b71393425530b52a9fc276cd89e5f0910d2435ca45fbb5R217). In this case, ENOENT is considered successful because a non-existent path is considered to be masked already (not accessible).

I believe all the tracing add you see are at the caller of syscall::mount. In most cases, the mount call failure indicates an actual failure, so we log them, unless the error case is handled.

I will also add one more commit to trigger the integration_validation test, so we can be complete in this PR.

MsFlags::MS_BIND | MsFlags::MS_REC,
None,
)
.map_err(|err| {
Copy link
Collaborator Author

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 the rootfs module. Here, mount call failure indicates an actual failure, so we log the error here.

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Jun 5, 2023

Hey @yihuaf Thanks for the detailed explanation! I think I got the actual call site and implementation mixed up originally. This looks good then, and once the CI pass, I'll approve and merge. Thanks a lot!

Copy link
Collaborator

@YJDoc2 YJDoc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@yihuaf yihuaf merged commit d09c984 into youki-dev:main Jun 5, 2023
@yihuaf yihuaf deleted the yihuaf/mount_error branch June 5, 2023 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants