-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Add support in AWS Batch Operator for multinode jobs #28321
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
Closed
camilleanne
wants to merge
16
commits into
apache:main
from
camilleanne:ct/aws-batch-operator-for-multinode-jobs
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
917c415
add node_overrides parameter to batch operator to support multinode j…
camilleanne 57d8675
use trim_none_values to pass only truthy parameters to boto
camilleanne e9cf26e
add test
camilleanne 5713c48
access logstreamname for multinode jobs; add batch_client test
camilleanne 4c226fa
better conditionals on attempts array length
camilleanne d59729f
lint
camilleanne 59e9a87
fix line length; extend test for multiple attempts
camilleanne 5d16298
Merge branch 'main' of https://github.com/apache/airflow into ct/aws-…
camilleanne c2182e3
fix bad tab
camilleanne 830bbe9
update logstream tests
camilleanne b6750cf
update tests for new expectations around arrayProperties
camilleanne 6169610
Merge branch 'main' of https://github.com/apache/airflow into ct/aws-…
camilleanne 79e488c
rename overrides param
vandonr-amz 40453ca
Merge pull request #2 from aws-mwaa/vandonr/multinode
camilleanne 179fc21
raise exception instead of a warning on unrecognized job type
camilleanne 528bb99
Merge branch 'main' of https://github.com/apache/airflow into ct/aws-…
camilleanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,13 +274,16 @@ def test_job_awslogs_user_defined(self): | |
| assert awslogs["awslogs_stream_name"] == LOG_STREAM_NAME | ||
| assert awslogs["awslogs_group"] == "/test/batch/job" | ||
| assert awslogs["awslogs_region"] == "ap-southeast-2" | ||
|
|
||
|
|
||
| def test_job_no_awslogs_stream(self, caplog): | ||
| self.client_mock.describe_jobs.return_value = { | ||
| "jobs": [ | ||
| { | ||
| "jobId": JOB_ID, | ||
| "container": {}, | ||
| "container": { | ||
| "logConfiguration": {} | ||
| }, | ||
| } | ||
| ] | ||
| } | ||
|
|
@@ -290,6 +293,22 @@ def test_job_no_awslogs_stream(self, caplog): | |
| assert len(caplog.records) == 1 | ||
| assert "doesn't create AWS CloudWatch Stream" in caplog.messages[0] | ||
|
|
||
| def test_job_not_recognized_job(self): | ||
| self.client_mock.describe_jobs.return_value = { | ||
| "jobs": [ | ||
| { | ||
| "jobId": JOB_ID | ||
| } | ||
| ] | ||
| } | ||
| with pytest.raises(AirflowException) as ctx: | ||
| self.batch_client.get_job_awslogs_info(JOB_ID) | ||
| # It should not retry when this client error occurs | ||
| self.client_mock.describe_jobs.assert_called_once_with(jobs=[JOB_ID]) | ||
| msg = f"AWS Batch job (%s) is not a supported job type. Supported job types: container, array, multinode." | ||
| assert msg in str(ctx.value) | ||
|
|
||
|
|
||
| def test_job_splunk_logs(self, caplog): | ||
| self.client_mock.describe_jobs.return_value = { | ||
| "jobs": [ | ||
|
|
@@ -309,6 +328,40 @@ def test_job_splunk_logs(self, caplog): | |
| assert len(caplog.records) == 1 | ||
| assert "uses logDriver (splunk). AWS CloudWatch logging disabled." in caplog.messages[0] | ||
|
|
||
| def test_job_awslogs_multinode_job(self): | ||
| self.client_mock.describe_jobs.return_value = { | ||
| "jobs": [ | ||
| { | ||
| "jobId": JOB_ID, | ||
| "attempts": [ | ||
| {"container": {"exitCode": 0, "logStreamName": "test/stream/attempt0"}}, | ||
| {"container": {"exitCode": 0, "logStreamName": LOG_STREAM_NAME}}, | ||
| ], | ||
| "nodeProperties": { | ||
| "mainNode": 0, | ||
| "nodeRangeProperties": [ | ||
| { | ||
| "targetNodes": "0:", | ||
| "container": { | ||
| "logConfiguration": { | ||
| "logDriver": "awslogs", | ||
| "options": { | ||
| "awslogs-group": "/test/batch/job", | ||
| "awslogs-region": AWS_REGION, | ||
| }, | ||
| } | ||
| }, | ||
| } | ||
| ], | ||
| }, | ||
| } | ||
| ] | ||
| } | ||
|
Comment on lines
+351
to
+359
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beautiful 😄 |
||
| awslogs = self.batch_client.get_job_awslogs_info(JOB_ID) | ||
| assert awslogs["awslogs_stream_name"] == LOG_STREAM_NAME | ||
| assert awslogs["awslogs_group"] == "/test/batch/job" | ||
| assert awslogs["awslogs_region"] == AWS_REGION | ||
|
|
||
|
|
||
| class TestBatchClientDelays: | ||
| @mock.patch.dict("os.environ", AWS_DEFAULT_REGION=AWS_REGION) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have zero element in the array ? i.e. should we add a check on
len == 0and a user-friendly error message ?