Discuss log access during build


#1

Hi !

I’m currently working on another Drone patch (https://github.com/drone/drone/compare/master...gboddin:feature/log-in-build), basically it would target the agent and :

  • Add an optional build to file logger on the agent with a config to which directory it should log
  • Automatically use log-dir/repo-name/build-number as final directory
  • Store one file per build or per step
  • Allow for automatic mount of log-dir/repo-name/build-number in /.drone/logs inside the build
  • Cleanup after, as there’s no point in keeping logs on agents

The expected result is that it would be easy to get the log content during a running build :

pipeline:
  failing-step:
    image: golang:1.8
    commands: go test ...
  show-logs:
    image: alpine
    commands: cat /.drone/logs/build.log

Any recommandations on this ?

cc @bradrydzewski @tboerger @tonglil


#2

I would instead recommend building a custom drone-runtime plugin that augments the existing behavior. The new drone-runtime will be included in version 0.9 of drone which is planned to release this summer.

If it were me, I would wrap the existing Docker runtime in my plugin, and override the Tail function to copy the stream to the filesystem, so that it is available to your build. You could then wrap the Destroy function as well to cleanup logs once the build completes.

More details here:

The benefit of using a plugin is that you would not be required to maintain a fork of the agent with your custom patch. Instead you could just build a custom agent image that includes your plugin and loads on startup. It would probably look something like this:

FROM drone/agent:0.9
ADD plugin.so /usr/lib/plugin.so
ENTRYPOINT ["/bin/drone-agent", "-plugin", "/usr/lib/plugin.so"]

#3

Awesome, thank you so much for the pointers to drone-runtime !

I have to say, thank you so much for this project, it helped me a lot learning golang the last months !