Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 409s from /step endpoint in Metaflow Service #258

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion metaflow/metadata/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def create_object():
raise

@classmethod
def _request(cls, monitor, path, data=None):
def _request(cls, monitor, path, data=None, retry_409_path=None):
if cls.INFO is None:
raise MetaflowException('Missing Metaflow Service URL. '
'Specify with METAFLOW_SERVICE_URL environment variable')
Expand Down Expand Up @@ -231,6 +231,19 @@ def _request(cls, monitor, path, data=None):
else:
if resp.status_code < 300:
return resp.json()
elif resp.status_code == 409 and data is not None:
# a special case: the post fails due to a conflict
# this could occur when we missed a success response
# from the first POST request but the request
# actually went though, so a subsequent POST
# returns 409 (conflict) or we end up with a
# conflict while running on AWS Step Functions
# instead of retrying the post we retry with a get since
# the record is guaranteed to exist
if retry_409_path:
return self._request(retry_409_path)
else:
return
elif resp.status_code != 503:
raise ServiceException('Metadata request (%s) failed (code %s): %s'
% (path, resp.status_code, resp.text),
Expand Down