Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions disco/endpoints/cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ async def stderr(text: str) -> None:
project_name,
service_name,
)
extra_run_params = disco_file.services[service_name].extra_run_params
await docker.run(
image=image,
project_name=project_name,
Expand All @@ -237,6 +238,13 @@ async def stderr(text: str) -> None:
stdin=content,
stdout=stdout,
stderr=stderr,
extra_params=[
param.strip()
for param in extra_run_params.split(" ")
if len(param.strip()) > 0
]
if extra_run_params is not None
else None,
)
if len(cgi_err) > 0:
log.info("Received stderr from CGI: %s", cgi_err)
Expand Down
11 changes: 11 additions & 0 deletions disco/utils/asyncworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ async def update_for_deployment(
self.next = self.cron.get_next(datetime)
self.schedule = schedule
self.timeout = disco_file.services[self.service_name].timeout
extra_run_params = disco_file.services[self.service_name].extra_run_params
self.extra_params = (
[
param.strip()
for param in extra_run_params.split(" ")
if len(param.strip()) > 0
]
if extra_run_params is not None
else None
)

async def run(self) -> None:
async def log_stdout(stdout: str) -> None:
Expand All @@ -227,6 +237,7 @@ async def log_stderr(stderr: str) -> None:
timeout=self.timeout,
stdout=log_stdout,
stderr=log_stderr,
extra_params=self.extra_params,
)

def schedule_next(self) -> None:
Expand Down
8 changes: 8 additions & 0 deletions disco/utils/commandruns.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ async def log_output_terminate():

name = f"{project_name}-run.{run_number}"
try:
extra_run_params = disco_file.services[service].extra_run_params
await docker.run(
image=image,
project_name=project_name,
Expand All @@ -92,6 +93,13 @@ async def log_output_terminate():
timeout=timeout,
stdout=log_output,
stderr=log_output,
extra_params=[
param.strip()
for param in extra_run_params.split(" ")
if len(param.strip()) > 0
]
if extra_run_params is not None
else None,
)
except TimeoutError:
await log_output(f"Timed out after {timeout} seconds\n")
Expand Down
14 changes: 14 additions & 0 deletions disco/utils/deploymentflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ async def run_hook_deploy_start_before(
timeout=service.timeout,
stdout=log_output,
stderr=log_output,
extra_params=[
param.strip()
for param in service.extra_run_params.split(" ")
if len(param.strip()) > 0
]
if service.extra_run_params is not None
else None,
)


Expand Down Expand Up @@ -456,6 +463,13 @@ async def run_hook_deploy_start_after(
timeout=service.timeout,
stdout=log_output,
stderr=log_output,
extra_params=[
param.strip()
for param in service.extra_run_params.split(" ")
if len(param.strip()) > 0
]
if service.extra_run_params is not None
else None,
)


Expand Down
4 changes: 4 additions & 0 deletions disco/utils/discofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class Service(BaseModel):
None,
alias="extraSwarmParams",
)
extra_run_params: str | None = Field(
None,
alias="extraRunParams",
)


class DiscoFile(BaseModel):
Expand Down
3 changes: 3 additions & 0 deletions disco/utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,10 +1017,13 @@ async def run(
stdin: AsyncGenerator[bytes, None] | None = None,
workdir: str | None = None,
timeout: int = 600,
extra_params: list[str] | None = None,
) -> None:
log.info("Docker run %s (%s)", name, image)
try:
more_args = []
if extra_params is not None:
more_args.extend(extra_params)
for var_name, var_value in env_variables:
more_args.append("--env")
more_args.append(f"{var_name}={var_value}")
Expand Down