diff --git a/compose.go b/compose.go index d7afb68..777af4b 100644 --- a/compose.go +++ b/compose.go @@ -623,17 +623,15 @@ func (g *Generator) buildNixContainer(service types.ServiceConfig, networkMap ma } // Name is misleading - this actually is the exact number passed in with "cpus". if limits.NanoCPUs != 0 { - c.ExtraOptions = append(c.ExtraOptions, "--cpu-quota="+strconv.FormatFloat(float64(limits.NanoCPUs), 'f', -1, 32)) + c.ExtraOptions = append(c.ExtraOptions, "--cpus="+strconv.FormatFloat(float64(limits.NanoCPUs), 'f', -1, 32)) } } if reservations := deploy.Resources.Reservations; reservations != nil { if reservations.MemoryBytes != 0 { c.ExtraOptions = append(c.ExtraOptions, fmt.Sprintf("--memory-reservation=%db", reservations.MemoryBytes)) } - // Name is misleading - this actually is the exact number passed in with "cpus". - if reservations.NanoCPUs != 0 { - c.ExtraOptions = append(c.ExtraOptions, "--cpus="+strconv.FormatFloat(float64(reservations.NanoCPUs), 'f', -1, 32)) - } + + // CPU reservation is a Docker Swarm option. // CDI GPU support. for _, device := range reservations.Devices { diff --git a/testdata/TestBasic.docker.nix b/testdata/TestBasic.docker.nix index 63f3765..8b3e9f5 100644 --- a/testdata/TestBasic.docker.nix +++ b/testdata/TestBasic.docker.nix @@ -32,8 +32,7 @@ ]; log-driver = "journald"; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestBasic.podman.nix b/testdata/TestBasic.podman.nix index 793108f..e7d94f3 100644 --- a/testdata/TestBasic.podman.nix +++ b/testdata/TestBasic.podman.nix @@ -42,8 +42,7 @@ ]; log-driver = "journald"; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestBasicAutoFormat.docker.nix b/testdata/TestBasicAutoFormat.docker.nix index 1e06619..2d7affb 100644 --- a/testdata/TestBasicAutoFormat.docker.nix +++ b/testdata/TestBasicAutoFormat.docker.nix @@ -34,8 +34,7 @@ dependsOn = [ "myproject-sabnzbd" ]; log-driver = "journald"; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestBasicAutoFormat.podman.nix b/testdata/TestBasicAutoFormat.podman.nix index a177511..df722e9 100644 --- a/testdata/TestBasicAutoFormat.podman.nix +++ b/testdata/TestBasicAutoFormat.podman.nix @@ -44,8 +44,7 @@ dependsOn = [ "myproject-sabnzbd" ]; log-driver = "journald"; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestDeployDevices.compose.yml b/testdata/TestDeployDevices.compose.yml index 3ffd344..56fa134 100644 --- a/testdata/TestDeployDevices.compose.yml +++ b/testdata/TestDeployDevices.compose.yml @@ -29,4 +29,6 @@ services: count: 1 capabilities: - gpu + limits: + cpus: '0.50' diff --git a/testdata/TestDeployDevices.docker.nix b/testdata/TestDeployDevices.docker.nix index 0ffc149..7fabd70 100644 --- a/testdata/TestDeployDevices.docker.nix +++ b/testdata/TestDeployDevices.docker.nix @@ -14,6 +14,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ + "--cpus=0.5" "--device=nvidia.com/gpu=all" "--network-alias=deploy-nvidia" "--network=test_default" diff --git a/testdata/TestDeployDevices.podman.nix b/testdata/TestDeployDevices.podman.nix index 80a7792..0a8d5fd 100644 --- a/testdata/TestDeployDevices.podman.nix +++ b/testdata/TestDeployDevices.podman.nix @@ -24,6 +24,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ + "--cpus=0.5" "--device=nvidia.com/gpu=all" "--network-alias=deploy-nvidia" "--network=test_default" diff --git a/testdata/TestNoWriteNixSetup.docker.nix b/testdata/TestNoWriteNixSetup.docker.nix index b6b1e7e..7ff0ad4 100644 --- a/testdata/TestNoWriteNixSetup.docker.nix +++ b/testdata/TestNoWriteNixSetup.docker.nix @@ -27,8 +27,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestNoWriteNixSetup.podman.nix b/testdata/TestNoWriteNixSetup.podman.nix index e30b4d5..2755758 100644 --- a/testdata/TestNoWriteNixSetup.podman.nix +++ b/testdata/TestNoWriteNixSetup.podman.nix @@ -27,8 +27,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestOverrideSystemdStopTimeout.docker.nix b/testdata/TestOverrideSystemdStopTimeout.docker.nix index 2b50d62..9f5e700 100644 --- a/testdata/TestOverrideSystemdStopTimeout.docker.nix +++ b/testdata/TestOverrideSystemdStopTimeout.docker.nix @@ -33,8 +33,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestOverrideSystemdStopTimeout.podman.nix b/testdata/TestOverrideSystemdStopTimeout.podman.nix index 081d1de..7d16ae1 100644 --- a/testdata/TestOverrideSystemdStopTimeout.podman.nix +++ b/testdata/TestOverrideSystemdStopTimeout.podman.nix @@ -43,8 +43,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestProject.docker.nix b/testdata/TestProject.docker.nix index 9690353..9af2c09 100644 --- a/testdata/TestProject.docker.nix +++ b/testdata/TestProject.docker.nix @@ -33,8 +33,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestProject.podman.nix b/testdata/TestProject.podman.nix index 89c8fcb..77c9dc2 100644 --- a/testdata/TestProject.podman.nix +++ b/testdata/TestProject.podman.nix @@ -43,8 +43,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestRemoveVolumes.docker.nix b/testdata/TestRemoveVolumes.docker.nix index 2c6be52..aa040f4 100644 --- a/testdata/TestRemoveVolumes.docker.nix +++ b/testdata/TestRemoveVolumes.docker.nix @@ -33,8 +33,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestRemoveVolumes.podman.nix b/testdata/TestRemoveVolumes.podman.nix index ce82b47..49f504f 100644 --- a/testdata/TestRemoveVolumes.podman.nix +++ b/testdata/TestRemoveVolumes.podman.nix @@ -43,8 +43,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestSystemdMount.docker.nix b/testdata/TestSystemdMount.docker.nix index d94410e..66a5c09 100644 --- a/testdata/TestSystemdMount.docker.nix +++ b/testdata/TestSystemdMount.docker.nix @@ -33,8 +33,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestSystemdMount.podman.nix b/testdata/TestSystemdMount.podman.nix index 1297af2..f4055fc 100644 --- a/testdata/TestSystemdMount.podman.nix +++ b/testdata/TestSystemdMount.podman.nix @@ -43,8 +43,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestUpheldBy.docker.nix b/testdata/TestUpheldBy.docker.nix index 9c25ac5..5c89d77 100644 --- a/testdata/TestUpheldBy.docker.nix +++ b/testdata/TestUpheldBy.docker.nix @@ -33,8 +33,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/TestUpheldBy.podman.nix b/testdata/TestUpheldBy.podman.nix index 6d5c831..d240c93 100644 --- a/testdata/TestUpheldBy.podman.nix +++ b/testdata/TestUpheldBy.podman.nix @@ -43,8 +43,7 @@ log-driver = "journald"; autoStart = false; extraOptions = [ - "--cpu-quota=1.5" - "--cpus=1" + "--cpus=1.5" "--dns=1.1.1.1" "--health-cmd=curl -f http://localhost/\${POTATO}" "--memory-reservation=524288000b" diff --git a/testdata/compose.yml b/testdata/compose.yml index 5b395d4..f112010 100644 --- a/testdata/compose.yml +++ b/testdata/compose.yml @@ -126,7 +126,7 @@ services: cpus: 1.5 memory: 1000M reservations: - cpus: 1.0 + cpus: 1.0 # ignored memory: 500M logging: driver: "json-file"