mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
cmd/cli: silent un-necessary error for physical interfaces loop
The loop is run after the main interface DNS was set, thus the error would make noise to users. This commit removes the noise, by making currentStaticDNS returns an additional error, so it's up to the caller to decive whether to emit the error or not. Further, the physical interface loop will now only log when the callback function runs successfully. Emitting the callback error can be done in the future, until we can figure out how to detect physical interfaces in Go portably.
This commit is contained in:
committed by
Cuong Manh Le
parent
fdb82f6ec3
commit
583718f234
+3
-6
@@ -703,11 +703,8 @@ func withEachPhysicalInterfaces(excludeIfaceName, context string, f func(i *net.
|
||||
if strings.Contains(netIface.Name, "vEthernet") {
|
||||
return
|
||||
}
|
||||
if err := f(netIface); err != nil {
|
||||
if ifaceUp(netIface) {
|
||||
mainLog.Load().Warn().Err(err).Msgf("failed to %s for interface: %q", context, i.Name)
|
||||
}
|
||||
} else {
|
||||
// TODO: investigate whether we should report this error?
|
||||
if err := f(netIface); err == nil {
|
||||
mainLog.Load().Debug().Msgf("%s for interface %q successfully", context, i.Name)
|
||||
}
|
||||
})
|
||||
@@ -735,7 +732,7 @@ func saveCurrentStaticDNS(iface *net.Interface) error {
|
||||
if err := os.Remove(file); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
mainLog.Load().Warn().Err(err).Msg("could not remove old static DNS settings file")
|
||||
}
|
||||
ns := currentStaticDNS(iface)
|
||||
ns, _ := currentStaticDNS(iface)
|
||||
if len(ns) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user