https://prefect.io logo
Title
m

Maikel Penz

03/01/2023, 2:01 AM
Hey team. I'm getting an error to deploy the agent on Kubernetes. This is what I am running
export PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/><ACCOUNT-ID>/workspaces/<WORKSPACE-ID>"
export PREFECT_API_KEY="<API-KEY>"
prefect kubernetes manifest agent -q <MY-QUEUE> | kubectl apply --namespace=default -f -
And the error..
| _ \ _ \ __| __| __/ __|_   _|   /_\ / __| __| \| |_   _|
 |  _/   / _|| _|| _| (__  | |    / _ \ (_ | _|| .` | | |
 |_| |_|_\___|_| |___\___| |_|   /_/ \_\___|___|_|\_| |_|


Agent started! Looking for work from queue(s): <MY-QUEUE>...
An exception occurred.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 230, in coroutine_wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 181, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "/usr/local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "/usr/local/lib/python3.8/site-packages/prefect/cli/agent.py", line 201, in start
    tg.start_soon(
  File "/usr/local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 662, in __aexit__
    raise exceptions[0]
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/services.py", line 46, in critical_service_loop
    await workload()
  File "/usr/local/lib/python3.8/site-packages/prefect/agent.py", line 265, in check_for_cancelled_flow_runs
    named_cancelling_flow_runs = await self.client.read_flow_runs(
  File "/usr/local/lib/python3.8/site-packages/prefect/client/orchestration.py", line 1715, in read_flow_runs
    response = await <http://self._client.post|self._client.post>(f"/flow_runs/filter", json=body)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.8/site-packages/prefect/client/base.py", line 253, in send
    response.raise_for_status()
  File "/usr/local/lib/python3.8/site-packages/prefect/client/base.py", line 130, in raise_for_status
    raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__
prefect.exceptions.PrefectHTTPStatusError: Client error '404 Not Found' for url '<https://api.prefect.cloud/api/accounts/><ACCOUNT-ID>/workspaces/<WORKSPACE-ID>/flow_runs/filter'
Response: {'detail': 'Not Found'}
For more information check: <https://httpstatuses.com/404>
Why do I get
Not Found
on
<https://api.prefect.cloud/api/accounts/><ACCOUNT-ID>/workspaces/<WORKSPACE-ID>/flow_runs/filter
?
s

sjammula

04/18/2023, 5:46 PM
Hi @Chris Guidry I'm facing the same error ,how do I assign this specific permission to workspaces?Could you please let me know
Hi @Maikel Penz Would like to know inputs from how are you able to solve this ?
m

Maikel Penz

04/19/2023, 8:20 PM
@sjammula when you create your API key make sure you assign a workspace to it in the dropdown list. This should be the Workspace you are spinning up the agent.
s

sjammula

04/19/2023, 9:32 PM
Thanks @Maikel Penz for the response.I don't see any workspace in the dropdown .Here is the screenshot what I see when trying to create new apikey in Prefect2
m

Maikel Penz

04/19/2023, 9:45 PM
try creating a service account
s

sjammula

04/19/2023, 9:52 PM
sure @Maikel Penz let me do
so basically we need to create an organization then only this service account will be available.correct my understanding @Maikel Penz
m

Maikel Penz

04/20/2023, 3:25 AM
Instead of creating an api key that is tied to your user you create a service account that has permission to your workspace. You need to be logged into your account/organization yes.
s

sjammula

04/20/2023, 3:45 PM
thanks @Maikel Penz
c

Chris Guidry

04/24/2023, 1:58 PM
Hi @sjammula, sorry I was PTO when you sent this reply. What @Maikel Penz has described here is exactly what you'll need to do, create a Service Account and then grant it access to one or more of your organization's workspaces. If your workspaces represent different promotion environments (like
development
vs
production
) we recommend using separate service accounts for those.
Thank you so much for fielding this, Maikel!
💪 1