rahulgoyal2987 commented on code in PR #23490:
URL: https://github.com/apache/airflow/pull/23490#discussion_r866450119
##########
airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -368,20 +368,25 @@ def extract_xcom(self, pod: V1Pod) -> str:
_preload_content=False,
)
) as resp:
- result = self._exec_pod_command(resp, f'cat
{PodDefaults.XCOM_MOUNT_PATH}/return.json')
+ result = self._exec_pod_command(resp, f'cat
{PodDefaults.XCOM_MOUNT_PATH}/return.json', True)
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
- def _exec_pod_command(self, resp, command: str) -> Optional[str]:
+ def _exec_pod_command(self, resp, command: str,
extract_full_content=False) -> Optional[str]:
if resp.is_open():
self.log.info('Running command... %s\n', command)
resp.write_stdin(command + '\n')
while resp.is_open():
resp.update(timeout=1)
+ res = None
if resp.peek_stdout():
- return resp.read_stdout()
+ res = resp.read_stdout()
+ if extract_full_content:
Review Comment:
_extract_xcom function can load content which is string and can be large
also. The plus(+) operator works
perfectly for string content and There is no surity about what all type
values can be retuned by resp.read_stdout(). Now this function support two
behavior one reading partial response and another reading full response.
Keeping only the while loop may not be the right thing.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]