Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XFN Runner: Show STDOUT of failed composition function (exit code >= 1) #42

Open
jan-di opened this issue Oct 4, 2023 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@jan-di
Copy link

jan-di commented Oct 4, 2023

What problem are you facing?

We've implemented a function similar to the example functions from docs. If this functions fails, it returns a exit code greater than 0 and prints the error message in STDOUT.

[..] "error": "cannot run Composition Function pipeline: cannot run function \"service-versioning\": cannot run container: rpc error: code = Unknown desc = exit status 1: xfn: error: spark.Command.Run(): OCI runtime error: exit status 1"

Currenty, I cannot debug a composition function that fails to execute. When the function in the OCI container fails, I see the exit code but no additional information printed in STDOUT.

How could Crossplane help solve your problem?

Provide a way to see the STDOUT of functions that failed. That may be behind a flag/option like verbosity level/debug mode, etc.
Perhaps, also STDERR could be used, as it would be the more appropriate place for error messages.

@jan-di jan-di added the enhancement New feature or request label Oct 4, 2023
@negz negz transferred this issue from crossplane/crossplane Oct 4, 2023
@negz
Copy link
Member

negz commented Oct 4, 2023

The xfn runner has moved out-of-tree, so I'm moving this issue. In v1.14 (due end of the month) we'll have a new architecture for Functions that won't be prone to this issue. We haven't started on docs yet for the new architecture, but you can learn about it here:

@jan-di
Copy link
Author

jan-di commented Oct 6, 2023

That sounds really good, thanks!

If others stumble upon this thing, we worked around it by sending the uncatched exceptions to a HTTP endpoint (jmalloc/echo-server) that runs in the same cluster. It's absolutely not pretty, but get's the job done.

import http.client
import sys
import traceback

def main():
    try:
        # your actual function code
    except Exception as e:
        try:
            trace = traceback.format_exc()
            host = "echo.default.svc.cluster.local"
            conn = http.client.HTTPConnection(host, 80)
            conn.request("POST", "/", headers={"Host": host}, body=str(trace))
            response = conn.getresponse()
            if response.status >= 400 or response.status < 200:
                raise Exception("webtrace failed")
            sys.exit(90)
        except:
            sys.exit(99)

        raise e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants