Skip to content

Commit

Permalink
revert default StartLimitIntervalSec override
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Mar 16, 2024
1 parent 0a4b995 commit 2629f34
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 39 deletions.
3 changes: 1 addition & 2 deletions nixos-test/docker-compose.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto-generated using compose2nix v0.1.7.
# Auto-generated using compose2nix v0.1.8.
{ pkgs, lib, ... }:

{
Expand Down Expand Up @@ -35,7 +35,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down
3 changes: 1 addition & 2 deletions nixos-test/podman-compose.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto-generated using compose2nix v0.1.7.
# Auto-generated using compose2nix v0.1.8.
{ pkgs, lib, ... }:

{
Expand Down Expand Up @@ -37,7 +37,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"podman-network-myproject-default.service"
Expand Down
25 changes: 8 additions & 17 deletions systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,26 +200,17 @@ func (c *NixContainerSystemdConfig) ParseRestartPolicy(service *types.ServiceCon
c.Unit.Set("StartLimitIntervalSec", windowSecs)
} else if c.StartLimitBurst != nil {
c.Unit.Set("StartLimitIntervalSec", "infinity")
} else {
// Defaults to zero (i.e., indefinite retry attempts).
c.Unit.Set("StartLimitIntervalSec", 0)
}
}

if indefiniteRestart {
if _, ok := c.Unit.Options["StartLimitIntervalSec"]; !ok {
// Defaults to zero (i.e., indefinite retry attempts).
c.Unit.Set("StartLimitIntervalSec", 0)
}
if runtime == ContainerRuntimeDocker {
// This simulates the default behavior of Docker. Basically, Docker will restart
// the container with a sleep period of 100ms. This sleep period is doubled until a
// maximum of 1 minute.
// See: https://docs.docker.com/reference/cli/docker/container/run/#restart
c.Service.Set("RestartSec", "100ms")
c.Service.Set("RestartSteps", 9) // 2^(9 attempts) = 512 (* 100ms) ~= 1 minute
c.Service.Set("RestartMaxDelaySec", "1m")
}
if indefiniteRestart && runtime == ContainerRuntimeDocker {
// This simulates the default behavior of Docker. Basically, Docker will restart
// the container with a sleep period of 100ms. This sleep period is doubled until a
// maximum of 1 minute.
// See: https://docs.docker.com/reference/cli/docker/container/run/#restart
c.Service.Set("RestartSec", "100ms")
c.Service.Set("RestartSteps", 9) // 2^(9 attempts) = 512 (* 100ms) ~= 1 minute
c.Service.Set("RestartMaxDelaySec", "1m")
}

return nil
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_EnvFilesOnly_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -280,7 +279,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_NoWriteNixSetup_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -300,7 +299,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_OverrideSystemdStopTimeout_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -311,7 +310,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_RemoveVolumes_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -306,7 +305,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_SystemdMount_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -314,7 +313,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -306,7 +305,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestDocker_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"docker-network-myproject-default.service"
Expand Down Expand Up @@ -301,7 +300,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"docker-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestPodman_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"podman-network-myproject-default.service"
Expand Down Expand Up @@ -285,7 +284,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"podman-compose-myproject-root.target"
Expand Down
2 changes: 0 additions & 2 deletions testdata/TestPodman_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
};
unitConfig = {
Description = lib.mkOverride 500 "This is the sabnzbd container!";
StartLimitIntervalSec = lib.mkOverride 500 0;
};
after = [
"podman-network-myproject-default.service"
Expand Down Expand Up @@ -280,7 +279,6 @@
};
unitConfig = {
AllowIsolate = lib.mkOverride 500 true;
StartLimitIntervalSec = lib.mkOverride 500 0;
};
partOf = [
"podman-compose-myproject-root.target"
Expand Down

0 comments on commit 2629f34

Please sign in to comment.