I've got prefect server and all its components dep...
# prefect-server
m
I've got prefect server and all its components deployed and talking to each other, now trying to interact w/ it from the cli and running into 400 errors trying to do the first few steps (create tenant)
Copy code
$ prefect agent start --name "Default Agent"
server
{"errors":[{"message":"Cannot query field \"tenant\" on type \"Query\".","locations":[{"line":2,"column":5}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}]}

Traceback (most recent call last):
  File "/Users/mattforbes/virtualenvs/py3/bin/prefect", line 8, in <module>
    sys.exit(cli())
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/cli/agent.py", line 263, in start
    no_cloud_logs=no_cloud_logs,
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/agent/local/agent.py", line 78, in __init__
    no_cloud_logs=no_cloud_logs,
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/agent/agent.py", line 153, in __init__
    self.client = Client(api_server=config.cloud.api, api_token=token)
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/client/client.py", line 125, in __init__
    tenant_info = self.graphql({"query": {"tenant": {"id"}}})
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/client/client.py", line 284, in graphql
    retry_on_api_error=retry_on_api_error,
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/client/client.py", line 238, in post
    retry_on_api_error=retry_on_api_error,
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/client/client.py", line 406, in _request
    session=session, method=method, url=url, params=params, headers=headers
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/prefect/client/client.py", line 338, in _send_request
    response.raise_for_status()
  File "/Users/mattforbes/virtualenvs/py3/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url:
added some print statements in the cli script to get the response body
Copy code
{
  "errors": [
    {
      "message": "Cannot query field \"tenant\" on type \"Query\".",
      "locations": [
        {
          "line": 2,
          "column": 5
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED"
      }
    }
  ]
}
any advice on how to debug this?
do I have some version incompatibility?
anything change w.r.t tenants in recent releases?
Copy code
$ prefect version
0.13.7
deployed w/
:latest
tags from the docker images
n
Hi @matt forbes - have you run
prefect backend server
before running the agent? If so, can you confirm that:
Copy code
[server]
endpoint = "<https://your_deployment_adddress:4200/graphql>"
is set correctly in your
~/.prefect/config.toml
?
m
yeah it's correct
however the code uses the config in
[cloud]
not
[server]
but it's set correctly there as well
if I go to that url, I get the graphql playground ui
is there a request I can try running to see if everything is working?
n
Ok good, that's usually the best place to start. So that specific error message is usually a result of Hasura being unable to run the database migrations correctly - this is usually because either the database didn't start correctly OR the database that exists is incompatible (perhaps a db from a pre-013.0 version of prefect server)
In the playground, can you view the schema? Does
tenant
exist there?
m
that would show up as
type tenant
? no
I may have extracted one of the env variables incorrectly,
PREFECT_SERVER_DB_CMD: ${PREFECT_SERVER_DB_CMD:-"echo 'DATABASE MIGRATIONS SKIPPED'"}
is that used to create the schema?
maybe that should be
prefect-server database upgrade -y
?
n
Yes - the first time you start the server you'll need to run the migrations, even if you're persisting the db somewhere.
So the command you listed should work
m
ok I think I'm on the right path, thanks nicholas
n
great! Let me know if you run into any other issues
m
👍 I got this all working now, thanks
🚀 1