https://prefect.io logo
n

Nate Jahncke

04/09/2021, 10:18 PM
Hi everyone, I'm new to Prefect and assume it will be a great product to use once I actually have it working. Thank you for all the effort you've put into it, and for making it free to evaluate effectively. I'm attempting to integrate Prefect into an existing docker-compose development environment. Running
prefect server start
yields a functional deployment with a working dashboard, but calling
docker-compose up
on the
docker-compose.yml
produced by executing
prefect server config
does not (the UI is responsive, but the dashboard pane below the top nav bar is blank). Also, any attempt to start a local agent in an adjacent docker container gives me a "No tenant found" message via a ClientError exception. Is the
prefect server config
command not actually producing everything it should be at present? I'm sure I can manually build a functional docker-compose.yml by reviewing the prefect docker-compose wrapper, but that might be very time-consuming, so I'm hoping the problem is just something simple that
prefect server config
is leaving out. I'm going to be evaluating the two deployments back to back now to see if I can tell what's missing. Any ideas would be greatly appreciated. Thanks again!
👍 1
z

Zanie

04/09/2021, 11:29 PM
Hey @Nate Jahncke --
prefect server start
creates the default tenant for you but spinning up your own does not 🙂 you'll just need to run
prefect server create-tenant -n default
n

Nate Jahncke

04/09/2021, 11:40 PM
So wait, you're telling me I need to connect my local docker-compose environment to the Prefect cloud in order to use it?
z

Zanie

04/09/2021, 11:40 PM
Nope you just need to insert a tenant into the prefect server database
Which part did you think meant it interacted with Cloud?
n

Nate Jahncke

04/09/2021, 11:41 PM
Hey thanks for your help btw.
z

Zanie

04/09/2021, 11:42 PM
Run
prefect backend server
🙂
Usually I mention that but presumed you had already here since you were playing with server earlier
n

Nate Jahncke

04/09/2021, 11:43 PM
Yeah, as I mentioned I'm really trying to run all this stuff without using the prefect module wrapper, as I have a number of other services to integrate it with. It doesn't really make sense to me to run some things via docker-compose.yml, and prefect using its own special program.
👍 1
z

Zanie

04/09/2021, 11:45 PM
So you can take a look at the backing function for this and just use
curl
to hit the graphql api instead. The mutation used is at https://github.com/PrefectHQ/prefect/blob/master/src/prefect/client/client.py#L111
n

Nate Jahncke

04/09/2021, 11:47 PM
Ah ok perfect, I think that's exactly what I was looking for! Thanks for your help 🙂
z

Zanie

04/09/2021, 11:47 PM
Also perhaps helpful as a reference, the Helm chart uses a K8s job to run the tenant creation https://github.com/PrefectHQ/server/blob/master/helm/prefect-server/templates/jobs/create_tenant.yaml
n

Nate Jahncke

04/09/2021, 11:48 PM
Great, that's helpful, thank you. I'll be doing something similar in my agent container.
z

Zanie

04/09/2021, 11:49 PM
That could definitely do it. It's also your database so you can just run SQL to insert a tenant if you wanted. Lots of options here.
You're welcome
prefect server config
should include docs that say this and
prefect server create-tenant
should tell you how to change backends if you're not trying to use Cloud so I'll open an issue to resolve those.
n

Nate Jahncke

04/09/2021, 11:50 PM
I think I was just missing a piece of info because my (obviously false) understanding was the client was required only for cloud connections. Lots of banging my head against the desk today lol.
Thanks a lot for your help!
z

Zanie

04/09/2021, 11:50 PM
@Marvin open "`prefect server config` does not include instructions on tenant creation"
z

Zanie

04/09/2021, 11:51 PM
👍
Yeah the client hits the backend which can be Server or Cloud and the APIs overlap a whole bunch but Cloud provides hosting and features around automation / user management / enterprise things
n

Nate Jahncke

04/09/2021, 11:54 PM
Right. We'll definitely eventually move that route if things work out. There was one other issue I think you might want to make a note of. Should I write it here or do you want me to submit an issue myself? Happy to if that's better.
Actually nvm let me see if it's still an issue now that other stuff should be working.
z

Zanie

04/09/2021, 11:55 PM
I might have the answer but if it's long form an issues are easier to track I'll see it either way.
n

Nate Jahncke

04/09/2021, 11:56 PM
Actually nope, it was part of the other problem apparently. URL resolution issue I thought was due to a parsing problem. I'm completely up and running! Thanks a lot Michael.
z

Zanie

04/10/2021, 12:13 AM
Sweet -- what did you end up doing for tenant creation? (trying to survey the most convenient option here)
n

Nate Jahncke

04/10/2021, 5:31 AM
Oh I thought originally that would need to happen from outside the container environment, which is why I was concerned about it, but now I just use the prefect module from within the agent container before running the actual agent. On startup it just pipes the result of a curl query through jq to see if there's an existing tenant and creates one if not. Not really a necessary extra step, but I hate having exceptions in my logs even if they're expected. I'm really looking forward to digging into this stuff this weekend, so thanks again for getting me unstuck! I'm sure that extra bit of info around the tenant role when using
prefect server config
will be very helpful for the next person that stumbles across it like I did.
Hey I just noticed there's an issue with the option text for create-tenant:
Copy code
root@c98af4692386:/tmp# prefect server create-tenant -h
Usage: prefect server create-tenant [OPTIONS]

  This command creates a tenant for the Prefect Server

  Options:
      --name, -n       TEXT    The name of a tenant to create
      --slug, -n       TEXT    The slug of a tenant to create (optional)

Options:
  -h, --help  Show this message and exit.
Should be
-s
for slugs I'm assuming.
m

Michael Wheeler

04/12/2021, 3:05 PM
2 Views