Skip to content

Commit

Permalink
Modify /query call when pointing at CromIAM (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsasch authored Mar 1, 2019
1 parent 19761a5 commit d28fd91
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Job Manager Change Log

## v0.5.9 Release Notes

### Modified query to backend when it's going to a CromIAM instead of a Cromwell

## v0.5.8 Release Notes

### Added events to timing diagram
Expand Down
14 changes: 11 additions & 3 deletions servers/cromwell/jobs/controllers/jobs_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,11 @@ def query_jobs(body, **kwargs):
offset = page_tokens.decode_offset(query.page_token)
page = page_from_offset(offset, query_page_size)

has_auth = headers is not None

response = requests.post(
_get_base_url() + '/query',
json=cromwell_query_params(query, page, query_page_size),
json=cromwell_query_params(query, page, query_page_size, has_auth),
auth=auth,
headers=headers)

Expand Down Expand Up @@ -356,7 +358,7 @@ def page_from_offset(offset, page_size):
return 1 + (offset / page_size)


def cromwell_query_params(query, page, page_size):
def cromwell_query_params(query, page, page_size, has_auth):
query_params = []
if query.start:
start = datetime.strftime(query.start, '%Y-%m-%dT%H:%M:%S.%fZ')
Expand Down Expand Up @@ -385,7 +387,13 @@ def cromwell_query_params(query, page, page_size):
query_params.append({'page': str(page)})
query_params.append({'additionalQueryResultFields': 'parentWorkflowId'})
query_params.append({'additionalQueryResultFields': 'labels'})
query_params.append({'includeSubworkflows': 'false'})

# If the query request is passing along an auth header, that means the API
# is sending requests to a CromIAM, not a Cromwell. CromIAM can't retrieve
# subworkflows, so it's not necessary to the query (and slows things down
# significantly)
if not has_auth:
query_params.append({'includeSubworkflows': 'false'})
if query.extensions and query.extensions.hide_archived:
query_params.append({'excludeLabelAnd': 'flag:archive'})
return query_params
Expand Down
5 changes: 3 additions & 2 deletions servers/cromwell/jobs/test/test_jobs_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def _request_callback(request, context):
def test_empty_cromwell_query_params(self):
query = QueryJobsRequest()
self.assertEqual(
sorted(jobs_controller.cromwell_query_params(query, 1, 64)),
sorted(jobs_controller.cromwell_query_params(query, 1, 64, False)),
sorted([{
'page': '1'
}, {
Expand Down Expand Up @@ -694,7 +694,8 @@ def test_cromwell_query_params(self):
query_params.extend([{'status': s} for s in query.status])
self.assertItemsEqual(
sorted(query_params),
sorted(jobs_controller.cromwell_query_params(query, 23, 100)))
sorted(
jobs_controller.cromwell_query_params(query, 23, 100, False)))

def test_format_job(self):
time = '2017-10-27T18:04:47.271Z'
Expand Down

0 comments on commit d28fd91

Please sign in to comment.