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

reduce start-execution-worker concurrency to address AWS Batch service limit errors #1677

Merged
merged 1 commit into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.9.3]
### Fixed
- Reduced `start-execution-worker` concurrency to address AWS Batch `Too Many Requests` errors. Fixes [#1676](https://github.com/ASFHyP3/hyp3/issues/1676).

## [3.9.2]
### Fixed
- Reverted `asf_search` to v6.0.2. Fixes [#1673](https://github.com/ASFHyP3/hyp3/issues/1673).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def lambda_handler(event, context) -> None:
pending_jobs = dynamo.jobs.get_jobs_waiting_for_execution(limit=900)
logger.info(f'Got {len(pending_jobs)} pending jobs')

batch_size = 300
batch_size = 450
for i in range(0, len(pending_jobs), batch_size):
jobs = pending_jobs[i:i + batch_size]
logger.info(f'Invoking worker for {len(jobs)} jobs')
Expand Down
13 changes: 6 additions & 7 deletions tests/test_start_execution_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ def test_lambda_handler_900_jobs():
mock_get_jobs_waiting_for_execution.assert_called_once_with(limit=900)

assert mock_invoke_worker.mock_calls == [
call('test-worker-function-arn', mock_jobs[0:300]),
call('test-worker-function-arn', mock_jobs[300:600]),
call('test-worker-function-arn', mock_jobs[600:900]),
call('test-worker-function-arn', mock_jobs[0:450]),
call('test-worker-function-arn', mock_jobs[450:900]),
]


def test_lambda_handler_400_jobs():
def test_lambda_handler_500_jobs():
with patch('dynamo.jobs.get_jobs_waiting_for_execution') as mock_get_jobs_waiting_for_execution, \
patch('start_execution_manager.invoke_worker') as mock_invoke_worker, \
patch.dict(os.environ, {'START_EXECUTION_WORKER_ARN': 'test-worker-function-arn'}, clear=True):
mock_jobs = list(range(400))
mock_jobs = list(range(500))
mock_get_jobs_waiting_for_execution.return_value = mock_jobs

mock_invoke_worker.return_value = {'StatusCode': None}
Expand All @@ -87,8 +86,8 @@ def test_lambda_handler_400_jobs():
mock_get_jobs_waiting_for_execution.assert_called_once_with(limit=900)

assert mock_invoke_worker.mock_calls == [
call('test-worker-function-arn', mock_jobs[0:300]),
call('test-worker-function-arn', mock_jobs[300:400]),
call('test-worker-function-arn', mock_jobs[0:450]),
call('test-worker-function-arn', mock_jobs[450:500]),
]


Expand Down