Skip to content
Merged
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
3 changes: 2 additions & 1 deletion Dockerfile.agent
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ EXPOSE 8001
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8001/api/public/health || exit 1

ENTRYPOINT ["python", "-m", "agent.start"]
ENTRYPOINT ["uvicorn", "agent.app:app"]
CMD ["--host", "0.0.0.0", "--port", "8001", "--log-level", "warning"]
12 changes: 0 additions & 12 deletions agent/start.py

This file was deleted.

39 changes: 39 additions & 0 deletions backend/alembic/versions/cdb22157557a_added_hosts_ssl_flag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""added hosts.ssl flag

Revision ID: cdb22157557a
Revises: 98851d1b3589
Create Date: 2026-01-28 00:08:11.318293

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "cdb22157557a"
down_revision: Union[str, Sequence[str], None] = "98851d1b3589"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Upgrade schema."""
with op.batch_alter_table("hosts") as batch_op:
batch_op.add_column(
sa.Column(
"ssl",
sa.Boolean(),
default=True,
server_default=sa.text("TRUE"),
nullable=False,
)
)


def downgrade() -> None:
"""Downgrade schema."""
with op.batch_alter_table("hosts") as batch_op:
batch_op.drop_column("ssl")
6 changes: 3 additions & 3 deletions backend/core/agent_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from python_on_whales.components.image.models import (
ImageInspectResult,
)
from python_on_whales.components.manifest.cli_wrapper import (
ManifestList,
)
from backend.exception import TugAgentClientError
from shared.schemas.command_schemas import RunCommandRequestBodySchema
from shared.schemas.container_schemas import (
Expand Down Expand Up @@ -39,6 +36,7 @@ def __init__(
url: str,
secret: str | None = None,
timeout: int = 5,
ssl: bool = True,
):
self._id = id
self._url = url
Expand All @@ -47,6 +45,7 @@ def __init__(
self._long_timeout = (
600 # timeout for potentially long requests
)
self._ssl = ssl
self.public = AgentClientPublic(self)
self.container = AgentClientContainer(self)
self.image = AgentClientImage(self)
Expand Down Expand Up @@ -84,6 +83,7 @@ async def _request(
headers=headers,
json=_body,
params=params,
ssl=self._ssl,
) as resp:
# Parse error manually to get detail
if resp.status >= 400:
Expand Down
2 changes: 1 addition & 1 deletion backend/core/hosts_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _create_client(cls, host: HostsModel) -> AgentClient:
filtered = {
k: v
for k, v in info.model_dump(exclude_unset=True).items()
if k in allowed_keys and v
if k in allowed_keys and v != None
}
return AgentClient(**filtered)

Expand Down
6 changes: 6 additions & 0 deletions backend/db/models/hosts_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class HostsModel(BaseModel):
secret: Mapped[Optional[str]] = mapped_column(
String, nullable=True
)
ssl: Mapped[bool] = mapped_column(
Boolean,
nullable=False,
default=True,
server_default=text("TRUE"),
)
timeout: Mapped[int] = mapped_column(
Integer, nullable=False, default=5, server_default=text("5")
)
Expand Down
1 change: 1 addition & 0 deletions backend/schemas/hosts_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class HostBase(BaseModel):
prune_all: bool
url: str
secret: Optional[str] = None
ssl: bool
timeout: int
container_hc_timeout: int

Expand Down
2 changes: 2 additions & 0 deletions frontend/public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
"URL": "Agent address",
"URL_PLACEHOLDER": "http://127.0.0.1:8001",
"SECRET": "Agent secret",
"SSL": "SSL",
"SSL_HINT": "Whether to use SSL verification for backend > agent requests.",
"TIMEOUT": "Agent timeout",
"TIMEOUT_HINT": "Timeout in seconds for typically fast agent requests. It does not affect potentially long requests such as container create or image pull.",
"CONTAINER_HC_TIMEOUT": "Container healthcheck timeout",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/entities/hosts/hosts-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ICreateHost {
prune_all: boolean;
url: string;
secret: string;
ssl: boolean;
timeout: number;
container_hc_timeout: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@
</label>
</p-iftaLabel>

<span
class="switch-field"
fluid
>
<p-toggle-switch
[inputId]="'host-ssl'"
formControlName="ssl"
></p-toggle-switch>
<label for="host-ssl">
{{ 'HOSTS.CARD.GENERAL.SSL' | translate }}
<i
class="pi pi-question-circle"
style="margin: 0 0.5rem"
[pTooltip]="'HOSTS.CARD.GENERAL.SSL_HINT' | translate"
tooltipPosition="left"
></i>
</label>
</span>

<p-iftaLabel fluid>
<p-iconfield>
<p-input-number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class HostsPageCard implements OnInit {
Validators.pattern(/^(http|https):\/\//),
]),
secret: new FormControl<string>(null),
ssl: new FormControl<boolean>(true),
timeout: new FormControl<number>(null, [Validators.required]),
container_hc_timeout: new FormControl(null, [Validators.required]),
});
Expand Down
2 changes: 1 addition & 1 deletion supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ autorestart=true
priority=10

[program:agent]
command=python -m agent.start
command=uvicorn agent.app:app --host 127.0.0.1 --port 8001 --log-level warning
directory=/app
autostart=%(ENV_AGENT_ENABLED)s
autorestart=true
Expand Down