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

Enable streaming of build logs #459

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

munishchouhan
Copy link
Member

This PR will enalbe log streaming to get build log endpoint, while build is in process

@munishchouhan munishchouhan linked an issue Apr 17, 2024 that may be closed by this pull request
@munishchouhan munishchouhan marked this pull request as draft April 17, 2024 16:10
@munishchouhan munishchouhan self-assigned this Apr 17, 2024
@munishchouhan
Copy link
Member Author

@pditommaso is this required or should it refresh automatically?

wavebuildpodlogs1.mov

@pditommaso
Copy link
Collaborator

If only build box content is refreshed while the status is PENDING, it would be cool

@munishchouhan
Copy link
Member Author

If only build box content is refreshed while the status is PENDING, it would be cool

I will give it a try

@munishchouhan
Copy link
Member Author

@pditommaso build logs with refresh now

refreshwavebuildlogs.mov

Comment on lines 473 to 480
try {
return k8sClient.coreV1Api().readNamespacedPodLog(name, namespace, null, null, null, null, null, null, null, null, null)
} catch (Exception e) {
// logging trace here because errors are expected when the pod is not running
log.trace "Unable to fetch logs for pod: $name", e
return null
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@munishchouhan munishchouhan Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did tried it, but streamNamespacedPodLog() waits till the pod execution is completed. I will dig more

Copy link
Member Author

@munishchouhan munishchouhan Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will move the logic to convert string to inputstream to this function so that getLogs return input stream

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is a limitation of java client or a bug, but I'm quite sure it's possible to stream the logs of a running pod.

I've made a simple test running a pod like this

kubectl run counter --image=busybox --command -- /bin/sh -c 'n=0; while true; do echo $((n++)); sleep 1;

Then I've used the K8s client implemented in Nextflow, that's a bare simple http request over URLConnection.

This snippet just stream the pod logs until the pod completes

    def 'should get pod log' () {
        given:
        def settings = ['context': 'docker-desktop', name: 'default']
        def config = new K8sConfig(settings)
        def client = new K8sClient( config.getClient() )

        when:
        def logs = client.podLog([follow:'true'], 'counter')
        then:
        logs.text == 'hello\n'
    }

@munishchouhan munishchouhan marked this pull request as ready for review April 19, 2024 13:37
@munishchouhan
Copy link
Member Author

@pditommaso its ready for review

@munishchouhan
Copy link
Member Author

I have moved the docs changes to #464
it will easier to apply once the docs repo is in sync with wave

@munishchouhan
Copy link
Member Author

Suggestion from @ewels
Was thinking about what you were saying about ASCII codes in the logs yesterday
. I wonder if we can keep them (maybe via a flag in the API?). I would love to be able to render the colours if possible as it makes the logs much easier to read.
The back-end used by Hub is written Python, and my favourite library Rich is able to convert ascii codes to html. So we might be able to do that on the round trip and preserve colour. On the Wave side we just have to not throw them out. What do you think?

@pditommaso
Copy link
Collaborator

Please keep colour outside of this PR. We need fist makes the logs stream to work

@munishchouhan
Copy link
Member Author

Please keep colour outside of this PR. We need fist makes the logs stream to work

I will create another issue

@munishchouhan
Copy link
Member Author

merged get messed up, moving to draft

@munishchouhan munishchouhan marked this pull request as draft October 17, 2024 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable streaming of build logs
2 participants