Skip to content

Commit

Permalink
[AIRFLOW-5048] Improve display of Kubernetes resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ms32035 committed Jul 26, 2019
1 parent b0a4e97 commit 363142b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions airflow/kubernetes/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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},
'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 @@ -246,6 +246,12 @@ def test_extract_requested_resources(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):
# Test when resources is not empty
resources = Resources(limit_memory='2Gi', limit_cpu=2)
Expand Down

0 comments on commit 363142b

Please sign in to comment.