Giter Site home page Giter Site logo

Comments (3)

roycaihw avatar roycaihw commented on July 18, 2024

/help

It is unclear where the limitation is coming from. Whether the limitation is coming from this client or some underlying library

from python.

k8s-ci-robot avatar k8s-ci-robot commented on July 18, 2024

@roycaihw:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

It is unclear where the limitation is coming from. Whether the limitation is coming from this client or some underlying library

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

from python.

paramjeet01 avatar paramjeet01 commented on July 18, 2024

I'm not sure where the data is lost in between but I'm trying this code as suggested by @Paul424 in this issue :
kubernetes-client/python-base#190. My understanding is that the data is lost while reading from the cat command,

def _extract_xcom(self, pod: V1Pod):
    try:
        self.log.info(f'Running command... cat {PodDefaults.XCOM_MOUNT_PATH}/return.json')

        # Can't use _preload_content=True because that would return str(json.load(response))
        client = kubernetes_stream(
            self._client.connect_get_namespaced_pod_exec,
            pod.metadata.name,
            pod.metadata.namespace,
            container=PodDefaults.SIDECAR_CONTAINER_NAME,
            command=[
                '/bin/sh',
                '-c',
                f'cat {PodDefaults.XCOM_MOUNT_PATH}/return.json',
            ],
            stderr=True,
            stdin=False,
            stdout=True,
            tty=False,
            _preload_content=False,
            _request_timeout=10,
        )
        client.run_forever(timeout=10)
        resp = client.read_all()
        self.log.info("Received {} ({}) ({} ... {}))".format(type(resp), len(resp), resp[:64], resp[-64:]))

        # validate it's valid json
        _ = json.loads(resp)

        # Terminate the sidecar
        _ = kubernetes_stream(
            self._client.connect_get_namespaced_pod_exec,
            pod.metadata.name,
            pod.metadata.namespace,
            container=PodDefaults.SIDECAR_CONTAINER_NAME,
            command=[
                '/bin/sh',
                '-c',
                'kill -s SIGINT 1',
            ],
            stderr=True,
            stdin=False,
            stdout=True,
            tty=False,
            _preload_content=True,
            _request_timeout=10,
        )

        return resp

    except JSONDecodeError:
        message = f'Failed to decode json document from pod: {pod.metadata.name}'
        self.log.exception(message)
        raise AirflowException(message)

    except Exception as e:
        message = f'Failed to extract xcom from pod: {pod.metadata.name}'
        self.log.exception(message)
        raise AirflowException(message)

from python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.