-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
KubernetesExecutor should default to template image if used #19484
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
import os | ||
import re | ||
import sys | ||
import unittest | ||
import uuid | ||
from unittest import mock | ||
|
||
|
@@ -38,8 +37,8 @@ | |
from airflow.kubernetes.secret import Secret | ||
|
||
|
||
class TestPodGenerator(unittest.TestCase): | ||
def setUp(self): | ||
Comment on lines
-41
to
-42
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. converting to pytest is required when combining pytest params and unittest.mock |
||
class TestPodGenerator: | ||
def setup_method(self): | ||
self.static_uuid = uuid.UUID('cf4a56d2-8101-4217-b027-2af6216feb48') | ||
self.deserialize_result = { | ||
'apiVersion': 'v1', | ||
|
@@ -395,10 +394,17 @@ def test_reconcile_pods(self, mock_uuid): | |
|
||
assert result_dict == expected_dict | ||
|
||
@pytest.mark.parametrize( | ||
'config_image, expected_image', | ||
[ | ||
pytest.param('my_image:my_tag', 'my_image:my_tag', id='image_in_cfg'), | ||
pytest.param(None, 'busybox', id='no_image_in_cfg'), | ||
], | ||
) | ||
@mock.patch('uuid.uuid4') | ||
def test_construct_pod(self, mock_uuid): | ||
path = sys.path[0] + '/tests/kubernetes/pod_generator_base_with_secrets.yaml' | ||
worker_config = PodGenerator.deserialize_model_file(path) | ||
def test_construct_pod(self, mock_uuid, config_image, expected_image): | ||
template_file = sys.path[0] + '/tests/kubernetes/pod_generator_base_with_secrets.yaml' | ||
worker_config = PodGenerator.deserialize_model_file(template_file) | ||
mock_uuid.return_value = self.static_uuid | ||
executor_config = k8s.V1Pod( | ||
spec=k8s.V1PodSpec( | ||
|
@@ -414,7 +420,7 @@ def test_construct_pod(self, mock_uuid): | |
dag_id=self.dag_id, | ||
task_id=self.task_id, | ||
pod_id='pod_id', | ||
kube_image='airflow_image', | ||
kube_image=config_image, | ||
try_number=self.try_number, | ||
date=self.execution_date, | ||
args=['command'], | ||
|
@@ -430,7 +436,7 @@ def test_construct_pod(self, mock_uuid): | |
expected.metadata.name = 'pod_id.' + self.static_uuid.hex | ||
expected.metadata.namespace = 'test_namespace' | ||
expected.spec.containers[0].args = ['command'] | ||
expected.spec.containers[0].image = 'airflow_image' | ||
expected.spec.containers[0].image = expected_image | ||
expected.spec.containers[0].resources = {'limits': {'cpu': '1m', 'memory': '1G'}} | ||
expected.spec.containers[0].env.append( | ||
k8s.V1EnvVar( | ||
|
This file contains 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.
we could probably loosen this to allow user to specify image only (and not tag) but this is the current behavior. currently if either is not specified it won't work unless specified in executor_config