https://prefect.io logo
m

Matthias

05/07/2020, 2:01 PM
How does the Prefect agent get notified of new flows? I am running the agent in a Docker container and it is active and connected to apollo. Also I mapped the .prefect directory as a volume. But the Agent does not pick up new flows (when clicking run in the UI). When I run
prefect agent start
in my main Docker container the process picks up the flows
👀 1
n

nicholas

05/07/2020, 2:14 PM
Hi @Matthias! Would you mind trying:
export PREFECT__CLOUD__API={docker.url}:{port}
? Replacing the stuff in curly braces with your exposed docker setup?
(probably localhost and whatever port you've exposed for apollo)
Oh and then restarting the agent after, sorry!
m

Matthias

05/07/2020, 2:27 PM
Hi @nicholas ! Thanks, but that did not do the trick
n

nicholas

05/07/2020, 2:38 PM
Ah I misunderstood, sorry. The way the agent works is it polls the server every ~10 seconds. So the agent in the container needs to have access to your apollo server (be default this is localhost:4200 for Prefect Server), and it needs to be correctly pointed wherever that is.
Oh! Have you run
prefect backend server
?
m

Matthias

05/07/2020, 2:50 PM
Everything is set up like that. I even tried to curl the graphql out of the agent Container and I got the results. Still, it does not act on available flows. Really strange. I‘ll investigate further. Is there a way to get logs from the agent?
n

nicholas

05/07/2020, 2:51 PM
Strange indeed. You can start the agent with the
--verbose
flag to get some more info from it
One other thing to investigate: what are the labels you're using on your registered flows and does your agent have labels to match?
m

Matthias

05/07/2020, 3:03 PM
Huh, I assume it is related to the label. The registration seems to default to the hostname, and by default includes this as a label when running the agent. When I run the agent in a different containter, the hostname is different and there are no matching labels
I’ll dig into this. It should be fine to run the agent like this
prefect agent start --label prod
and to register the flow like this
flow.register(labels=["prod"])
, to match right?
n

nicholas

05/07/2020, 3:05 PM
That would make sense since it sounds like you're running the Local Agent. One thing to note there is that the agent will need access to the flows that you're registering, probably by specifying storage of some sort
Yup that'll match the labels! But the agent, since it's in a container, will need to have access to wherever your flow lives, whether that's a docker image, gcs, etc
m

Matthias

05/07/2020, 3:06 PM
yes, i am making sure of that
Thanks!
n

nicholas

05/07/2020, 3:07 PM
Great! Let me know if you get it solved 🙂
m

Matthias

05/07/2020, 3:08 PM
Would it throw an error, if the agent gets a flow from apollo, but does not find it in storage?
n

nicholas

05/07/2020, 3:08 PM
I think it will
I believe the flow runner will fail to start
m

Matthias

05/07/2020, 3:09 PM
so the setup with the label as I described above did not work yet.
Still strange 😄
n

nicholas

05/07/2020, 3:12 PM
Hm, are you able to send a minimum repro of your flow?
m

Matthias

05/07/2020, 4:25 PM
I’ll try to create something. Nothing public right now :/
n

nicholas

05/07/2020, 4:27 PM
Something that was brought to my attention was that if you're using LocalStorage for your flows, even if you're making the actual filesystem available to your agent container, there will be extra labels added to the flow by default. So when you're starting your agent, the agent will need to have all the labels your flow has, something like this:
prefect agent start --label prod -l HOSTNAME -l etc
m

Matthias

05/07/2020, 6:18 PM
That was it! Thanks so much 🙂
😄 1