From 92e2cc71da53113a9dfc1a7f98c444b24a11d0c6 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Sun, 29 Dec 2024 19:26:36 +0530 Subject: [PATCH 1/2] add time namespace to generated config.json Signed-off-by: Akhil Mohan --- libcontainer/specconv/example.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libcontainer/specconv/example.go b/libcontainer/specconv/example.go index 1e9cfa2dbfe..a361aa956c4 100644 --- a/libcontainer/specconv/example.go +++ b/libcontainer/specconv/example.go @@ -144,6 +144,9 @@ func Example() *specs.Spec { { Type: specs.MountNamespace, }, + { + Type: specs.TimeNamespace, + }, }, }, } From bea75f1b2b4ef5ebe82bdf227856d6f8447ce41f Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Mon, 30 Dec 2024 00:21:43 +0530 Subject: [PATCH 2/2] fix timens tests Signed-off-by: Akhil Mohan --- tests/integration/run.bats | 6 ++---- tests/integration/timens.bats | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/integration/run.bats b/tests/integration/run.bats index c6e30709402..b0bf65dad72 100644 --- a/tests/integration/run.bats +++ b/tests/integration/run.bats @@ -142,16 +142,14 @@ function teardown() { requires timens # Create a detached container with the namespaces we want. We notably want - # to include both userns and timens, which require config-related - # configuration. + # to include userns, which require config-related configuration. if [ $EUID -eq 0 ]; then update_config '.linux.namespaces += [{"type": "user"}] | .linux.uidMappings += [{"containerID": 0, "hostID": 100000, "size": 100}] | .linux.gidMappings += [{"containerID": 0, "hostID": 200000, "size": 200}]' remap_rootfs fi - update_config '.linux.namespaces += [{"type": "time"}] - | .linux.timeOffsets = { + update_config '.linux.timeOffsets = { "monotonic": { "secs": 7881, "nanosecs": 2718281 }, "boottime": { "secs": 1337, "nanosecs": 3141519 } }' diff --git a/tests/integration/timens.bats b/tests/integration/timens.bats index fb33e2b2783..8896700132e 100644 --- a/tests/integration/timens.bats +++ b/tests/integration/timens.bats @@ -28,8 +28,7 @@ function teardown() { requires timens update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' - update_config '.linux.namespaces += [{"type": "time"}] - | .linux.timeOffsets = null' + update_config '.linux.timeOffsets = null' runc run test_busybox [ "$status" -eq 0 ] @@ -42,8 +41,7 @@ function teardown() { requires timens update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' - update_config '.linux.namespaces += [{"type": "time"}] - | .linux.timeOffsets = { + update_config '.linux.timeOffsets = { "monotonic": { "secs": 7881, "nanosecs": 2718281 }, "boottime": { "secs": 1337, "nanosecs": 3141519 } }' @@ -64,8 +62,7 @@ function teardown() { remap_rootfs update_config '.process.args = ["cat", "/proc/self/timens_offsets"]' - update_config '.linux.namespaces += [{"type": "time"}] - | .linux.timeOffsets = { + update_config '.linux.timeOffsets = { "monotonic": { "secs": 7881, "nanosecs": 2718281 }, "boottime": { "secs": 1337, "nanosecs": 3141519 } }'