PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.97k stars 1.57k forks source link

Invalid names being generated for Azure Container Instance runs #13708

Closed bjorhn closed 2 months ago

bjorhn commented 4 months ago

First check

Bug summary

There's something wrong with the logic in container_instance.py for workers. I can use job_variables to override the name for the azure container instances container group that should be created in Azure, using the "name" variable, but only if the name of the flow itself is over a certain character length. If it's under that character length, the "name" variable is ignored and Prefect attempts to create the Azure resource using the flow name instead. This doesn't work, since the flow name, in my case, contains invalid characters such as spaces.

I have tried this with the following two flows: Keyvault Notification (with the name in job_variables set to "keyvault-notification" - this works Refresh PBI (with the name in job_variables set to "refresh-pbi" - this doesn't work

If I change the name of the Refresh PBI flow to Refresh PBIWorkerTest, which is the same character length as Keyvault Notification, everything works as expected. Everything also works as expected when using agents instead of workers.

Reproduction

Don't have an MRE at the moment, sorry.

Error

The provided deployment name 'prefect-Refresh PBI-77de0178-0dc6-4c17-a1fe-3c79cb0a7528' has these invalid characters: ' '

Versions

2.19.2

Additional context

No response

bjorhn commented 3 months ago

I compared the code for the old ACI agents with the worker code and I've found the source of the problem:

I think this could be dealt with in two ways. Either the name job variable should be used instead of the flow name, like how the agent implemented it, or the slugify code path should be used regardless of how long the flow name is. The latter should be easier to implement, but will result in us remaining unable to manually set the name of the container group separately from the flow name.