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

Pebble doesn't report errors starting startup-enabled services #167

Closed
barrettj12 opened this issue Dec 2, 2022 · 4 comments
Closed

Pebble doesn't report errors starting startup-enabled services #167

barrettj12 opened this issue Dec 2, 2022 · 4 comments
Labels
Feature A feature request Needs Design Needs a design or spec

Comments

@barrettj12
Copy link
Contributor

I have the following simple "service" at root/log.sh:

#!/bin/bash
while true
do
  echo "Hi I'm alive"
  sleep 1
done

and the following Pebble layer:

services:
  log:
    command: /root/log.sh
    override: merge
    startup: enabled

If I don't have permission to run /root/log.sh:

$ /root/log.sh
bash: /root/log.sh: Permission denied

then I would expect Pebble to report an error when I go pebble run, but it doesn't report anything:

$ pebble run -v
2022-12-02T02:47:24.670Z [pebble] Started daemon.
2022-12-02T02:47:24.692Z [pebble] POST /v1/services 20.668906ms 202
2022-12-02T02:47:24.693Z [pebble] Service "log" starting: /root/log.sh
2022-12-02T02:47:24.693Z [pebble] Started default services with change 9.
@benhoyt benhoyt changed the title Pebble doesn't report "permission denied" Pebble doesn't report errors starting startup-enabled services Dec 2, 2022
@benhoyt
Copy link
Contributor

benhoyt commented Dec 2, 2022

Yeah, I've noticed this too, and it's unexpected not to get any feedback (unless you specify PEBBLE_DEBUG=1). It's actually more general than just permission denied errors -- it's any error starting the startup-enabled services when the daemon starts.

Do you think it should log an error, or wait (up to 1 second per service, I think it is) and exit pebble run with an error message and non-zero exit code?

@barrettj12
Copy link
Contributor Author

It doesn't report No such file or directory errors either.

I think it should log an error right away - because errors like permission denied and no such file or directory are "unrecoverable" - trying again is not gonna help, some manual intervention is needed.

I'm not sure what Pebble's usual behaviour is, but I think exiting pebble run is probably not the right move - you still want the other services to run if possible, I presume?

@hpidcock
Copy link
Member

hpidcock commented Dec 2, 2022

I'm not sure what Pebble's usual behaviour is, but I think exiting pebble run is probably not the right move - you still want the other services to run if possible, I presume?

if the service is critical to the plan then it should have

on-failure: shutdown

@benhoyt
Copy link
Contributor

benhoyt commented Mar 21, 2024

This was actually fixed by the snapd state changes we pulled across, now that the task runner logs task failures: e494ff2#diff-e8b7c8da8654dde95838cfa0cc4b497cdd32050ea3a1bf0640e6404303aef0d6R294

Additionally, we do slightly more logging with #257.

We can consider behaviour changes like having "on-failure: shutdown" default services not starting up make Pebble not start. But that needs a spec and further considering. This issue is just about reporting the errors, which is now in place, so closing.

@benhoyt benhoyt closed this as completed Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A feature request Needs Design Needs a design or spec
Projects
None yet
Development

No branches or pull requests

3 participants