mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
runtime: return error if clh's binary has not a normal stat
When checking clh's binary path if valid, return error even though the error is not a IsNotExist error. And add errors to log filed when errors occurred. Fixes: #2208 Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
parent
c8f32936d3
commit
9081bee2fd
@ -561,7 +561,7 @@ func (clh *cloudHypervisor) resizeMemory(ctx context.Context, reqMemMB uint32, m
|
|||||||
resize := chclient.VmResize{DesiredRam: int64(newMem.ToBytes())}
|
resize := chclient.VmResize{DesiredRam: int64(newMem.ToBytes())}
|
||||||
clh.Logger().WithFields(log.Fields{"current-memory": currentMem, "new-memory": newMem}).Debug("updating VM memory")
|
clh.Logger().WithFields(log.Fields{"current-memory": currentMem, "new-memory": newMem}).Debug("updating VM memory")
|
||||||
if _, err = cl.VmResizePut(ctx, resize); err != nil {
|
if _, err = cl.VmResizePut(ctx, resize); err != nil {
|
||||||
clh.Logger().WithFields(log.Fields{"current-memory": currentMem, "new-memory": newMem}).Warnf("failed to update memory %s", openAPIClientError(err))
|
clh.Logger().WithError(err).WithFields(log.Fields{"current-memory": currentMem, "new-memory": newMem}).Warnf("failed to update memory %s", openAPIClientError(err))
|
||||||
err = fmt.Errorf("Failed to resize memory from %d to %d: %s", currentMem, newMem, openAPIClientError(err))
|
err = fmt.Errorf("Failed to resize memory from %d to %d: %s", currentMem, newMem, openAPIClientError(err))
|
||||||
return uint32(currentMem.ToMiB()), memoryDevice{}, openAPIClientError(err)
|
return uint32(currentMem.ToMiB()), memoryDevice{}, openAPIClientError(err)
|
||||||
}
|
}
|
||||||
@ -777,7 +777,7 @@ func (clh *cloudHypervisor) terminate(ctx context.Context, waitOnly bool) (err e
|
|||||||
|
|
||||||
clh.Logger().Debug("stop virtiofsd")
|
clh.Logger().Debug("stop virtiofsd")
|
||||||
if err = clh.virtiofsd.Stop(ctx); err != nil {
|
if err = clh.virtiofsd.Stop(ctx); err != nil {
|
||||||
clh.Logger().Error("failed to stop virtiofsd")
|
clh.Logger().WithError(err).Error("failed to stop virtiofsd")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -839,7 +839,7 @@ func (clh *cloudHypervisor) clhPath() (string, error) {
|
|||||||
return "", fmt.Errorf("Cloud-Hypervisor path (%s) does not exist", p)
|
return "", fmt.Errorf("Cloud-Hypervisor path (%s) does not exist", p)
|
||||||
}
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clh *cloudHypervisor) launchClh() (int, error) {
|
func (clh *cloudHypervisor) launchClh() (int, error) {
|
||||||
@ -893,7 +893,7 @@ func (clh *cloudHypervisor) launchClh() (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clh.waitVMM(clhTimeout); err != nil {
|
if err := clh.waitVMM(clhTimeout); err != nil {
|
||||||
clh.Logger().WithField("error", err).Warn("cloud-hypervisor init failed")
|
clh.Logger().WithError(err).Warn("cloud-hypervisor init failed")
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,7 +1134,7 @@ func (clh *cloudHypervisor) cleanupVM(force bool) error {
|
|||||||
path, err := clh.vsockSocketPath(clh.id)
|
path, err := clh.vsockSocketPath(clh.id)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err := os.Remove(path); err != nil {
|
if err := os.Remove(path); err != nil {
|
||||||
clh.Logger().WithField("path", path).Warn("removing vm socket failed")
|
clh.Logger().WithError(err).WithField("path", path).Warn("removing vm socket failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user