mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-01 09:42:45 +00:00
virtcontainers: add kata-proxy rollback
If some errors occur after kata-proxy start, we need to rollback to kill kata-proxy process Fixes: #297 Signed-off-by: flyflypeng <jiangpengfei9@huawei.com>
This commit is contained in:
parent
daebbd1e93
commit
c2651a85a8
@ -450,6 +450,8 @@ func (k *kataAgent) generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) startProxy(sandbox *Sandbox) error {
|
func (k *kataAgent) startProxy(sandbox *Sandbox) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
if k.proxy == nil {
|
if k.proxy == nil {
|
||||||
return errorMissingProxy
|
return errorMissingProxy
|
||||||
}
|
}
|
||||||
@ -475,10 +477,18 @@ func (k *kataAgent) startProxy(sandbox *Sandbox) error {
|
|||||||
return err
|
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.
|
// Fill agent state with proxy information, and store them.
|
||||||
k.state.ProxyPid = pid
|
k.state.ProxyPid = pid
|
||||||
k.state.URL = uri
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user