Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix worker arm template name length #122

Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Worker created deployments will cut flow name length to not reach max 64 character deployment name length

### Deprecated

### Removed
Expand Down
12 changes: 12 additions & 0 deletions prefect_azure/workers/container_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
else:
from pydantic import Field, SecretStr

from slugify import slugify

from prefect_azure.container_instance import ACRManagedIdentity
from prefect_azure.credentials import AzureContainerInstanceCredentials

Expand Down Expand Up @@ -566,6 +568,16 @@ async def run(
flow = await prefect_client.read_flow(flow_run.flow_id)
container_group_name = f"{flow.name}-{flow_run.id}"

# Slugify flow.name if the generated name will be too long for the
# max deployment name length (64) including "prefect-"
if len(container_group_name) > 55:
slugified_flow_name = slugify(
flow.name,
max_length=55 - len(flow_run.id),
regex_pattern=r"[^a-zA-Z0-9-]+",
)
container_group_name = f"{slugified_flow_name}-{flow_run.id}"

self._logger.info(
f"{self._log_prefix}: Preparing to run command {configuration.command} "
f"in container {configuration.image})..."
Expand Down