Skip to content

Commit

Permalink
🐛♻️ adding meaningful restart policy for services (#3262)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrei Neagu <[email protected]>
  • Loading branch information
GitHK and Andrei Neagu authored Aug 22, 2022
1 parent 25e7ca9 commit 8443c68
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Final

_SECOND: Final[int] = 1_000_000_000 # expressed in nano-seconds

DOCKER_CONTAINER_SPEC_RESTART_POLICY_DEFAULTS = {
"Condition": "on-failure",
"MaxAttempts": 0,
"Delay": 5 * _SECOND,
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from ....core.settings import DynamicSidecarProxySettings, DynamicSidecarSettings
from ....models.schemas.dynamic_services import SchedulerData, ServiceType
from ._constants import DOCKER_CONTAINER_SPEC_RESTART_POLICY_DEFAULTS


def get_dynamic_proxy_spec(
Expand Down Expand Up @@ -107,10 +108,6 @@ def get_dynamic_proxy_spec(
},
"Limits": {"MemoryBytes": MEMORY_250MB, "NanoCPUs": CPU_100_PERCENT},
},
"RestartPolicy": {
"Condition": "on-failure",
"Delay": 5000000,
"MaxAttempts": 100,
},
"RestartPolicy": DOCKER_CONTAINER_SPEC_RESTART_POLICY_DEFAULTS,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ....models.schemas.dynamic_services import SchedulerData, ServiceType
from .._namespace import get_compose_namespace
from ..volumes import DynamicSidecarVolumesPathsResolver
from ._constants import DOCKER_CONTAINER_SPEC_RESTART_POLICY_DEFAULTS
from .settings import update_service_params_from_settings

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -253,11 +254,7 @@ def get_dynamic_sidecar_spec(
app_settings.DIRECTOR_V2_SERVICES_CUSTOM_CONSTRAINTS
)
},
"RestartPolicy": {
"Condition": "on-failure",
"Delay": 5000000,
"MaxAttempts": 2,
},
"RestartPolicy": DOCKER_CONTAINER_SPEC_RESTART_POLICY_DEFAULTS,
# this will get overwritten
"Resources": {
"Limits": {"NanoCPUs": 0, "MemoryBytes": 0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ def expected_dynamic_sidecar_spec(run_id: RunID) -> dict[str, Any]:
},
"RestartPolicy": {
"Condition": "on-failure",
"Delay": 5000000,
"MaxAttempts": 2,
"Delay": 5000000000,
"MaxAttempts": 0,
},
},
}
Expand Down

0 comments on commit 8443c68

Please sign in to comment.