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
runtime-rs: bind mount volumes in sandbox level #5607
runtime-rs: bind mount volumes in sandbox level #5607
Conversation
|
Can one of the admins verify this patch? |
42f3d20
to
de7e580
Compare
|
Hi @liubin, I found some errors making ci failure in compiling Dragonball. However, this pull request didn't change Dragonball at all. How to fix this? Thanks. |
|
@justxuewei #5640 is fixing the clippy issue. |
de7e580
to
4bdcd35
Compare
98d3ae2
to
f1c1374
Compare
|
/test |
| @@ -38,13 +38,29 @@ pub const PASSTHROUGH_FS_DIR: &str = "passthrough"; | |||
| const RAFS_DIR: &str = "rafs"; | |||
|
|
|||
| #[async_trait] | |||
| pub trait ShareFs: Send + Sync { | |||
| pub trait ShareFs: Send + Sync + Debug { | |||
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.
Why is Debug required?
| async fn share_rootfs(&self, config: ShareFsRootfsConfig) -> Result<ShareFsMountResult>; | ||
| async fn share_volume(&self, config: ShareFsVolumeConfig) -> Result<ShareFsMountResult>; | ||
| /// Upgrade to readwrite permission | ||
| async fn upgrade(&self, file_name: &str) -> Result<()>; |
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.
Please name it explicitly. Something like upgrade_rw and dowgrade_ro sound better.
| let host_dest = do_get_host_path(file_name, &self.id, "", true, false); | ||
| umount_timeout(&host_dest, 0).context("Umount readonly host dest")?; | ||
| let host_dest = do_get_host_path(file_name, &self.id, "", true, true); | ||
| umount_timeout(&host_dest, 0).context("Umount readwrite host dest")?; |
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.
The umount event is propagated to the ro virtiofs mount subtree. We only need to umount the rw directory bindmount.
| mounted_info.rw_ref_count += 1; | ||
| } | ||
| share_fs | ||
| .set_mounted_info(&m.source, mounted_info) |
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.
Do we need any lock when manipulating mounted_info? There are a whole bunch of race windows here.
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.
Yes, you are right. I am working on it.
| readonly, | ||
| ); | ||
| share_fs | ||
| .set_mounted_info(&m.source, mounted_info) |
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.
The same locking concern applies here too.
Implemented bind mount related managment on the sandbox side, involving bind mount a volume if it's not mounted before, upgrade permission to readwrite if there is a new container needs. Fixes: kata-containers#5588 Signed-off-by: Xuewei Niu <justxuewei@apache.org>
This commit implemented umonut controls and permission controls. When a volume is no longer referenced, it will be umounted immediately. When a volume mounted with readonly permission and a new coming container needs readwrite permission, the volume should be upgraded to readwrite permission. On the contrary, if a volume with readwrite permission and no container needs readwrite, then the volume should be downgraded. Fixes: kata-containers#5588 Signed-off-by: Xuewei Niu <justxuewei@apache.org>
Removed the `Debug` trait for the `ShareFs` and etc. Renamed `ShareFsMount::upgrade()` and `ShareFsMount::downgrade()` to `upgrade_to_rw()` and `downgrade_to_ro()`. Protected `mounted_info_set` with a mutex to avoid race conditions. Fixes: kata-containers#5588 Signed-off-by: Xuewei Niu <justxuewei@apache.org>
f1c1374
to
fdf0a7b
Compare
|
Thanks for your reviews @bergwolf. I've pushed a new commit to fix the issues you mentioned above. Please take a look. |
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.
lgtm! Thanks!
|
/test |
|
/retest |
…ebug test-agent-shutdown: Fix false positive match
This PR fixes the issue mentioned in #5588. In this pull request all shared volumes, except for rootfs, are bind mounted in sandbox level. That is all volumes referred to the same source on the host are bind mounted only once until no container references to it.
It supports dynamic permission controls as well. For example, when a volume mounted with readonly permission and a new coming container needs readwrite permission, the volume should be upgraded to readwrite permission. At the same time, if readwrite permission is no longer needed, then the volume should be downgraded.
Fixes: #5588
Signed-off-by: Xuewei Niu justxuewei@apache.org