Commit 8de419b1 authored by Minhan Xia's avatar Minhan Xia

expose lock release error from iptables util

parent 96d8ab72
...@@ -24,6 +24,7 @@ go_library( ...@@ -24,6 +24,7 @@ go_library(
"//vendor/github.com/godbus/dbus:go_default_library", "//vendor/github.com/godbus/dbus:go_default_library",
"//vendor/github.com/golang/glog:go_default_library", "//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/sys/unix:go_default_library", "//vendor/golang.org/x/sys/unix:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
], ],
......
...@@ -338,7 +338,7 @@ func (runner *runner) RestoreAll(data []byte, flush FlushFlag, counters RestoreC ...@@ -338,7 +338,7 @@ func (runner *runner) RestoreAll(data []byte, flush FlushFlag, counters RestoreC
} }
type iptablesLocker interface { type iptablesLocker interface {
Close() Close() error
} }
// restoreInternal is the shared part of Restore/RestoreAll // restoreInternal is the shared part of Restore/RestoreAll
...@@ -361,7 +361,11 @@ func (runner *runner) restoreInternal(args []string, data []byte, flush FlushFla ...@@ -361,7 +361,11 @@ func (runner *runner) restoreInternal(args []string, data []byte, flush FlushFla
if err != nil { if err != nil {
return err return err
} }
defer locker.Close() defer func(locker iptablesLocker) {
if err := locker.Close(); err != nil {
glog.Errorf("Failed to close iptables locks: %v", err)
}
}(locker)
} }
// run the command and return the output or an error including the output and error // run the command and return the output or an error including the output and error
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"time" "time"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
) )
...@@ -33,13 +34,19 @@ type locker struct { ...@@ -33,13 +34,19 @@ type locker struct {
lock14 *net.UnixListener lock14 *net.UnixListener
} }
func (l *locker) Close() { func (l *locker) Close() error {
errList := []error{}
if l.lock16 != nil { if l.lock16 != nil {
l.lock16.Close() if err := l.lock16.Close(); err != nil {
errList = append(errList, err)
}
} }
if l.lock14 != nil { if l.lock14 != nil {
l.lock14.Close() if err := l.lock14.Close(); err != nil {
errList = append(errList, err)
}
} }
return utilerrors.NewAggregate(errList)
} }
func grabIptablesLocks(lockfilePath string) (iptablesLocker, error) { func grabIptablesLocks(lockfilePath string) (iptablesLocker, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment