runtime: fix static check errors

It turns out we have managed to break the static checker in many
difference places with the absence of static checker in github action.
Let's fix them while enabling static checker in github actions...

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao
2021-03-24 16:36:00 +08:00
parent a2dee1f6a0
commit 74192d179d
37 changed files with 203 additions and 378 deletions

View File

@@ -445,7 +445,7 @@ func (s *Sandbox) getAndStoreGuestDetails(ctx context.Context) error {
// to physically create that sandbox i.e. starts a VM for that sandbox to eventually
// be started.
func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (*Sandbox, error) {
span, ctx := trace(ctx, "createSandbox")
span, _ := trace(ctx, "createSandbox")
defer span.End()
if err := createAssets(ctx, &sandboxConfig); err != nil {
@@ -483,7 +483,7 @@ func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
}
func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (sb *Sandbox, retErr error) {
span, ctx := trace(ctx, "newSandbox")
span, _ := trace(ctx, "newSandbox")
defer span.End()
if !sandboxConfig.valid() {
@@ -618,7 +618,7 @@ func (s *Sandbox) createCgroupManager() error {
// storeSandbox stores a sandbox config.
func (s *Sandbox) storeSandbox(ctx context.Context) error {
span, ctx := s.trace(ctx, "storeSandbox")
span, _ := s.trace(ctx, "storeSandbox")
defer span.End()
// flush data to storage
@@ -628,15 +628,6 @@ func (s *Sandbox) storeSandbox(ctx context.Context) error {
return nil
}
func rLockSandbox(sandboxID string) (func() error, error) {
store, err := persist.GetDriver()
if err != nil {
return nil, fmt.Errorf("failed to get fs persist driver: %v", err)
}
return store.Lock(sandboxID, false)
}
func rwLockSandbox(sandboxID string) (func() error, error) {
store, err := persist.GetDriver()
if err != nil {
@@ -761,7 +752,7 @@ func (s *Sandbox) createNetwork(ctx context.Context) error {
return nil
}
span, ctx := s.trace(ctx, "createNetwork")
span, _ := s.trace(ctx, "createNetwork")
defer span.End()
s.networkNS = NetworkNamespace{
@@ -951,7 +942,7 @@ func (cw *consoleWatcher) start(s *Sandbox) (err error) {
scanner = bufio.NewScanner(cw.conn)
case consoleProtoPty:
// read-only
cw.ptyConsole, err = os.Open(cw.consoleURL)
cw.ptyConsole, _ = os.Open(cw.consoleURL)
scanner = bufio.NewScanner(cw.ptyConsole)
default:
return fmt.Errorf("unknown console proto %s", cw.proto)
@@ -1003,7 +994,7 @@ func (cw *consoleWatcher) stop() {
// startVM starts the VM.
func (s *Sandbox) startVM(ctx context.Context) (err error) {
span, ctx := s.trace(ctx, "startVM")
span, _ := s.trace(ctx, "startVM")
defer span.End()
s.Logger().Info("Starting VM")
@@ -1084,7 +1075,7 @@ func (s *Sandbox) startVM(ctx context.Context) (err error) {
// stopVM: stop the sandbox's VM
func (s *Sandbox) stopVM(ctx context.Context) error {
span, ctx := s.trace(ctx, "stopVM")
span, _ := s.trace(ctx, "stopVM")
defer span.End()
s.Logger().Info("Stopping sandbox in the VM")
@@ -1460,7 +1451,7 @@ func (s *Sandbox) ResumeContainer(ctx context.Context, containerID string) error
// createContainers registers all containers, create the
// containers in the guest and starts one shim per container.
func (s *Sandbox) createContainers(ctx context.Context) error {
span, ctx := s.trace(ctx, "createContainers")
span, _ := s.trace(ctx, "createContainers")
defer span.End()
for _, contConfig := range s.config.Containers {
@@ -1532,7 +1523,7 @@ func (s *Sandbox) Start(ctx context.Context) error {
// will be destroyed.
// When force is true, ignore guest related stop failures.
func (s *Sandbox) Stop(ctx context.Context, force bool) error {
span, ctx := s.trace(ctx, "Stop")
span, _ := s.trace(ctx, "Stop")
defer span.End()
if s.state.State == types.StateStopped {
@@ -1643,7 +1634,7 @@ func (s *Sandbox) unsetSandboxBlockIndex(index int) error {
// HotplugAddDevice is used for add a device to sandbox
// Sandbox implement DeviceReceiver interface from device/api/interface.go
func (s *Sandbox) HotplugAddDevice(ctx context.Context, device api.Device, devType config.DeviceType) error {
span, ctx := s.trace(ctx, "HotplugAddDevice")
span, _ := s.trace(ctx, "HotplugAddDevice")
defer span.End()
if s.config.SandboxCgroupOnly {