From ada9bec2d4c345fe6a4ac6d7f08082f6027e0219 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Tue, 24 Mar 2026 18:29:45 +1000 Subject: [PATCH] refactor: remove docker dependency for Pid container property --- internal/machine/docker/server.go | 2 +- pkg/api/service.go | 7 +++---- pkg/api/service_test.go | 2 +- pkg/client/compose/service.go | 2 +- pkg/client/compose/service_test.go | 2 +- pkg/client/deploy/container_test.go | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/machine/docker/server.go b/internal/machine/docker/server.go index a566d76b..9225b150 100644 --- a/internal/machine/docker/server.go +++ b/internal/machine/docker/server.go @@ -627,7 +627,7 @@ func (s *Server) CreateServiceContainer( Binds: spec.Container.Volumes, Init: spec.Container.Init, Mounts: mounts, - PidMode: spec.Container.Pid, + PidMode: container.PidMode(spec.Container.PidMode), PortBindings: portBindings, Privileged: spec.Container.Privileged, Resources: container.Resources{ diff --git a/pkg/api/service.go b/pkg/api/service.go index f992e739..b86aad35 100644 --- a/pkg/api/service.go +++ b/pkg/api/service.go @@ -11,7 +11,6 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/distribution/reference" - "github.com/docker/docker/api/types/container" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/psviderski/uncloud/internal/machine/api/pb" @@ -257,8 +256,8 @@ type ContainerSpec struct { Init *bool // LogDriver overrides the default logging driver for the container. Each Docker daemon can have its own default. LogDriver *LogDriver - // Pid allows setting the PID name space, currently only "" or "host" is supported. - Pid container.PidMode + // PidMode sets the PID namespace mode for the container. Currently only "" or "host" is supported. + PidMode string // Privileged gives extended privileges to the container. This is a security risk and should be used with caution. Privileged bool // PullPolicy determines when to pull the image from the registry or use the image already available in the cluster. @@ -266,7 +265,7 @@ type ContainerSpec struct { PullPolicy string // Resource allocation for the container. Resources ContainerResources - // Namespaced kernel parameters to be set in container + // Namespaced kernel parameters to be set in the container. Sysctls map[string]string // User overrides the default user of the image used to run the container. Format: user|UID[:group|GID]. User string diff --git a/pkg/api/service_test.go b/pkg/api/service_test.go index dbd39070..1b067ab5 100644 --- a/pkg/api/service_test.go +++ b/pkg/api/service_test.go @@ -206,7 +206,7 @@ func TestContainerSpec_Clone(t *testing.T) { original := ContainerSpec{ CapAdd: []string{"NET_ADMIN"}, CapDrop: []string{"ALL"}, - Pid: container.PidMode("host"), + PidMode: "host", Command: []string{"sh", "-c", "echo hello"}, Entrypoint: []string{"/bin/bash"}, Env: EnvVars{ diff --git a/pkg/client/compose/service.go b/pkg/client/compose/service.go index 81e5444b..adabd216 100644 --- a/pkg/client/compose/service.go +++ b/pkg/client/compose/service.go @@ -53,7 +53,7 @@ func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.Ser Healthcheck: healthcheckFromCompose(service.HealthCheck), Image: service.Image, Init: service.Init, - Pid: container.PidMode(service.Pid), + PidMode: service.Pid, Privileged: service.Privileged, PullPolicy: pullPolicy, Resources: resourcesFromCompose(service), diff --git a/pkg/client/compose/service_test.go b/pkg/client/compose/service_test.go index 49ec513d..074ee79e 100644 --- a/pkg/client/compose/service_test.go +++ b/pkg/client/compose/service_test.go @@ -127,7 +127,7 @@ func TestServiceSpecFromCompose(t *testing.T) { "max-file": "3", }, }, - Pid: "host", + PidMode: "host", Privileged: true, PullPolicy: api.PullPolicyAlways, Resources: api.ContainerResources{ diff --git a/pkg/client/deploy/container_test.go b/pkg/client/deploy/container_test.go index d5106f93..0586aa07 100644 --- a/pkg/client/deploy/container_test.go +++ b/pkg/client/deploy/container_test.go @@ -58,7 +58,7 @@ func TestEvalContainerSpecChange_ContainerPid(t *testing.T) { newSpec := api.ServiceSpec{ Container: api.ContainerSpec{ Image: "nginx:latest", - Pid: "host", + PidMode: "host", CapAdd: []string{"NET_ADMIN"}, }, }