:white_check_mark: thought for 378.6 seconds
# ask-marvin
m
thought for 378.6 seconds
Ciao! Grazie per i dettagli — qui ci sono i motivi più probabili per cui la tua Automation non è partita e come sistemarla. Due punti chiave nel tuo trigger: 1) threshold/within - Hai impostato
threshold: 5
e
within: 60
. Questo significa che l’automation scatterà solo dopo 5 eventi che corrispondono ai filtri entro 60 secondi. Dall’evento che hai incollato vedo un solo
prefect.flow-run.Failed
, quindi il trigger non ha raggiunto la soglia. - Se vuoi che parta al primo fallimento, imposta
threshold: 1
. 2) match vs match_related - Il campo
prefect.state-message
appartiene alla risorsa primaria dell’evento (vedi nel tuo payload: è dentro
resource
, non in
related
). Quindi va messo in
match
, non in
match_related
. Con
match_related
stai filtrando su risorse “collegate” (deployment, work-pool, ecc.), non sul flow-run stesso. Inoltre: - Il filtro
prefect.resource.id: ["prefect.flow-run.*"]
non è necessario, dato che stai già usando
expect: ["prefect.flow-run.Failed"]
, che limita il trigger ai soli eventi dei flow run in stato Failed. Può anche restringere inutilmente il matching. Ti consiglio di rimuoverlo per semplificare. - Filtrare su
prefect.state-message
è “fragile” perché il testo può cambiare. Se lo usi, assicurati che la stringa combaci esattamente (come nel tuo esempio). Proposta di configurazione minima che dovrebbe partire al primo fallimento da git_clone:
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
after: []
expect:
  - "prefect.flow-run.Failed"
posture: "Reactive"
threshold: 1
within: 60
Per l’azione: - In Prefect Cloud 2.x l’azione tipica è “Run deployment” / “Create flow run” (spesso con opzione “infer deployment” dall’evento). Assicurati che l’azione che hai scelto avvii un nuovo flow run dal deployment correlato. Se l’azione nel tuo workspace si chiama “Resume deployment”, verifica che in realtà stia creando/rilanciando un flow run del deployment associato (se vuoi, condividi uno screenshot dell’azione e la ricontrolliamo insieme). Suggerimenti pratici: - Nella UI usa “Preview matches” (se disponibile) o prova ad abbassare
threshold
a 1 e lanciare un fallimento di test per vedere se scatta. - Valuta di non dipendere esclusivamente dalla
state-message
e, se possibile, aggiungere altri filtri (es. limitare a uno specifico deployment usando
match_related
con l’id del deployment) per evitare false partenze. Riferimenti utili: - Automations in Prefect Cloud 2.x - Event triggers (match, match_related, threshold/within) Se il tuo obiettivo è “ri-tentare automaticamente quando il git clone/pull fallisce”, questa Automation con
threshold: 1
e azione “run deployment (infer from event)” è il modo giusto in Prefect 2.x, dato che il fallimento avviene prima di caricare il flow (quindi i retry del flow non si applicano). Vuoi che ti proponga una versione che limiti il trigger solo a un determinato deployment e con un minimo “backoff” tra tentativi per evitare loop rapidi? Posso fornirti un esempio completo.
m
@Marvin - ho fatto allora ho fatto in modo che un flow run fallise per quel motivo ecco l'evento: { "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect.flow-run.Failed", "occurred": "2025-09-23T142847.936Z", "payload": { "intended": { "from": "PENDING", "to": "FAILED" }, "initial_state": { "type": "PENDING", "name": "Pending", "timestamp": "2025-09-23T142839.293545+00:00", "id": "068d2ae9-74b2-7352-8000-34103d23ffc1" }, "validated_state": { "type": "FAILED", "name": "Failed", "message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "timestamp": "2025-09-23T142847.936945+00:00", "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12" } }, "received": "2025-09-23T142848.046Z", "related": [ { "prefect.resource.id": "prefect.flow.5d0d7048-44fc-40ec-a9d9-83f519dd8bec", "prefect.resource.role": "flow", "prefect.resource.name": "assets-uploader" }, { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "deployment", "prefect.resource.name": "bper-upload", "prefect.deployment.version-id": "068d2a50-7e9e-700e-8000-d152987ca352", "prefect.deployment.version-type": "prefect:simple", "prefect.deployment.version": "" }, { "prefect.resource.id": "prefect.work-queue.4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1", "prefect.resource.role": "work-queue", "prefect.resource.name": "default" }, { "prefect.resource.id": "prefect.work-pool.fe84b63b-38dc-4c81-b1cf-d9e23c48f014", "prefect.resource.role": "work-pool", "prefect.resource.name": "customer-workpool", "prefect.work-pool.type": "process" }, { "prefect.resource.id": "prefect.tag.BPER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.tag.CUSTOMER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect-cloud.user.83007882-d244-469e-919f-a2361cfaeb2f", "prefect.resource.role": "creator", "prefect.resource.name": "kappa585-sen" } ], "resource": { "prefect.resource.id": "prefect.flow-run.068d2ae9-20de-7fc5-8000-8033aa5d38ec", "prefect.resource.name": "competent-chachalaca", "prefect.run-count": "0", "prefect.state-message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "prefect.state-name": "Failed", "prefect.state-timestamp": "2025-09-23T142847.936945+00:00", "prefect.state-type": "FAILED" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } è partita l'automation triggered { "id": "068d2aea-084f-79c0-8000-ecf8262f0bd4", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect-cloud.automation.triggered", "occurred": "2025-09-23T142848.518Z", "payload": { "triggering_labels": {}, "triggering_event": { "occurred": "2025-09-23T142847.936945Z", "event": "prefect.flow-run.Failed", "resource": { "prefect.resource.id": "prefect.flow-run.068d2ae9-20de-7fc5-8000-8033aa5d38ec", "prefect.resource.name": "competent-chachalaca", "prefect.run-count": "0", "prefect.state-message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "prefect.state-name": "Failed", "prefect.state-timestamp": "2025-09-23T142847.936945+00:00", "prefect.state-type": "FAILED" }, "related": [ { "prefect.resource.id": "prefect.flow.5d0d7048-44fc-40ec-a9d9-83f519dd8bec", "prefect.resource.role": "flow", "prefect.resource.name": "assets-uploader" }, { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "deployment", "prefect.resource.name": "bper-upload", "prefect.deployment.version-id": "068d2a50-7e9e-700e-8000-d152987ca352", "prefect.deployment.version-type": "prefect:simple", "prefect.deployment.version": "" }, { "prefect.resource.id": "prefect.work-queue.4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1", "prefect.resource.role": "work-queue", "prefect.resource.name": "default" }, { "prefect.resource.id": "prefect.work-pool.fe84b63b-38dc-4c81-b1cf-d9e23c48f014", "prefect.resource.role": "work-pool", "prefect.resource.name": "customer-workpool", "prefect.work-pool.type": "process" }, { "prefect.resource.id": "prefect.tag.BPER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.tag.CUSTOMER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect-cloud.user.83007882-d244-469e-919f-a2361cfaeb2f", "prefect.resource.role": "creator", "prefect.resource.name": "kappa585-sen" } ], "payload": { "intended": { "from": "PENDING", "to": "FAILED" }, "initial_state": { "type": "PENDING", "name": "Pending", "timestamp": "2025-09-23T142839.293545+00:00", "id": "068d2ae9-74b2-7352-8000-34103d23ffc1" }, "validated_state": { "type": "FAILED", "name": "Failed", "message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "timestamp": "2025-09-23T142847.936945+00:00", "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12" } }, "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12", "follows": "068d2ae9-74b2-7352-8000-34103d23ffc1", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "workspace": "2594e140-0794-4088-9494-2597c8db464c", "received": "2025-09-23T142848.046951Z" } }, "received": "2025-09-23T142848.519Z", "related": [ { "prefect.resource.id": "prefect-cloud.event.068d2ae9-fefd-75da-8000-d5d71a32bc12", "prefect.resource.role": "triggering-event" } ], "resource": { "prefect.resource.id": "prefect-cloud.automation.29095e82-298f-46da-9626-e1452fe586a4", "prefect.resource.name": "Retry - git clone failed", "prefect-cloud.posture": "Reactive" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } l'automation action triggered { "id": "068d2aea-0a47-793c-8000-dd61f9424b79", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect-cloud.automation.action.triggered", "occurred": "2025-09-23T142848.518Z", "payload": { "action_index": 0, "action_type": "resume-deployment", "invocation": "068d2aea-0897-7e6d-8000-40831aee26b2" }, "received": "2025-09-23T142848.642Z", "related": [ { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "target" } ], "resource": { "prefect.resource.id": "prefect-cloud.automation.29095e82-298f-46da-9626-e1452fe586a4", "prefect.resource.name": "Retry - git clone failed", "prefect-cloud.trigger-type": "event", "prefect-cloud.posture": "Reactive" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } automation action executed { "id": "068d2aea-0a48-7556-8000-1b304b6ae484", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect-cloud.automation.action.executed", "occurred": "2025-09-23T142848.642Z", "payload": { "action_index": 0, "action_type": "resume-deployment", "invocation": "068d2aea-0897-7e6d-8000-40831aee26b2", "status_code": 200 }, "received": "2025-09-23T142848.642Z", "related": [ { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "target" } ], "resource": { "prefect.resource.id": "prefect-cloud.automation.29095e82-298f-46da-9626-e1452fe586a4", "prefect.resource.name": "Retry - git clone failed", "prefect-cloud.trigger-type": "event", "prefect-cloud.posture": "Reactive" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } e poi ha regstrato questi due eventi { "id": "125e469b-67ff-4f8b-9009-724f191400c1", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect.worker.submitted-flow-run", "occurred": "2025-09-23T142859.967Z", "payload": {}, "received": "2025-09-23T142840.412Z", "related": [ { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "deployment", "prefect.resource.name": "bper-upload" }, { "prefect.resource.id": "prefect.flow.5d0d7048-44fc-40ec-a9d9-83f519dd8bec", "prefect.resource.role": "flow", "prefect.resource.name": "assets-uploader" }, { "prefect.resource.id": "prefect.flow-run.068d2ae9-20de-7fc5-8000-8033aa5d38ec", "prefect.resource.role": "flow-run", "prefect.resource.name": "competent-chachalaca" }, { "prefect.resource.id": "prefect.tag.BPER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.tag.CUSTOMER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.work-pool.fe84b63b-38dc-4c81-b1cf-d9e23c48f014", "prefect.resource.role": "work-pool", "prefect.resource.name": "customer-workpool" } ], "resource": { "prefect.resource.id": "prefect.worker.process.processworker-9434d040-6c6b-4005-8bbf-51a08760429e", "prefect.resource.name": "ProcessWorker 9434d040-6c6b-4005-8bbf-51a08760429e", "prefect.version": "2.17.1", "prefect.worker-type": "process" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } { "id": "e100df9e-5218-44dc-a1fc-a7eee137433a", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect.worker.executed-flow-run", "occurred": "2025-09-23T142909.122Z", "payload": {}, "received": "2025-09-23T142849.026Z", "related": [ { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "deployment", "prefect.resource.name": "bper-upload" }, { "prefect.resource.id": "prefect.flow.5d0d7048-44fc-40ec-a9d9-83f519dd8bec", "prefect.resource.role": "flow", "prefect.resource.name": "assets-uploader" }, { "prefect.resource.id": "prefect.flow-run.068d2ae9-20de-7fc5-8000-8033aa5d38ec", "prefect.resource.role": "flow-run", "prefect.resource.name": "competent-chachalaca", "prefect.infrastructure.identifier": "15064", "prefect.infrastructure.status-code": "0" }, { "prefect.resource.id": "prefect.tag.BPER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.tag.CUSTOMER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.work-pool.fe84b63b-38dc-4c81-b1cf-d9e23c48f014", "prefect.resource.role": "work-pool", "prefect.resource.name": "customer-workpool" } ], "resource": { "prefect.resource.id": "prefect.worker.process.processworker-9434d040-6c6b-4005-8bbf-51a08760429e", "prefect.resource.name": "ProcessWorker 9434d040-6c6b-4005-8bbf-51a08760429e", "prefect.version": "2.17.1", "prefect.worker-type": "process" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } ma il deployment non è stato fatto ripartire
m
Your message was too long, here's your message at the allowed limit: - ho fatto allora ho fatto in modo che un flow run fallise per quel motivo ecco l'evento { id 068d2ae9-fefd-75da-8000-d5d71a32bc12 account cee6a56e-3348-4a6b-9393-390bb5d6e39f event prefect flow-run Failed occurred 2025-09-23T14 28 47 936Z payload { intended { from PENDING to FAILED } initial_state { type PENDING name Pending timestamp 2025-09-23T14 28 39 293545+00 00 id 068d2ae9-74b2-7352-8000-34103d23ffc1 } validated_state { type FAILED name Failed message Flow could not be retrieved from deployment StepExecutionError Encountered error while running prefect deployments steps git_clone timestamp 2025-09-23T14 28 47 936945+00 00 id 068d2ae9-fefd-75da-8000-d5d71a32bc12 } } received 2025-09-23T14 28 48 046Z related [ { prefect resource id prefect flow 5d0d7048-44fc-40ec-a9d9-83f519dd8bec prefect resource role flow prefect resource name assets-uploader } { prefect resource id prefect deployment 2cf7ff68-db33-4b35-98d8-ad067ab5e4aa prefect resource role deployment prefect resource name bper-upload prefect deployment version-id 068d2a50-7e9e-700e-8000-d152987ca352 prefect deployment version-type prefect simple prefect deployment version } { prefect resource id prefect work-queue 4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1 prefect resource role work-queue prefect resource name default } { prefect resource id prefect work-pool fe84b63b-38dc-4c81-b1cf-d9e23c48f014 prefect resource role work-pool prefect resource name customer-workpool prefect work-pool type process } { prefect resource id prefect tag BPER prefect resource role tag } { prefect resource id prefect tag CUSTOMER prefect resource role tag } { prefect resource id prefect-cloud user 83007882-d244-469e-919f-a2361cfaeb2f prefect resource role creator prefect resource name kappa585-sen } ] resource { prefect resource id prefect flow-run 068d2ae9-20de-7fc5-8000-8033aa5d38ec prefect resource name competent-chachalaca prefect run-count 0 prefect state-message Flow could not be retrieved from deployment StepExecutionError Encountered error while running prefect deployments steps git_clone prefect state-name Failed prefect state-timestamp 2025-09-23T14 28 47 936945+00 00 prefect state-type FAILED } workspace 2594e140-0794-4088-9494-2597c8db464c } è partita l'automation triggered { id 068d2aea-084f-79c0-8000-ecf8262f0bd4 account cee6a56e-3348-4a6b-9393-390bb5d6e39f event prefect-cloud automation triggered occurred 2025-09-23T14 28 48 518Z payload { triggering_labels {} triggering_event { occurred 2025-09-23T14 28 47 936945Z event prefect flow-run Failed resource { prefect resource id prefect flow-run 068d2ae9-20de-7fc5-8000-8033aa5d38ec prefect resource name competent-chachalaca prefect run-count 0 prefect state-message Flow could not be retrieved from deployment StepExecutionError Encountered error while running prefect deployments steps git_clone prefect state-name Failed prefect state-timestamp 2025-09-23T14 28 47 936945+00 00 prefect state-type FAILED } related [ { prefect resource id prefect flow 5d0d7048-44fc-40ec-a9d9-83f519dd8bec prefect resource role flow prefect resource name assets-uploader } { prefect resource id prefect deployment 2cf7ff68-db33-4b35-98d8-ad067ab5e4aa prefect resource role deployment prefect resource name bper-upload prefect deployment version-id 068d2a50-7e9e-700e-8000-d152987ca352 prefect deployment version-type prefect simple prefect deployment version } { prefect resource id prefect work-queue 4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1 prefect resource role work-queue prefect resource name default } { prefect resource id prefect work-pool fe84b63b-38dc-4c81-b1cf-d9e23c48f014 prefect resource role work-pool prefect resource name customer-workpool prefect work-pool type process } { prefect resource id prefect tag BPER prefect resource role tag } { prefect resource id prefect tag CUSTOMER prefect resource role tag } { prefect resource id prefect-cloud user 83007882-d244-469e-919f-a2361cfaeb2f prefec
t resource role creator prefect resource name kappa585-sen } ] payload { intended { from PENDING to FAILED } initial_state { type PENDING name Pending timestamp 2025-09-23T14 28 39 293545+00 00 id 068d2ae9-74b2-7352-8000-34103d23ffc1 } validated_state { type FAILED name Failed
m
@Marvin ho fatto in modo che un flow run fallise per quel motivo ecco l'evento: { "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect.flow-run.Failed", "occurred": "2025-09-23T142847.936Z", "payload": { "intended": { "from": "PENDING", "to": "FAILED" }, "initial_state": { "type": "PENDING", "name": "Pending", "timestamp": "2025-09-23T142839.293545+00:00", "id": "068d2ae9-74b2-7352-8000-34103d23ffc1" }, "validated_state": { "type": "FAILED", "name": "Failed", "message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "timestamp": "2025-09-23T142847.936945+00:00", "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12" } }, "received": "2025-09-23T142848.046Z", "related": [ { "prefect.resource.id": "prefect.flow.5d0d7048-44fc-40ec-a9d9-83f519dd8bec", "prefect.resource.role": "flow", "prefect.resource.name": "assets-uploader" }, { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "deployment", "prefect.resource.name": "bper-upload", "prefect.deployment.version-id": "068d2a50-7e9e-700e-8000-d152987ca352", "prefect.deployment.version-type": "prefect:simple", "prefect.deployment.version": "" }, { "prefect.resource.id": "prefect.work-queue.4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1", "prefect.resource.role": "work-queue", "prefect.resource.name": "default" }, { "prefect.resource.id": "prefect.work-pool.fe84b63b-38dc-4c81-b1cf-d9e23c48f014", "prefect.resource.role": "work-pool", "prefect.resource.name": "customer-workpool", "prefect.work-pool.type": "process" }, { "prefect.resource.id": "prefect.tag.BPER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.tag.CUSTOMER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect-cloud.user.83007882-d244-469e-919f-a2361cfaeb2f", "prefect.resource.role": "creator", "prefect.resource.name": "kappa585-sen" } ], "resource": { "prefect.resource.id": "prefect.flow-run.068d2ae9-20de-7fc5-8000-8033aa5d38ec", "prefect.resource.name": "competent-chachalaca", "prefect.run-count": "0", "prefect.state-message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "prefect.state-name": "Failed", "prefect.state-timestamp": "2025-09-23T142847.936945+00:00", "prefect.state-type": "FAILED" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } è partita l'automation triggered { "id": "068d2aea-084f-79c0-8000-ecf8262f0bd4", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect-cloud.automation.triggered", "occurred": "2025-09-23T142848.518Z", "payload": { "triggering_labels": {}, "triggering_event": { "occurred": "2025-09-23T142847.936945Z", "event": "prefect.flow-run.Failed", "resource": { "prefect.resource.id": "prefect.flow-run.068d2ae9-20de-7fc5-8000-8033aa5d38ec", "prefect.resource.name": "competent-chachalaca", "prefect.run-count": "0", "prefect.state-message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "prefect.state-name": "Failed", "prefect.state-timestamp": "2025-09-23T142847.936945+00:00", "prefect.state-type": "FAILED" }, "related": [ { "prefect.resource.id": "prefect.flow.5d0d7048-44fc-40ec-a9d9-83f519dd8bec", "prefect.resource.role": "flow", "prefect.resource.name": "assets-uploader" }, { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "deployment", "prefect.resource.name": "bper-upload", "prefect.deployment.version-id": "068d2a50-7e9e-700e-8000-d152987ca352", "prefect.deployment.version-type": "prefect:simple", "prefect.deployment.version": "" }, { "prefect.resource.id": "prefect.work-queue.4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1", "prefect.resource.role": "work-queue", "prefect.resource.name": "default" }, { "prefect.resource.id": "prefect.work-pool.fe84b63b-38dc-4c81-b1cf-d9e23c48f014", "prefect.resource.role": "work-pool", "prefect.resource.name": "customer-workpool", "prefect.work-pool.type": "process" }, { "prefect.resource.id": "prefect.tag.BPER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect.tag.CUSTOMER", "prefect.resource.role": "tag" }, { "prefect.resource.id": "prefect-cloud.user.83007882-d244-469e-919f-a2361cfaeb2f", "prefect.resource.role": "creator", "prefect.resource.name": "kappa585-sen" } ], "payload": { "intended": { "from": "PENDING", "to": "FAILED" }, "initial_state": { "type": "PENDING", "name": "Pending", "timestamp": "2025-09-23T142839.293545+00:00", "id": "068d2ae9-74b2-7352-8000-34103d23ffc1" }, "validated_state": { "type": "FAILED", "name": "Failed", "message": "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone", "timestamp": "2025-09-23T142847.936945+00:00", "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12" } }, "id": "068d2ae9-fefd-75da-8000-d5d71a32bc12", "follows": "068d2ae9-74b2-7352-8000-34103d23ffc1", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "workspace": "2594e140-0794-4088-9494-2597c8db464c", "received": "2025-09-23T142848.046951Z" } }, "received": "2025-09-23T142848.519Z", "related": [ { "prefect.resource.id": "prefect-cloud.event.068d2ae9-fefd-75da-8000-d5d71a32bc12", "prefect.resource.role": "triggering-event" } ], "resource": { "prefect.resource.id": "prefect-cloud.automation.29095e82-298f-46da-9626-e1452fe586a4", "prefect.resource.name": "Retry - git clone failed", "prefect-cloud.posture": "Reactive" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } l'automation action triggered { "id": "068d2aea-0a47-793c-8000-dd61f9424b79", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect-cloud.automation.action.triggered", "occurred": "2025-09-23T142848.518Z", "payload": { "action_index": 0, "action_type": "resume-deployment", "invocation": "068d2aea-0897-7e6d-8000-40831aee26b2" }, "received": "2025-09-23T142848.642Z", "related": [ { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "target" } ], "resource": { "prefect.resource.id": "prefect-cloud.automation.29095e82-298f-46da-9626-e1452fe586a4", "prefect.resource.name": "Retry - git clone failed", "prefect-cloud.trigger-type": "event", "prefect-cloud.posture": "Reactive" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } automation action executed { "id": "068d2aea-0a48-7556-8000-1b304b6ae484", "account": "cee6a56e-3348-4a6b-9393-390bb5d6e39f", "event": "prefect-cloud.automation.action.executed", "occurred": "2025-09-23T142848.642Z", "payload": { "action_index": 0, "action_type": "resume-deployment", "invocation": "068d2aea-0897-7e6d-8000-40831aee26b2", "status_code": 200 }, "received": "2025-09-23T142848.642Z", "related": [ { "prefect.resource.id": "prefect.deployment.2cf7ff68-db33-4b35-98d8-ad067ab5e4aa", "prefect.resource.role": "target" } ], "resource": { "prefect.resource.id": "prefect-cloud.automation.29095e82-298f-46da-9626-e1452fe586a4", "prefect.resource.name": "Retry - git clone failed", "prefect-cloud.trigger-type": "event", "prefect-cloud.posture": "Reactive" }, "workspace": "2594e140-0794-4088-9494-2597c8db464c" } ma il deployment non è stato fatto ripartire
m
Your message was too long, here's your message at the allowed limit: ho fatto in modo che un flow run fallise per quel motivo ecco l'evento { id 068d2ae9-fefd-75da-8000-d5d71a32bc12 account cee6a56e-3348-4a6b-9393-390bb5d6e39f event prefect flow-run Failed occurred 2025-09-23T14 28 47 936Z payload { intended { from PENDING to FAILED } initial_state { type PENDING name Pending timestamp 2025-09-23T14 28 39 293545+00 00 id 068d2ae9-74b2-7352-8000-34103d23ffc1 } validated_state { type FAILED name Failed message Flow could not be retrieved from deployment StepExecutionError Encountered error while running prefect deployments steps git_clone timestamp 2025-09-23T14 28 47 936945+00 00 id 068d2ae9-fefd-75da-8000-d5d71a32bc12 } } received 2025-09-23T14 28 48 046Z related [ { prefect resource id prefect flow 5d0d7048-44fc-40ec-a9d9-83f519dd8bec prefect resource role flow prefect resource name assets-uploader } { prefect resource id prefect deployment 2cf7ff68-db33-4b35-98d8-ad067ab5e4aa prefect resource role deployment prefect resource name bper-upload prefect deployment version-id 068d2a50-7e9e-700e-8000-d152987ca352 prefect deployment version-type prefect simple prefect deployment version } { prefect resource id prefect work-queue 4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1 prefect resource role work-queue prefect resource name default } { prefect resource id prefect work-pool fe84b63b-38dc-4c81-b1cf-d9e23c48f014 prefect resource role work-pool prefect resource name customer-workpool prefect work-pool type process } { prefect resource id prefect tag BPER prefect resource role tag } { prefect resource id prefect tag CUSTOMER prefect resource role tag } { prefect resource id prefect-cloud user 83007882-d244-469e-919f-a2361cfaeb2f prefect resource role creator prefect resource name kappa585-sen } ] resource { prefect resource id prefect flow-run 068d2ae9-20de-7fc5-8000-8033aa5d38ec prefect resource name competent-chachalaca prefect run-count 0 prefect state-message Flow could not be retrieved from deployment StepExecutionError Encountered error while running prefect deployments steps git_clone prefect state-name Failed prefect state-timestamp 2025-09-23T14 28 47 936945+00 00 prefect state-type FAILED } workspace 2594e140-0794-4088-9494-2597c8db464c } è partita l'automation triggered { id 068d2aea-084f-79c0-8000-ecf8262f0bd4 account cee6a56e-3348-4a6b-9393-390bb5d6e39f event prefect-cloud automation triggered occurred 2025-09-23T14 28 48 518Z payload { triggering_labels {} triggering_event { occurred 2025-09-23T14 28 47 936945Z event prefect flow-run Failed resource { prefect resource id prefect flow-run 068d2ae9-20de-7fc5-8000-8033aa5d38ec prefect resource name competent-chachalaca prefect run-count 0 prefect state-message Flow could not be retrieved from deployment StepExecutionError Encountered error while running prefect deployments steps git_clone prefect state-name Failed prefect state-timestamp 2025-09-23T14 28 47 936945+00 00 prefect state-type FAILED } related [ { prefect resource id prefect flow 5d0d7048-44fc-40ec-a9d9-83f519dd8bec prefect resource role flow prefect resource name assets-uploader } { prefect resource id prefect deployment 2cf7ff68-db33-4b35-98d8-ad067ab5e4aa prefect resource role deployment prefect resource name bper-upload prefect deployment version-id 068d2a50-7e9e-700e-8000-d152987ca352 prefect deployment version-type prefect simple prefect deployment version } { prefect resource id prefect work-queue 4d08aff9-34c0-43f4-9e47-cd4e3a3b1ec1 prefect resource role work-queue prefect resource name default } { prefect resource id prefect work-pool fe84b63b-38dc-4c81-b1cf-d9e23c48f014 prefect resource role work-pool prefect resource name customer-workpool prefect work-pool type process } { prefect resource id prefect tag BPER prefect resource role tag } { prefect resource id prefect tag CUSTOMER prefect resource role tag } { prefect resource id prefect-cloud user 83007882-d244-469e-919f-a2361cfaeb2f prefect resource role cr
eator prefect resource name kappa585-sen } ] payload { intended { from PENDING to FAILED } initial_state { type PENDING name Pending timestamp 2025-09-23T14 28 39 293545+00 00 id 068d2ae9-74b2-7352-8000-34103d23ffc1 } validated_state { type FAILED name Failed message Flow could not
thought for 152.9 seconds
Grazie per la sequenza di eventi — è molto utile. Il comportamento che descrivi è coerente con questa situazione: - L’azione che hai configurato è “resume-deployment”. - In Prefect Cloud 2.x, “resume deployment” riprende/riattiva la schedule del deployment (se era in pausa), ma non crea un nuovo flow run. Quindi l’API risponde 200, ma non parte nessuna nuova esecuzione. Se la schedule non era in pausa, “resume” non ha effetto visibile. Per ottenere il retry dopo il fallimento di
git_clone
, devi usare un’azione che CREI un nuovo flow run, non che modifichi lo stato della schedule. In UI questa azione è tipicamente “Run a deployment” (a volte chiamata “Create flow run”), con “infer deployment” dall’evento. Cosa fare subito - Modifica l’Automation sostituendo l’azione “resume-deployment” con “run-deployment” (o “create flow run”) e imposta “deployment: infer from event”. - Se vuoi farla partire al primo fallimento, tieni
threshold: 1
. Esempio di trigger + azione che crea una nuova run
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
expect:
  - "prefect.flow-run.Failed"
posture: Reactive
threshold: 1
within: 300
actions:
  - type: run-deployment
    deployment: infer
    parameters: {}   # opzionale: aggiungi parametri se servono
Note e suggerimenti - “Infer deployment” funziona perché l’evento
prefect.flow-run.Failed
include il deployment correlato nei
related
. L’azione “run-deployment” userà quell’ID per creare una nuova run. - Se devi ripassare gli stessi parametri della run fallita, confermami come li imposti (statici vs dinamici) e ti propongo il modo migliore; in alcuni casi conviene fissarli nell’azione, oppure leggere dal contesto evento se disponibile. - Attenzione ai loop: se
git_clone
continua a fallire, ogni run fallita innescherà un’altra run. Puoi mitigare con: -
threshold/within
per limitare la frequenza (es. max 3 tentativi in 10 min) - una seconda automation che, dopo N fallimenti, disabilita la schedule o invia un alert invece di rilanciare. Vuoi che ti prepari una versione “anti-loop” che faccia fino a 3 retry in 10 minuti e poi smetta di rilanciare, magari inviando una notifica?
m
@Marvin si va bene
m
thought for 163.9 seconds
Perfetto — ti propongo due soluzioni “anti-loop”. La 1ª è la più robusta e semplice da governare in Prefect 2.x. Soluzione A (robusta): catena di retry con deployment separati Idea: crei 3 deployment “retry” che puntano allo stesso flow/codice, e ogni Automation instrada il fallimento al prossimo deployment. Così eviti loop perché ogni Automation reagisce solo ai fallimenti del “suo” deployment. Passi: 1) Crea/duplica 3 deployment aggiuntivi: - <flow-name>/retry-1 - <flow-name>/retry-2 - <flow-name>/retry-3 2) Crea 4 Automations (tutte con trigger Reactive, within 600s = 10 min) - Automation 1 — dal base a retry-1
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
match_related:
  # limita al deployment "base"
  prefect.resource.id:
    - "prefect.deployment.<ID_DEL_BASE>"
expect:
  - "prefect.flow-run.Failed"
posture: Reactive
threshold: 1
within: 600
actions:
  - type: run-deployment
    deployment: "prefect.deployment.<ID_RETRY_1>"
    parameters: {}
- Automation 2 — da retry-1 a retry-2
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
match_related:
  prefect.resource.id:
    - "prefect.deployment.<ID_RETRY_1>"
expect:
  - "prefect.flow-run.Failed"
posture: Reactive
threshold: 1
within: 600
actions:
  - type: run-deployment
    deployment: "prefect.deployment.<ID_RETRY_2>"
- Automation 3 — da retry-2 a retry-3
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
match_related:
  prefect.resource.id:
    - "prefect.deployment.<ID_RETRY_2>"
expect:
  - "prefect.flow-run.Failed"
posture: Reactive
threshold: 1
within: 600
actions:
  - type: run-deployment
    deployment: "prefect.deployment.<ID_RETRY_3>"
- Automation 4 — dopo retry-3, stop e avvisa
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
match_related:
  prefect.resource.id:
    - "prefect.deployment.<ID_RETRY_3>"
expect:
  - "prefect.flow-run.Failed"
posture: Reactive
threshold: 1
within: 600
actions:
  - type: send-notification
    # il tuo canale (Slack/Email/etc.)
    recipient: "<il_tuo_canale>"
    message: "Git clone failed 3 times in 10m for <flow/deployment>. Manual intervention required."
  # opzionale: pausa la schedule del base per sicurezza
  - type: pause-schedule
    deployment: "prefect.deployment.<ID_DEL_BASE>"
Note importanti: - Usa gli ID reali dei deployment (li trovi nell’evento nei related oppure dalla UI). - L’azione è “run-deployment” (non “resume-deployment”). - Questa catena garantisce fino a 3 retry senza loop, perché ogni Automation ascolta SOLO i fallimenti del suo deployment specifico. Soluzione B (alternativa con tag; più delicata) - È possibile farlo con 3 automations a “stadi” basati su tag (retry-1/2/3), ma dipende da come l’azione “Run deployment” imposta i tag sulla nuova run (se li sostituisce o li unisce ai tag del deployment). Per evitare ambiguità e loop, la soluzione con deployment separati è preferibile in 2.x. Consigli extra per ridurre i fallimenti git: - Se possibile, avvolgi il pull step
git_clone
con un retry/backoff lato shell (es. step custom che tenta 3 volte con sleep esponenziale). Questo evita di dover ricorrere al rilancio completo del deployment per transitori di rete. - Documentazione Automations: Automations in Prefect Cloud 2.x
Vuoi che prepari noi i 4 trigger direttamente (se mi dai gli ID dei deployment) oppure preferisci uno screenshot guida per configurarli in UI?
m
@Marvin in realtà mi va bene il loop quindi va bene così --> { "type": "event", "match": { "prefect.state-message": [ "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone" ] }, "match_related": {}, "after": [], "expect": [ "prefect.flow-run.Failed" ], "for_each": [], "posture": "Reactive", "threshold": 1, "within": 60 } --> unica cosa il within 60 non mi piace, volgio che ogni volta che un evento del genere succede faccia il rilancio del deployment
m
thought for 59.4 seconds
Perfetto — per avere un “rilancio” ad ogni singolo evento di fallimento del git clone: - Con
threshold: 1
, l’automazione scatta per ogni evento che matcha. In questo caso
within
non aggrega nulla: puoi lasciarlo così, ridurlo a
0
, oppure ometterlo (se la UI lo consente). Mettere
within: 0
rende esplicito che non vuoi alcuna finestra temporale. Esempio minimale del trigger:
Copy code
type: event
match:
  prefect.state-message:
    - "Flow could not be retrieved from deployment. StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone"
expect:
  - "prefect.flow-run.Failed"
posture: Reactive
threshold: 1
within: 0
Punti critici da verificare: - Azione: usa “Run deployment” / “Create flow run” con “infer deployment from event” (non “Resume deployment”, che riattiva la schedule ma non crea una nuova run). - Il match su
prefect.state-message
è un match esatto; se il testo cambia anche di poco, non scatterà. Se dovesse capitare spesso, possiamo aggiungere filtri alternativi (es. limitare per deployment in
match_related
) o rimuovere la dipendenza dal messaggio. Nota sul loop: - Così com’è, ogni fallimento in
git_clone
rilancerà immediatamente il deployment e potresti avere molte run in coda se il problema persiste. Se in futuro vuoi introdurre un “paracadute”, puoi aggiungere una seconda automation che dopo N fallimenti in M minuti invii una notifica o metta in pausa la schedule. Riferimenti: - Automations in Prefect Cloud 2.x Se vuoi, condividi uno screenshot dell’azione in UI e ti confermo che è impostata su “Run deployment (infer)”.