mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
agent: add the FSGroup support
Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit is contained in:
parent
ff7874bc23
commit
9cb15ab4c5
@ -16,13 +16,14 @@ use crate::{
|
|||||||
ARPNeighbor, ARPNeighbors, AddArpNeighborRequest, AgentDetails, BlkioStats,
|
ARPNeighbor, ARPNeighbors, AddArpNeighborRequest, AgentDetails, BlkioStats,
|
||||||
BlkioStatsEntry, CgroupStats, CheckRequest, CloseStdinRequest, ContainerID,
|
BlkioStatsEntry, CgroupStats, CheckRequest, CloseStdinRequest, ContainerID,
|
||||||
CopyFileRequest, CpuStats, CpuUsage, CreateContainerRequest, CreateSandboxRequest, Device,
|
CopyFileRequest, CpuStats, CpuUsage, CreateContainerRequest, CreateSandboxRequest, Device,
|
||||||
Empty, ExecProcessRequest, GuestDetailsResponse, HealthCheckResponse, HugetlbStats,
|
Empty, ExecProcessRequest, FSGroup, FSGroupChangePolicy, GuestDetailsResponse,
|
||||||
IPAddress, IPFamily, Interface, Interfaces, KernelModule, MemHotplugByProbeRequest,
|
HealthCheckResponse, HugetlbStats, IPAddress, IPFamily, Interface, Interfaces,
|
||||||
MemoryData, MemoryStats, NetworkStats, OnlineCPUMemRequest, PidsStats, ReadStreamRequest,
|
KernelModule, MemHotplugByProbeRequest, MemoryData, MemoryStats, NetworkStats,
|
||||||
ReadStreamResponse, RemoveContainerRequest, ReseedRandomDevRequest, Route, Routes,
|
OnlineCPUMemRequest, PidsStats, ReadStreamRequest, ReadStreamResponse,
|
||||||
SetGuestDateTimeRequest, SignalProcessRequest, StatsContainerResponse, Storage, StringUser,
|
RemoveContainerRequest, ReseedRandomDevRequest, Route, Routes, SetGuestDateTimeRequest,
|
||||||
ThrottlingData, TtyWinResizeRequest, UpdateContainerRequest, UpdateInterfaceRequest,
|
SignalProcessRequest, StatsContainerResponse, Storage, StringUser, ThrottlingData,
|
||||||
UpdateRoutesRequest, VersionCheckResponse, WaitProcessRequest, WriteStreamRequest,
|
TtyWinResizeRequest, UpdateContainerRequest, UpdateInterfaceRequest, UpdateRoutesRequest,
|
||||||
|
VersionCheckResponse, WaitProcessRequest, WriteStreamRequest,
|
||||||
},
|
},
|
||||||
OomEventResponse, WaitProcessResponse, WriteStreamResponse,
|
OomEventResponse, WaitProcessResponse, WriteStreamResponse,
|
||||||
};
|
};
|
||||||
@ -72,6 +73,22 @@ impl From<empty::Empty> for Empty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<FSGroup> for agent::FSGroup {
|
||||||
|
fn from(from: FSGroup) -> Self {
|
||||||
|
let policy = match from.group_change_policy {
|
||||||
|
FSGroupChangePolicy::Always => types::FSGroupChangePolicy::Always,
|
||||||
|
FSGroupChangePolicy::OnRootMismatch => types::FSGroupChangePolicy::OnRootMismatch,
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
group_id: from.group_id,
|
||||||
|
group_change_policy: policy,
|
||||||
|
unknown_fields: Default::default(),
|
||||||
|
cached_size: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<StringUser> for agent::StringUser {
|
impl From<StringUser> for agent::StringUser {
|
||||||
fn from(from: StringUser) -> Self {
|
fn from(from: StringUser) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -105,6 +122,7 @@ impl From<Storage> for agent::Storage {
|
|||||||
driver_options: from_vec(from.driver_options),
|
driver_options: from_vec(from.driver_options),
|
||||||
source: from.source,
|
source: from.source,
|
||||||
fstype: from.fs_type,
|
fstype: from.fs_type,
|
||||||
|
fs_group: from_option(from.fs_group),
|
||||||
options: from_vec(from.options),
|
options: from_vec(from.options),
|
||||||
mount_point: from.mount_point,
|
mount_point: from.mount_point,
|
||||||
unknown_fields: Default::default(),
|
unknown_fields: Default::default(),
|
||||||
|
@ -12,7 +12,7 @@ logging::logger_with_subsystem!(sl, "agent");
|
|||||||
pub mod kata;
|
pub mod kata;
|
||||||
mod log_forwarder;
|
mod log_forwarder;
|
||||||
mod sock;
|
mod sock;
|
||||||
mod types;
|
pub mod types;
|
||||||
pub use types::{
|
pub use types::{
|
||||||
ARPNeighbor, ARPNeighbors, AddArpNeighborRequest, BlkioStatsEntry, CheckRequest,
|
ARPNeighbor, ARPNeighbors, AddArpNeighborRequest, BlkioStatsEntry, CheckRequest,
|
||||||
CloseStdinRequest, ContainerID, ContainerProcessID, CopyFileRequest, CreateContainerRequest,
|
CloseStdinRequest, ContainerID, ContainerProcessID, CopyFileRequest, CreateContainerRequest,
|
||||||
|
@ -15,6 +15,24 @@ impl Empty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FSGroupChangePolicy {
|
||||||
|
fn default() -> Self {
|
||||||
|
FSGroupChangePolicy::Always
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub enum FSGroupChangePolicy {
|
||||||
|
Always = 0,
|
||||||
|
OnRootMismatch = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone, Default)]
|
||||||
|
pub struct FSGroup {
|
||||||
|
pub group_id: u32,
|
||||||
|
pub group_change_policy: FSGroupChangePolicy,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Default)]
|
#[derive(PartialEq, Clone, Default)]
|
||||||
pub struct StringUser {
|
pub struct StringUser {
|
||||||
pub uid: String,
|
pub uid: String,
|
||||||
@ -37,6 +55,7 @@ pub struct Storage {
|
|||||||
pub driver_options: Vec<String>,
|
pub driver_options: Vec<String>,
|
||||||
pub source: String,
|
pub source: String,
|
||||||
pub fs_type: String,
|
pub fs_type: String,
|
||||||
|
pub fs_group: Option<FSGroup>,
|
||||||
pub options: Vec<String>,
|
pub options: Vec<String>,
|
||||||
pub mount_point: String,
|
pub mount_point: String,
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ impl ShareFs for ShareVirtioFsInline {
|
|||||||
driver_options: Vec::new(),
|
driver_options: Vec::new(),
|
||||||
source: String::from(MOUNT_GUEST_TAG),
|
source: String::from(MOUNT_GUEST_TAG),
|
||||||
fs_type: String::from(FS_TYPE_VIRTIO_FS),
|
fs_type: String::from(FS_TYPE_VIRTIO_FS),
|
||||||
|
fs_group: None,
|
||||||
options: shared_options,
|
options: shared_options,
|
||||||
mount_point: String::from(KATA_GUEST_SHARE_DIR),
|
mount_point: String::from(KATA_GUEST_SHARE_DIR),
|
||||||
};
|
};
|
||||||
|
@ -45,6 +45,7 @@ impl ShmVolume {
|
|||||||
driver_options: Vec::new(),
|
driver_options: Vec::new(),
|
||||||
source: String::from("shm"),
|
source: String::from("shm"),
|
||||||
fs_type: String::from("tmpfs"),
|
fs_type: String::from("tmpfs"),
|
||||||
|
fs_group: None,
|
||||||
options,
|
options,
|
||||||
mount_point: mount_path.to_string(),
|
mount_point: mount_path.to_string(),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user