Skip to content

Commit

Permalink
pw: retry check posts
Browse files Browse the repository at this point in the history
When patchwork gets slow everything fails.
Try 2 times before crashing.

Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kuba-moo committed Jul 11, 2024
1 parent a331727 commit 1252818
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pw/patchwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
import time
import urllib

import core
Expand Down Expand Up @@ -125,7 +126,10 @@ def _post(self, req, headers, data, api='1.1'):
core.log("Headers", headers)
core.log("Data", data)
core.log("Response", ret)
core.log("Response data", ret.json())
try:
core.log("Response data", ret.json())
except json.decoder.JSONDecodeError:
core.log("Response data", ret.content.decode())
finally:
core.log_end_sec()

Expand Down Expand Up @@ -189,6 +193,10 @@ def post_check(self, patch, name, state, url, desc):
}

r = self._post(f'patches/{patch}/checks/', headers=headers, data=data)
if r.status_code == 502 or r.status_code == 504:
# Timeout, let's wait 30 sec and retry, POST isn't retried by the lib.
time.sleep(30)
r = self._post(f'patches/{patch}/checks/', headers=headers, data=data)
if r.status_code != 201:
raise PatchworkPostException(r)

Expand Down

0 comments on commit 1252818

Please sign in to comment.