e

    Eric

    1 year ago
    Hi folks, I have a question around the hybrid model. As mentioned in the hybrid model - medium blog, once I registered my flow on the Prefect Cloud (step 2), I could run an agent on my infra (step 3). That is, the Prefect Cloud and the agent (using docker agent) are two different machines. And I set the same env as mentioned above. The question is, in the agent machine, I use the command “prefect agent docker start --api http://<Prefect Cloud IP>:4200 (backend: server) and the agent will query the prefect core in my cloud server. But I change backend to cloud, using “prefect agent docker start -t <MY_TOKEN> --api http://<Prefect Cloud IP>:4200” will show the following message:
    prefect.utilities.exceptions.ClientError: 400 Client Error: Bad Request for url: http://<Prefect Cloud IP>:4200
    
    This is likely caused by a poorly formatted GraphQL query or mutation. GraphQL sent:
    
    query {
      query { auth_info { api_token_scope } }
    }
    variables {
      null
    }
    Is there any missing step when I set Prefect agent? Thank you very much!
    Kyle Moon-Wright

    Kyle Moon-Wright

    1 year ago
    Hey Eric (didn’t ping you bc there seems to be multiple Erics!), When starting an agent to poll against the Prefect Cloud backend rather than your instance of Prefect Server (open-source UI), you don’t need to specify a Prefect API URL because it will poll against cloud.prefect.io by default. You just need to make sure that your backend is set to Cloud wherever your agent is running by issuing
    prefect backend cloud
    before starting you agent -
    prefect agent docker start -t <MY_TOKEN>
    . You can always switch back to poll your Server instance for work by issuing
    prefect backend server
    before starting your agent and specifying a URL with the API flag.
    e

    Eric

    1 year ago
    @Kyle Moon-Wright Thank you for the reply! After trying prefect agent docker start -t <MY_TOKEN> without api route, it shows:
    requests.exceptions.SSLError: HTTPSConnectionPool(host='<http://api.prefect.io|api.prefect.io>', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:1076)')))
    I can connect to cloud.prefect.io via
    curl -v <http://cloud.prefect.io|cloud.prefect.io>
    but the agent still connot connect to my Prefect cloud 😥
    Kyle Moon-Wright

    Kyle Moon-Wright

    1 year ago
    Hmm, that is interesting. An SSLError would imply that the api.prefect.io endpoint the Agent polls against (not cloud.prefect.io, apologies that’s where cloud lives) is not secure or there are network issues - the first I can verify is untrue, so it must be network issues/firewall or something? In a vacuum, to start a Docker Agent for our Cloud flows we need to:1. Install Prefect where we are starting our Agent and ensure we have outbound network access to api.prefect.io 2. Set our backend to cloud with
    prefect backend cloud
    where our Agent lives 3. Have a running Docker daemon for the Docker Agent to access 4. Provide a Runner token to the Agent to verify Agent auth 5. Run the Agent with the CLI and verify it’s hitting our instance of Cloud in the Agent tile So it’s tough to discern where this error is coming from. I’d recommend starting small and trying a LocalAgent with a fresh Runner token against the Cloud backend api for any deterministic leads.
    One other thing to try: Updating our registered flow version and Agent version to the latest version of Prefect (0.13.18)
    e

    Eric

    1 year ago
    Thank you @Kyle Moon-Wright! I think it is the network problem, because the original setting of my hardware is one laptop and one server with strict firewall and the server raise this unusual error. But after using two laptops in same wifi instead, the agent works successfully. I could be sure that I have to solve the firewall issues on my server 😓 Thanks in advance 🙏🏽