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

[AIRFLOW-5048] Improve display of Kubernetes resources #5665

Merged
merged 7 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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 airflow/kubernetes/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def has_limits(self):
def has_requests(self):
return self.request_cpu is not None or self.request_memory is not None

def __str__(self):
return str({'request': {'memory': self.request_memory, 'cpu': self.request_cpu},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.request_memory can be None, may be check first?
same for self.limit_memory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, the test covers this, None to string is 'None'

'limit': {'memory': self.limit_memory}, 'cpu': self.limit_cpu})


class Port:
def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ def test_extract_requests(self):
KubernetesRequestFactory.extract_resources(pod, self.input_req)
self.assertEqual(self.input_req, self.expected)

def test_display_resources(self):
resources_string = str(Resources('1Gi', 1))
self.assertEqual(
resources_string,
"{'request': {'memory': '1Gi', 'cpu': 1}, 'limit': {'memory': None}, 'cpu': None}")

def test_extract_limits_resources(self):

def test_extract_limits(self):
# Test when resources is not empty
resources = Resources(
Expand Down