Carlos Paiva
05/01/2022, 5:49 PMAnna Geller
Although it seems a Cloud configuration.I understand your confusion. Even though the variable is called
PREFECT__CLOUD__REQUEST_TIMEOUT
, it's not just for Cloud, but it's also valid for Server.
your error may also come from the telemetry requests, which you can disable this way:
export PREFECT__SERVER__TELEMETRY__ENABLED=False
more on that hereAnna Geller
Carlos Paiva
05/03/2022, 11:32 AMAnna Geller
Carlos Paiva
05/03/2022, 1:44 PMAnna Geller
Carlos Paiva
05/05/2022, 4:55 PMCarlos Paiva
05/05/2022, 5:03 PMUnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
I have tried to set the variables in the Agent with the -e but it seems to have no effect. Am I doing something wrong?Anna Geller
Carlos Paiva
05/05/2022, 5:17 PMAnna Geller
TimeoutError
without providing any context, and I did the same with my answer 😄
If you want to dive deeper:
1. When do you get this error exactly?
2. Is this an issue related to Prefect or to your infrastructure? (we generally can't provide much help with infrastructure issues since it's hard to troubleshoot remotely via Slack, but I can still try to help)
3. How often does this error occur?
4. What was the first time you saw this error and how did you find out about this issue - Docker compose logs?
5. Did you try restarting your Docker service as shown in the SO issue?
6. Did you try restarting your Server?Carlos Paiva
05/05/2022, 5:27 PMKevin Kho
Carlos Paiva
05/05/2022, 5:42 PMException encountered while deploying flow run 705cf945-26ce-45dc-831e-c65374acec38
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 277, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/util/retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/packages/six.py", line 770, in reraise
raise value
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 447, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/home/ubuntu/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/prefect/agent/agent.py", line 391, in _deploy_flow_run
deployment_info = self.deploy_flow(flow_run)
File "/home/ubuntu/.local/lib/python3.8/site-packages/prefect/agent/docker/agent.py", line 482, in deploy_flow
container = self.docker_client.create_container(
File "/home/ubuntu/.local/lib/python3.8/site-packages/docker/api/container.py", line 428, in create_container
return self.create_container_from_config(config, name)
File "/home/ubuntu/.local/lib/python3.8/site-packages/docker/api/container.py", line 438, in create_container_from_config
res = self._post_json(u, data=config, params=params)
File "/home/ubuntu/.local/lib/python3.8/site-packages/docker/api/client.py", line 296, in _post_json
return self._post(url, data=json.dumps(data2), **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/docker/api/client.py", line 233, in _post
return <http://self.post|self.post>(url, **self._set_request_timeout(kwargs))
File "/home/ubuntu/.local/lib/python3.8/site-packages/requests/sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
Kevin Kho
docker run
or docker pull
?Carlos Paiva
05/05/2022, 5:54 PMAnna Geller
export DOCKER_CLIENT_TIMEOUT=120
export COMPOSE_HTTP_TIMEOUT=120
then restart the Docker service
and then restart Prefect Server
the order might be importantCarlos Paiva
05/05/2022, 6:20 PMAnna Geller
Carlos Paiva
05/05/2022, 7:12 PMCarlos Paiva
05/05/2022, 8:28 PMdef concurrent_handler(flow: Flow, old_state: State, new_state: State) -> Optional[State]:
if old_state.is_pending() and new_state.is_running():
client = Client()
now = dt.now(tz=pytz.UTC).replace(microsecond=0) + timedelta(seconds=1)
# Replacing microseconds because graphql api cant always handle the number of decimals
result = client.graphql(
"""{
flow(where: {
archived: {_eq: false},
name: {_eq: "%s"}
}) {
name
archived
flow_runs (where: {
state: {_in: ["Submitted", "Queued", "Scheduled", "Retrying", "Running"]},
scheduled_start_time:{_lte: "%s"}
}) {
scheduled_start_time
start_time
created
name
state
id
}
}
}"""
% (flow.name, now.isoformat()) # Sorry for % operator, but those {} make it a pain
)
# These flow runs will be everything thats scheduled to start in the past and
# might have built up.
logger = prefect.context.get("logger")
# This might fail if the GraphQL cant find anything, but havent seen this in practise
flow_runs = result["data"]["flow"][0]["flow_runs"]
# I dont want to run another task if theres already more than one flow running
# For me, Im happy to have two running at once, as API issues means we can get timeouts and
# hangs that dont terminate easily. For other use cases, Id generally say to cancel if theres
# any running
num_running = sum([1 if f["state"] in ("Running", "Retrying") else 0 for f in flow_runs])
if num_running > 1:
msg = "Existing tasks are already running"
<http://logger.info|logger.info>(msg)
return Scheduled(msg,
start_time=dt.strptime(now.isoformat(), "%Y-%m-%dT%H:%M:%S%z") + timedelta(seconds=15))
# And if there are multiple scheduled, only the latest one should be run
scheduled = [
f for f in flow_runs if f["state"] in ("Pending", "Scheduled", "Queued", "Submitted")
]
if len(scheduled) > 1:
last_scheduled_time = max(
[dt.strptime(f["scheduled_start_time"], "%Y-%m-%dT%H:%M:%S.%f%z") for f in scheduled]
)
<http://logger.info|logger.info>(scheduled)
this_flow_run_id = prefect.context.get("flow_run_id")
matching_runs = [f for f in scheduled if f["id"] == this_flow_run_id]
if not matching_runs:
<http://logger.info|logger.info>(f"Current id is {this_flow_run_id}")
<http://logger.info|logger.info>(f"Flow runs are: {scheduled}")
return Cancelled("Nope")
this_run = matching_runs[0]
this_run_time = dt.strptime(this_run["scheduled_start_time"], "%Y-%m-%dT%H:%M:%S.%f%z")
if this_run_time != last_scheduled_time:
msg = "Multiple scheduled tasks, this is not the last one"
<http://logger.info|logger.info>(msg)
return Scheduled(msg, start_time=this_run_time + timedelta(seconds=10))
return new_state
Kevin Kho
Kevin Kho
Carlos Paiva
05/06/2022, 8:19 AMKevin Kho
client.graphql()
portion. I think it’s overloading the APICarlos Paiva
05/06/2022, 2:07 PMKevin Kho
Carlos Paiva
05/06/2022, 3:34 PMKevin Kho
timedelta(seconds=10)
, how many of these are concurrently running? (even if just the state handler), like how many containers are there up at the same time?
It really seems like the Docker daemon is just failing to respond. If bumping up the resources doesn’t work, I’m not sure what we can do other than space out the flows a bit moreCarlos Paiva
05/06/2022, 3:47 PMKevin Kho
Kevin Kho
Kevin Kho
Carlos Paiva
05/06/2022, 3:53 PMKevin Kho
Scheduled
also?Carlos Paiva
05/06/2022, 3:56 PMSheduled
Kevin Kho
Scheduled
Carlos Paiva
05/10/2022, 12:04 PMAnna Geller
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by