-
Notifications
You must be signed in to change notification settings - Fork 46
feat: handle oci specification issue & refactor run_pod_sandbox function
#338
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
base: main
Are you sure you want to change the base?
Changes from all commits
c5e0c37
6e9f876
6ffebb1
6f23243
65f36e1
7fa39cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,7 @@ pub mod _private { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod lease; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub mod quic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use libcontainer::oci_spec::runtime::Capability; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub use libvault::modules::pki::types::{IssueCertificateRequest, IssueCertificateResponse}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Serialize, Deserialize, Clone)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -224,6 +225,74 @@ pub struct Resource { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub memory: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub struct SecurityContext { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(rename = "runAsUser")] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub run_as_user: Option<i64>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(rename = "runAsGroup")] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub run_as_group: Option<i64>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(default)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub privileged: Option<bool>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[serde(rename = "allowPrivilegeEscalation", default)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub allow_privilege_escalation: Option<bool>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+228
to
+241
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | |
| pub struct SecurityContext { | |
| #[serde(rename = "runAsUser")] | |
| pub run_as_user: Option<i64>, | |
| #[serde(rename = "runAsGroup")] | |
| pub run_as_group: Option<i64>, | |
| #[serde(default)] | |
| pub privileged: Option<bool>, | |
| #[serde(rename = "allowPrivilegeEscalation", default)] | |
| pub allow_privilege_escalation: Option<bool>, | |
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | |
| /// Container-level security options controlling user/group identity, | |
| /// privilege escalation and Linux capabilities. | |
| /// | |
| /// This roughly mirrors the Kubernetes `SecurityContext` semantics and is | |
| /// serialized/deserialized for use in API objects. All fields are optional: | |
| /// if a value is `None`, the runtime-specific defaults or image metadata | |
| /// typically apply. | |
| pub struct SecurityContext { | |
| /// Override for the effective user ID (UID) inside the container. | |
| /// | |
| /// When set, the container process will attempt to run as this UID | |
| /// instead of the image's default user. Using `0` (root) grants full | |
| /// privileges inside the container and increases the risk of container | |
| /// breakout or privilege escalation on the host; prefer non-root UIDs | |
| /// wherever possible. | |
| #[serde(rename = "runAsUser")] | |
| pub run_as_user: Option<i64>, | |
| /// Override for the effective primary group ID (GID) inside the container. | |
| /// | |
| /// When set, the container process will attempt to run with this GID as | |
| /// its primary group. Similar to `run_as_user`, using a highly privileged | |
| /// group (for example, a group with write access to sensitive paths) | |
| /// can weaken isolation. | |
| #[serde(rename = "runAsGroup")] | |
| pub run_as_group: Option<i64>, | |
| /// Run the container in "privileged" mode when `Some(true)`. | |
| /// | |
| /// Privileged containers are granted almost full access to the host, | |
| /// including device access and most kernel capabilities. This effectively | |
| /// disables many isolation mechanisms and should only be enabled for | |
| /// carefully audited workloads. When `None`, the runtime's default | |
| /// (usually non-privileged) is used. | |
| #[serde(default)] | |
| pub privileged: Option<bool>, | |
| /// Allow the container process to gain more privileges than its parent. | |
| /// | |
| /// When `Some(false)`, common escalation paths such as setuid/setgid | |
| /// binaries or acquiring new file-based capabilities are blocked, | |
| /// providing stronger confinement. When `Some(true)` (or if left to the | |
| /// runtime default), processes may increase their privileges, which can | |
| /// be necessary for some legacy applications but reduces overall safety. | |
| #[serde(rename = "allowPrivilegeEscalation", default)] | |
| pub allow_privilege_escalation: Option<bool>, | |
| /// Linux capabilities configuration applied to the container. | |
| /// | |
| /// Capabilities provide fine-grained control over privileged operations. | |
| /// Use this field to add or drop specific capabilities instead of running | |
| /// the container as fully privileged; only grant the minimal set required | |
| /// by the workload. |
Copilot
AI
Dec 17, 2025
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 EnvVar struct lacks documentation. It should include doc comments explaining its purpose and fields, particularly the relationship between value and the commented-out value_from field.
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | |
| pub struct EnvVar { | |
| pub name: String, | |
| #[serde(default)] | |
| pub value: Option<String>, | |
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | |
| /// Describes a single environment variable for a container, following Kubernetes-style semantics. | |
| /// | |
| /// An `EnvVar` typically has a `name` and either a literal `value` or a "value from" source | |
| /// (such as a Secret, ConfigMap, or pod field). In this implementation only literal values | |
| /// are supported via [`value`]; the `value_from` mechanism is currently commented out. | |
| /// | |
| /// When/if `value_from` is enabled, only one of `value` or `value_from` should be set for | |
| /// a given `EnvVar`, mirroring Kubernetes' `EnvVar` contract. | |
| pub struct EnvVar { | |
| /// Name of the environment variable. This must be unique within the container's | |
| /// environment and should be a valid shell variable identifier (e.g. `MY_VAR`). | |
| pub name: String, | |
| /// Literal value of the environment variable. | |
| /// | |
| /// If `None`, the variable may be omitted or populated by other mechanisms (such as | |
| /// defaults or a future `value_from` source). When `value_from` is supported, this | |
| /// field is intended to be mutually exclusive with `value_from`. | |
| #[serde(default)] | |
| pub value: Option<String>, | |
| // Source for the environment variable's value, such as a Secret, ConfigMap, or pod field. | |
| // Only one of `value` or `value_from` should be set when this is enabled. |
Copilot
AI
Dec 17, 2025
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 VolumeMount struct lacks documentation. It should include doc comments explaining its purpose and fields, particularly what sub_path is used for and how mount_path is interpreted.
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | |
| pub struct VolumeMount { | |
| pub name: String, | |
| #[serde(rename = "mountPath")] | |
| pub mount_path: String, | |
| #[serde(rename = "readOnly", default)] | |
| pub read_only: Option<bool>, | |
| #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | |
| /// Describes how a named volume is mounted into a container filesystem. | |
| /// | |
| /// This is conceptually similar to Kubernetes' `VolumeMount`. The `name` field | |
| /// must match a defined volume, and the volume (or a sub-path within it) is | |
| /// exposed inside the container at `mount_path`. | |
| pub struct VolumeMount { | |
| /// Name of the volume to mount, matching a volume defined in the pod spec. | |
| pub name: String, | |
| /// Absolute path inside the container where the volume (or `sub_path`) is mounted. | |
| /// | |
| /// This path is interpreted in the container's filesystem namespace, not on | |
| /// the host. The path must be absolute (e.g. `/data`, `/var/log/app`). | |
| #[serde(rename = "mountPath")] | |
| pub mount_path: String, | |
| /// Whether the container should see this mount as read-only. | |
| /// | |
| /// If `None`, the mount defaults to read-write, subject to the underlying | |
| /// volume's capabilities and permissions. | |
| #[serde(rename = "readOnly", default)] | |
| pub read_only: Option<bool>, | |
| /// Optional sub-path within the volume to mount instead of the volume root. | |
| /// | |
| /// When set, only this path inside the referenced volume is mounted at | |
| /// `mount_path`. If omitted, the entire volume root is mounted. |
Copilot
AI
Dec 17, 2025
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 newly added ContainerSpec fields (env, volume_mounts, command, working_dir) are not implemented in the OCISpecGenerator. These fields are added to the API but don't affect container behavior, which could lead to user confusion. They should either be implemented or removed if planned for future work.
| #[serde(default)] | |
| pub env: Option<Vec<EnvVar>>, | |
| #[serde(rename = "volumeMounts", default)] | |
| pub volume_mounts: Option<Vec<VolumeMount>>, | |
| #[serde(default)] | |
| pub command: Option<Vec<String>>, | |
| #[serde(rename = "workingDir", default)] | |
| pub working_dir: Option<String>, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ mod cri; | |
| mod daemon; | ||
| mod dns; | ||
| mod network; | ||
| mod oci; | ||
| mod quic; | ||
| mod rootpath; | ||
| mod task; | ||
|
|
||
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 SecurityContext fields run_as_user, run_as_group, and allow_privilege_escalation are defined but never used in the OCISpecGenerator implementation. These fields should either be implemented in the OCI spec generation logic or removed if they're planned for future work.