Browse Source

restartmanager: add SetPolicy() to the RestartManager interface

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 4 years ago
parent
commit
efb97da0da
2 changed files with 2 additions and 7 deletions
  1. 1 7
      container/container.go
  2. 1 0
      restartmanager/restartmanager.go

+ 1 - 7
container/container.go

@@ -557,13 +557,7 @@ func (container *Container) InitDNSHostConfig() {
 
 // UpdateMonitor updates monitor configure for running container
 func (container *Container) UpdateMonitor(restartPolicy containertypes.RestartPolicy) {
-	type policySetter interface {
-		SetPolicy(containertypes.RestartPolicy)
-	}
-
-	if rm, ok := container.RestartManager().(policySetter); ok {
-		rm.SetPolicy(restartPolicy)
-	}
+	container.RestartManager().SetPolicy(restartPolicy)
 }
 
 // FullHostname returns hostname and optional domain appended to it.

+ 1 - 0
restartmanager/restartmanager.go

@@ -23,6 +23,7 @@ var ErrRestartCanceled = errors.New("restart canceled")
 type RestartManager interface {
 	Cancel()
 	ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool, executionDuration time.Duration) (bool, chan error, error)
+	SetPolicy(policy container.RestartPolicy)
 }
 
 type restartManager struct {