canonical / craft-application

The basis for *craft applications
https://canonical-craft-application.readthedocs-hosted.com/en/latest
GNU Lesser General Public License v3.0
7 stars 12 forks source link

fetch-service logging does not work on snapped craft tools #550

Open tigarmo opened 6 days ago

tigarmo commented 6 days ago

Bug Description

The existing fetch-service integration is supposed to log the fetch-service output to $HOME//snap/fetch-service/common/craft/fetch-log.txt. This works fine in the integration tests but on real runs with a snapped application the log file is always empty. Also the location of this file is very cryptic and hidden - it needs to be reported somewhere so users have a chance of finding it (when its fixed).

To Reproduce

Run a snapped craft tool with --enable-fetch-service=permissive. The file at $HOME//snap/fetch-service/common/craft/fetch-log.txt will be created but will be empty.

part yaml

No response

Relevant log output

n/a
syncronize-issues-to-jira[bot] commented 6 days ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3656.

This message was autogenerated

tigarmo commented 9 hours ago

Update: the reason that the logging doesn't work is that the snap confinement does not let the fetch-service process (strictly confined) to inherit the file descriptor to the log file created by the snapped craft tool (classically confined). Trying to use the fetch-service binary directly fixes the logging issue but raises other issues as the fetch-service needs other things (licensecheck, which is a perl app, and git) which are included in its snap.

The solution then is to update the fetch-service itself to have it log to a provided filepath. This issue will still track the fix on the craft-application side.

Ref: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753