#564

inconsistent restart behavior for scripted services with different defaults

Openq66opened 3mo ago

The default value for restart is yes. The documentation implies that this works for any service type (i.e. scripted/internal/etc services should restart based on e.g. a dependency stopping). However, setting it to on-failure only works for (bg)process services and is like no for scripted services. Changing the default alters it for any service type. It would be desirable if the dinit-default (set via configure/mconfig) restart value of on-failure (which IMO makes much more sense; maybe would be good to consider making that the general default too?) behaved like yes for non-process/bgprocess services.

Activity

17
q663mo ago

additionally, is there actually a reason scripted services can't restart on failure exit code?

q663mo ago

additionally, is there actually a reason scripted services can't restart on failure exit code?

q663mo ago

additionally, is there actually a reason scripted services can't restart on failure exit code?

q663mo ago

additionally, is there actually a reason scripted services can't restart on failure exit code?

q663mo ago

i guess what i'm asking is a behavior where:

  1. all services restart by default due to dependencies, no matter the service type (unless inhibited with restart = no)
  2. process services don't restart if their process exits with 0

i guess making scripted services restart on failure doesn't make much sense as they are one-shot and therefore have no real supervision, even though it would be possible? maybe with an explicit restart = yes? not sure

q663mo ago

i guess what i'm asking is a behavior where:

  1. all services restart by default due to dependencies, no matter the service type (unless inhibited with restart = no)
  2. process services don't restart if their process exits with 0

i guess making scripted services restart on failure doesn't make much sense as they are one-shot and therefore have no real supervision, even though it would be possible? maybe with an explicit restart = yes? not sure

q663mo ago

i guess what i'm asking is a behavior where:

  1. all services restart by default due to dependencies, no matter the service type (unless inhibited with restart = no)
  2. process services don't restart if their process exits with 0

i guess making scripted services restart on failure doesn't make much sense as they are one-shot and therefore have no real supervision, even though it would be possible? maybe with an explicit restart = yes? not sure

q663mo ago

i guess what i'm asking is a behavior where:

  1. all services restart by default due to dependencies, no matter the service type (unless inhibited with restart = no)
  2. process services don't restart if their process exits with 0

i guess making scripted services restart on failure doesn't make much sense as they are one-shot and therefore have no real supervision, even though it would be possible? maybe with an explicit restart = yes? not sure

davmac3143mo ago

Agreed, restart = on-failure should apply if a dependency fails. I.e. dependency failure should count as failure for purposes of restart.

additionally, is there actually a reason scripted services can't restart on failure exit code?

There's no particular reason why a retry couldn't be attempted. It's not technically a restart (at service level) since the service never reached "started" state in this case. None of the service types currently support retry.

davmac3143mo ago

Agreed, restart = on-failure should apply if a dependency fails. I.e. dependency failure should count as failure for purposes of restart.

additionally, is there actually a reason scripted services can't restart on failure exit code?

There's no particular reason why a retry couldn't be attempted. It's not technically a restart (at service level) since the service never reached "started" state in this case. None of the service types currently support retry.

davmac3143mo ago

Agreed, restart = on-failure should apply if a dependency fails. I.e. dependency failure should count as failure for purposes of restart.

additionally, is there actually a reason scripted services can't restart on failure exit code?

There's no particular reason why a retry couldn't be attempted. It's not technically a restart (at service level) since the service never reached "started" state in this case. None of the service types currently support retry.

q663mo ago

oh, i didn't consider that - indeed, regardless of the restart value, a start will only be attempted once...

then scratch my question :) i guess retry would be a separate functionality should it ever be added

the rest of the issue still stands - i would like to configure dinit with default restart method of on-failure, but have dependency fails be considered a failure for restart purposes (which, as far as i can tell, should apply to any service type, not just process and bgprocess)

the current behavior can't accommodate that as far as i can tell, as it will alter scripted services behavior?

the current behavior goes like "if restart mode is on-failure, only set autorestart flag if the exit status was a fail, and only for process services" - as far as i understand it should be more like "if restart mode is on-failure, always set the autorestart flag for any service type, except when the service is a (bg)process service and explicitly exited with zero or term signal" perhaps?

q663mo ago

oh, i didn't consider that - indeed, regardless of the restart value, a start will only be attempted once...

then scratch my question :) i guess retry would be a separate functionality should it ever be added

the rest of the issue still stands - i would like to configure dinit with default restart method of on-failure, but have dependency fails be considered a failure for restart purposes (which, as far as i can tell, should apply to any service type, not just process and bgprocess)

the current behavior can't accommodate that as far as i can tell, as it will alter scripted services behavior?

the current behavior goes like "if restart mode is on-failure, only set autorestart flag if the exit status was a fail, and only for process services" - as far as i understand it should be more like "if restart mode is on-failure, always set the autorestart flag for any service type, except when the service is a (bg)process service and explicitly exited with zero or term signal" perhaps?

q663mo ago

oh, i didn't consider that - indeed, regardless of the restart value, a start will only be attempted once...

then scratch my question :) i guess retry would be a separate functionality should it ever be added

the rest of the issue still stands - i would like to configure dinit with default restart method of on-failure, but have dependency fails be considered a failure for restart purposes (which, as far as i can tell, should apply to any service type, not just process and bgprocess)

the current behavior can't accommodate that as far as i can tell, as it will alter scripted services behavior?

the current behavior goes like "if restart mode is on-failure, only set autorestart flag if the exit status was a fail, and only for process services" - as far as i understand it should be more like "if restart mode is on-failure, always set the autorestart flag for any service type, except when the service is a (bg)process service and explicitly exited with zero or term signal" perhaps?

davmac3143mo ago

as far as i understand it should be more like "if restart mode is on-failure, always set the autorestart flag for any service type, except when the service is a (bg)process service and explicitly exited with zero or term signal" perhaps?

Well, maybe, or maybe only actual failure should cause restart even of dependents. Eg:

  • scripted service A
  • process service B
  • A depends on B
  • B stops with no error (a clean exit). Should A restart in this case? Or in other words should any dependency stopping automatically count as failure even if it stopped "cleanly"?

I've been thinking about this a bit (sorry for the slow reply), but you might have a better sense of which behaviour would be better than I do, to be honest.

davmac3143mo ago

as far as i understand it should be more like "if restart mode is on-failure, always set the autorestart flag for any service type, except when the service is a (bg)process service and explicitly exited with zero or term signal" perhaps?

Well, maybe, or maybe only actual failure should cause restart even of dependents. Eg:

  • scripted service A
  • process service B
  • A depends on B
  • B stops with no error (a clean exit). Should A restart in this case? Or in other words should any dependency stopping automatically count as failure even if it stopped "cleanly"?

I've been thinking about this a bit (sorry for the slow reply), but you might have a better sense of which behaviour would be better than I do, to be honest.

q662mo ago

i'd lean towards not restarting

if a service depends on another and that other dependency stops cleanly, it should probably leave anything depending on it stopped, as we don't want to bring it back up spuriously