airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] dimberman commented on a change in pull request #6377: [AIRFLOW-5589] monitor pods by labels instead of names
Date Wed, 23 Oct 2019 12:27:15 GMT
dimberman commented on a change in pull request #6377: [AIRFLOW-5589] monitor pods by labels
instead of names
URL: https://github.com/apache/airflow/pull/6377#discussion_r338015860
 
 

 ##########
 File path: tests/integration/kubernetes/test_kubernetes_pod_operator.py
 ##########
 @@ -51,6 +53,49 @@
 # pylint: disable=unused-argument
 class TestKubernetesPodOperator(unittest.TestCase):
 
+    @staticmethod
+    def create_context(task):
+        return {
+            'task': task,
+            'dag': DAG(dag_id="dag"),
+            'ts': str(timezone.utcnow()),
+            'name': task.name
+        }
+
+    def compare_two_pods(self, actual_pod):
+        """
+        This is a disgusting hack that is unfortunately necessary because kubernetes is not
consistent
+        in it's return objects between "create_pod" and "get_pod"
+        :param actual_pod:
+        """
+        self._compare_sub_dicts(actual_pod['metadata'], expected_sub_pod=self.expected_pod['metadata'])
+
+        expected_containers = self.expected_pod['spec']['containers']
+        actual_containers = actual_pod['spec']['containers']
+        self.assertEqual(len(expected_containers), len(actual_containers))
+
+        self._compare_pod_containers(actual_containers, expected_containers)
+
+        filtered_spec_metadata = {k: v for k, v in self.expected_pod['spec'].items()
+                                  if (v and k != "containers")}
+
+        self._compare_sub_dicts(filtered_spec_metadata, expected_sub_pod=actual_pod['spec'])
+
+    def _compare_pod_containers(self, actual_containers, expected_containers):
+        container_map = {container['name']: container for container in expected_containers}
 
 Review comment:
   Does the order matter? Yaml is declarative so I think the general assumption is that all
containers are ready "when they're ready." The only place I'd imagine order mattering is between
init-container -> main containers

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message