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
[mounts] only allow one to one id mappings #3349
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3349 +/- ##
==========================================
- Coverage 83.92% 83.84% -0.08%
==========================================
Files 251 251
Lines 13678 13690 +12
==========================================
Hits 11479 11479
- Misses 2199 2211 +12 ☔ View full report in Codecov by Sentry. |
This is not a review, I just glanced over it out of curiosity. And I'm not sure I understand the whole auto unique_iter_end = std::unique(mappings.begin(), mappings.end(), [](auto& a, auto& b) {
return a.first == b.first || a.second == b.second;
}); Then |
Hey @andrei-toterman, The idea of the BackInserter was so that insertions could be made into the returned vector from either an existing vector (as used in Using |
Oops, you're right about the Anyway, when trying to do a mount with repeated mappings, the errors are indeed reported, but the mount still occurs. Shouldn't we abort the operation entirely? mp mount dir instance:dir -u 1000:1000 -u 1000:2000 I get the following error message
But the mount still happens, but only with the What about checking for duplicates only inside the |
31e655f
to
385dc25
Compare
Yes, I had considered that. For the some of the "errors" that can happen when creating mounts (eg. incorrect paths, incorrect instances name) we simply ignore those items and continue with establish as many of the mounts as possible. That is why I treated mappings the same way. I like the idea of checking mapping inside of |
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.
Hey @sharder996!
Thanks for this! I'm not done reviewing, but I did want to go ahead and give you my feedback below.
}; | ||
|
||
if (auto unique_iter_end = mp::unique_id_mappings(gid_mappings); unique_iter_end != gid_mappings.end()) | ||
throw std::runtime_error(fmt::format("Mount cannot apply mapping with duplicate gids: {}", |
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.
I don't think the message is very clear here. It doesn't reference the first mapping found with the duplicate. For example, if I passed in -g 1000:1000 -g 1000:1001 -g 1000:1002
, it will only print out the last two. I think it should print all of the duplicate mappings and let the user see what they are and decide how to fix it.
Also, I'm kind of on the fence on this, but I wonder if we should be a little more specific which gid is the duplicate meaning either the host gid or the instance gid that is the offender. Any opinions on this?
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.
I agree that the error message could be more descriptive, but it require the filtering algorithm to change quite a bit so that the offending id can be identified as well as it's associated duplicate id mappings. I haven't thought of a good way to do this yet and seeing as how other things are higher priority I haven't done anything yet.
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.
Ok, makes sense. We can put this on the back burner for now until the other items you are working on are more complete.
throw std::runtime_error(fmt::format("Mount cannot apply mapping with duplicate uids: {}", | ||
print_mappings(unique_iter_end, uid_mappings.end()))); |
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.
Idem: Error message is a bit unclear as I pointed out above.
Hey @sharder996, Any more thoughts on my comments in this? I've looked over the code and it otherwise seems reasonable to me, but I do think the error messages should be improved. Thanks! |
Fixes #3332