def _extract_xcom(self, pod): resp = kubernetes_stream(self._client.connect_get_namespaced_pod_exec, pod.name, pod.namespace, container=self.kube_req_factory.SIDECAR_CONTAINER_NAME, command=['/bin/sh'], stdin=True, stdout=True, stderr=True, tty=False, _preload_content=False) try: result = self._exec_pod_command( resp, 'cat {}/return.json'.format(self.kube_req_factory.XCOM_MOUNT_PATH)) self._exec_pod_command(resp, 'kill -s SIGINT 1') finally: resp.close() if result is None: raise AirflowException('Failed to extract xcom from pod: {}'.format(pod.name)) return result
def _extract_xcom(self, pod): resp = kubernetes_stream(self._client.connect_get_namespaced_pod_exec, pod.name, pod.namespace, container=self.kube_req_factory.SIDECAR_CONTAINER_NAME, command=['/bin/sh'], stdin=True, stdout=True, stderr=True, tty=False, _preload_content=False) try: result = self._exec_pod_command( resp, 'cat {}/return.json'.format(self.kube_req_factory.XCOM_MOUNT_PATH)) self._exec_pod_command(resp, 'kill -s SIGINT 1') finally: resp.close() if result is None: raise AirflowException('Failed to extract xcom from pod: {}'.format(pod.name)) return result
def _extract_xcom(self, pod: V1Pod): resp = kubernetes_stream( self._client.connect_get_namespaced_pod_exec, pod.metadata.name, pod.metadata.namespace, container=PodDefaults.SIDECAR_CONTAINER_NAME, command=['/bin/sh'], stdin=True, stdout=True, stderr=True, tty=False, _preload_content=False, ) try: result = self._exec_pod_command(resp, f'cat {PodDefaults.XCOM_MOUNT_PATH}/return.json') self._exec_pod_command(resp, 'kill -s SIGINT 1') finally: resp.close() if result is None: raise AirflowException(f'Failed to extract xcom from pod: {pod.metadata.name}') return result
def extract_xcom(self, pod: V1Pod) -> str: """Retrieves XCom value and kills xcom sidecar container""" with closing( kubernetes_stream( self._client.connect_get_namespaced_pod_exec, pod.metadata.name, pod.metadata.namespace, container=PodDefaults.SIDECAR_CONTAINER_NAME, command=['/bin/sh'], stdin=True, stdout=True, stderr=True, tty=False, _preload_content=False, ) ) as resp: result = self._exec_pod_command(resp, f'cat {PodDefaults.XCOM_MOUNT_PATH}/return.json') self._exec_pod_command(resp, 'kill -s SIGINT 1') if result is None: raise AirflowException(f'Failed to extract xcom from pod: {pod.metadata.name}') return result