engine: resources: Print a warning if svc is slow
The biggest horror is blocked execution somewhere, so if the svc start, stop or reload is being slow, then at least print a message to warn us.
This commit is contained in:
@@ -483,16 +483,28 @@ func (obj *SvcRes) CheckApply(ctx context.Context, apply bool) (bool, error) {
|
|||||||
}
|
}
|
||||||
refresh = false // We did a start or stop, so a reload is not needed.
|
refresh = false // We did a start or stop, so a reload is not needed.
|
||||||
|
|
||||||
// TODO: Do we need a timeout here?
|
// TODO: Should we permanenty error after a long timeout here?
|
||||||
|
for {
|
||||||
|
warn := true // warn once
|
||||||
select {
|
select {
|
||||||
case status, ok = <-result:
|
case status, ok = <-result:
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected closed channel during start/stop")
|
return false, fmt.Errorf("unexpected closed channel during start/stop")
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
if warn {
|
||||||
|
obj.init.Logf("service start/stop is slow...")
|
||||||
|
}
|
||||||
|
warn = false
|
||||||
|
continue
|
||||||
|
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return false, ctx.Err()
|
return false, ctx.Err()
|
||||||
}
|
}
|
||||||
|
break // don't loop forever
|
||||||
|
}
|
||||||
|
|
||||||
switch status {
|
switch status {
|
||||||
case "":
|
case "":
|
||||||
@@ -537,16 +549,28 @@ func (obj *SvcRes) CheckApply(ctx context.Context, apply bool) (bool, error) {
|
|||||||
return false, errwrap.Wrapf(err, "failed to reload unit")
|
return false, errwrap.Wrapf(err, "failed to reload unit")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Do we need a timeout here?
|
// TODO: Should we permanenty error after a long timeout here?
|
||||||
|
for {
|
||||||
|
warn := true // warn once
|
||||||
select {
|
select {
|
||||||
case status, ok = <-result:
|
case status, ok = <-result:
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected closed channel during reload")
|
return false, fmt.Errorf("unexpected closed channel during reload")
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
if warn {
|
||||||
|
obj.init.Logf("service start/stop is slow...")
|
||||||
|
}
|
||||||
|
warn = false
|
||||||
|
continue
|
||||||
|
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return false, ctx.Err()
|
return false, ctx.Err()
|
||||||
}
|
}
|
||||||
|
break // don't loop forever
|
||||||
|
}
|
||||||
|
|
||||||
switch status {
|
switch status {
|
||||||
case "":
|
case "":
|
||||||
|
|||||||
Reference in New Issue
Block a user