def __init__(self, config, datadog, prometheus, deployment_secrets): self._datadog = datadog self._prometheus = prometheus self._secrets = deployment_secrets self._fiaas_env = _build_fiaas_env(config) self._global_env = config.global_env self._lifecycle = None self._grace_period = self.MINIMUM_GRACE_PERIOD self._use_in_memory_emptydirs = config.use_in_memory_emptydirs if config.pre_stop_delay > 0: self._lifecycle = Lifecycle(preStop=Handler(_exec=ExecAction( command=["sleep", str(config.pre_stop_delay)]))) self._grace_period += config.pre_stop_delay self._max_surge = config.deployment_max_surge self._max_unavailable = config.deployment_max_unavailable
def _make_probe(check_spec): probe = Probe(initialDelaySeconds=check_spec.initial_delay_seconds, timeoutSeconds=check_spec.timeout_seconds, successThreshold=check_spec.success_threshold, failureThreshold=check_spec.failure_threshold, periodSeconds=check_spec.period_seconds) if check_spec.http: probe.httpGet = HTTPGetAction( path=check_spec.http.path, port=check_spec.http.port, httpHeaders=[ HTTPHeader(name=name, value=value) for name, value in check_spec.http.http_headers.items() ]) elif check_spec.tcp: probe.tcpSocket = TCPSocketAction(port=check_spec.tcp.port) elif check_spec.execute: probe._exec = ExecAction( command=shlex.split(check_spec.execute.command)) else: raise RuntimeError( "AppSpec must have exactly one health check, none was defined.") return probe