Skip to content

Commit

Permalink
agent: New method stop() for agent interface
Browse files Browse the repository at this point in the history
This stop method will be used to make sure we stop the connection
with the agent running on the VM, before the hypervisor stop the VM.

In some cases, keeping an opened connection could prevent the hypervisor
from stopping the VM.

In case we want to stop the pod, this means the pod

Signed-off-by: Sebastien Boeuf <[email protected]>
  • Loading branch information
Sebastien Boeuf committed Oct 25, 2016
1 parent b4baa1d commit 0f7de35
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,7 @@ type agent interface {

// stopPod will tell the agent to stop all containers related to the Pod.
stopPod(config PodConfig) error

// stop will stop the agent on the host.
stop() error
}
25 changes: 25 additions & 0 deletions hyperstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,28 @@ func (h *hyper) stopPod(config PodConfig) error {

return nil
}

// stop is the agent stopping implementation for hyperstart.
func (h *hyper) stop() error {
if h.cCtl == nil {
return fmt.Errorf("Cannot close CTL channel, fd is nil")
}

err := h.cCtl.Close()
if err != nil {
return err
}
h.cCtl = nil

if h.cTty == nil {
return fmt.Errorf("Cannot close TTY channel, fd is nil")
}

err = h.cTty.Close()
if err != nil {
return err
}
h.cTty = nil

return nil
}
5 changes: 5 additions & 0 deletions noop_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ func (n *noopAgent) startPod(config PodConfig) error {
func (n *noopAgent) stopPod(config PodConfig) error {
return nil
}

// stop is the Noop agent stopping implementation. It does nothing.
func (n *noopAgent) stop() error {
return nil
}
5 changes: 5 additions & 0 deletions pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ func (p *Pod) stop() error {
return err
}

err = p.agent.stop()
if err != nil {
return err
}

err = p.hypervisor.stopPod()
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions sshd.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ func (s *sshd) startPod(config PodConfig) error {
func (s *sshd) stopPod(config PodConfig) error {
return nil
}

// stop is the agent stopping implementation for sshd.
func (s *sshd) stop() error {
return nil
}

0 comments on commit 0f7de35

Please sign in to comment.