зеркало из https://github.com/microsoft/docker.git
Fix error message on firewalld init
If firewalld is not installed (or I suppose not running), firewalld was producing an error in the daemon init logs, even though firewalld is not required for iptables stuff to function. The firewalld library code was also logging directly to logrus instead of returning errors. Moved logging code higher up in the stack and changed firewalld code to return errors where appropriate. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Родитель
3697dddc0d
Коммит
38b5c7266a
|
@ -232,7 +232,9 @@ func InitDriver(config *Config) error {
|
|||
}
|
||||
|
||||
if config.EnableIptables {
|
||||
iptables.FirewalldInit()
|
||||
if err := iptables.FirewalldInit(); err != nil {
|
||||
logrus.Debugf("Error initializing firewalld: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Configure iptables for link support
|
||||
|
|
|
@ -33,19 +33,18 @@ var (
|
|||
onReloaded []*func() // callbacks when Firewalld has been reloaded
|
||||
)
|
||||
|
||||
func FirewalldInit() {
|
||||
func FirewalldInit() error {
|
||||
var err error
|
||||
|
||||
connection, err = newConnection()
|
||||
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to connect to D-Bus system bus: %s", err)
|
||||
if connection, err = newConnection(); err != nil {
|
||||
return fmt.Errorf("Failed to connect to D-Bus system bus: %v", err)
|
||||
}
|
||||
if connection != nil {
|
||||
go signalHandler()
|
||||
}
|
||||
|
||||
firewalldRunning = checkRunning()
|
||||
return nil
|
||||
}
|
||||
|
||||
// New() establishes a connection to the system bus.
|
||||
|
@ -146,19 +145,15 @@ func checkRunning() bool {
|
|||
logrus.Infof("Firewalld running: %t", err == nil)
|
||||
return err == nil
|
||||
}
|
||||
logrus.Info("Firewalld not running")
|
||||
return false
|
||||
}
|
||||
|
||||
// Firewalld's passthrough method simply passes args through to iptables/ip6tables
|
||||
func Passthrough(ipv IPV, args ...string) ([]byte, error) {
|
||||
var output string
|
||||
|
||||
logrus.Debugf("Firewalld passthrough: %s, %s", ipv, args)
|
||||
err := connection.sysobj.Call(dbusInterface+".direct.passthrough", 0, ipv, args).Store(&output)
|
||||
if output != "" {
|
||||
logrus.Debugf("passthrough output: %s", output)
|
||||
if err := connection.sysobj.Call(dbusInterface+".direct.passthrough", 0, ipv, args).Store(&output); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []byte(output), err
|
||||
return []byte(output), nil
|
||||
}
|
||||
|
|
|
@ -7,7 +7,12 @@ import (
|
|||
)
|
||||
|
||||
func TestFirewalldInit(t *testing.T) {
|
||||
FirewalldInit()
|
||||
if !checkRunning() {
|
||||
t.Skip("firewalld is not running")
|
||||
}
|
||||
if err := FirewalldInit(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReloaded(t *testing.T) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче