mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
debugd: reset unit failed status before restarting (#3183)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
a36e1a79f0
commit
c1e4da3ea1
@ -91,6 +91,8 @@ type dbusConn interface {
|
||||
// StopUnitContext is similar to StartUnitContext, but stops the specified unit
|
||||
// rather than starting it.
|
||||
StopUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
|
||||
// ResetFailedUnitContext resets the "failed" state of a unit.
|
||||
ResetFailedUnitContext(ctx context.Context, name string) error
|
||||
// RestartUnitContext restarts a service. If a service is restarted that isn't
|
||||
// running it will be started.
|
||||
RestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error)
|
||||
@ -122,6 +124,9 @@ func (s *ServiceManager) SystemdAction(ctx context.Context, request ServiceManag
|
||||
case Stop:
|
||||
_, err = conn.StopUnitContext(ctx, request.Unit, "replace", resultChan)
|
||||
case Restart:
|
||||
if err = conn.ResetFailedUnitContext(ctx, request.Unit); err != nil {
|
||||
s.log.Error("Failed to reset unit failed state", "error", err.Error(), "unit", request.Unit)
|
||||
}
|
||||
_, err = conn.RestartUnitContext(ctx, request.Unit, "replace", resultChan)
|
||||
case Reload:
|
||||
err = conn.ReloadContext(ctx)
|
||||
|
@ -356,6 +356,10 @@ func (c *fakeDbusConn) StopUnitContext(_ context.Context, name string, mode stri
|
||||
return c.jobID, c.actionErr
|
||||
}
|
||||
|
||||
func (c *fakeDbusConn) ResetFailedUnitContext(_ context.Context, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *fakeDbusConn) RestartUnitContext(_ context.Context, name string, mode string, ch chan<- string) (int, error) {
|
||||
c.inputs = append(c.inputs, dbusConnActionInput{name: name, mode: mode})
|
||||
ch <- c.result
|
||||
|
@ -38,6 +38,10 @@ func (c *dbusConnWrapper) StopUnitContext(ctx context.Context, name string, mode
|
||||
return c.conn.StopUnitContext(ctx, name, mode, ch)
|
||||
}
|
||||
|
||||
func (c *dbusConnWrapper) ResetFailedUnitContext(ctx context.Context, name string) error {
|
||||
return c.conn.ResetFailedUnitContext(ctx, name)
|
||||
}
|
||||
|
||||
func (c *dbusConnWrapper) RestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
|
||||
return c.conn.RestartUnitContext(ctx, name, mode, ch)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user