Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: add kata-proxy rollback
Browse files Browse the repository at this point in the history
If some errors occur after kata-proxy start, we need to
rollback to kill kata-proxy process

Fixes: #297

Signed-off-by: flyflypeng <[email protected]>
  • Loading branch information
flyflypeng authored and Eric Ernst committed Aug 23, 2018
1 parent a4de4e6 commit bd5c8fe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ func (k *kataAgent) generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*
}

func (k *kataAgent) startProxy(sandbox *Sandbox) error {
var err error

if k.proxy == nil {
return errorMissingProxy
}
Expand All @@ -446,10 +448,18 @@ func (k *kataAgent) startProxy(sandbox *Sandbox) error {
return err
}

// If error occurs after kata-proxy process start,
// then rollback to kill kata-proxy process
defer func() {
if err != nil && pid > 0 {
k.proxy.stop(sandbox, pid)
}
}()

// Fill agent state with proxy information, and store them.
k.state.ProxyPid = pid
k.state.URL = uri
if err := sandbox.storage.storeAgentState(sandbox.id, k.state); err != nil {
if err = sandbox.storage.storeAgentState(sandbox.id, k.state); err != nil {
return err
}

Expand Down

0 comments on commit bd5c8fe

Please sign in to comment.