Compare commits
5 Commits
0.10.7
...
0.10-relea
Author | SHA1 | Date | |
---|---|---|---|
|
ec4bfbc8fc | ||
|
de35d27bfc | ||
|
f0dea2475d | ||
|
62918a28ce | ||
|
8c936f10c5 |
@@ -38,7 +38,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version = "0.10.7"
|
||||
version = "0.10.9"
|
||||
datasourceInterval = 100 * time.Millisecond
|
||||
datasourceMaxInterval = 30 * time.Second
|
||||
datasourceTimeout = 5 * time.Minute
|
||||
|
@@ -313,6 +313,7 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
|
||||
}
|
||||
actions := make([]action, 0, len(units))
|
||||
reload := false
|
||||
restartNetworkd := false
|
||||
for _, unit := range units {
|
||||
dst := unit.Destination(root)
|
||||
if unit.Content != "" {
|
||||
@@ -349,7 +350,7 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
|
||||
}
|
||||
|
||||
if unit.Group() == "network" {
|
||||
actions = append(actions, action{"systemd-networkd.service", "restart"})
|
||||
restartNetworkd = true
|
||||
} else if unit.Command != "" {
|
||||
actions = append(actions, action{unit.Name, unit.Command})
|
||||
}
|
||||
@@ -361,6 +362,15 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
|
||||
}
|
||||
}
|
||||
|
||||
if restartNetworkd {
|
||||
log.Printf("Restarting systemd-networkd")
|
||||
res, err := um.RunUnitCommand("restart", "systemd-networkd.service")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Restarted systemd-networkd (%s)", res)
|
||||
}
|
||||
|
||||
for _, action := range actions {
|
||||
log.Printf("Calling unit command '%s %s'", action.command, action.unit)
|
||||
res, err := um.RunUnitCommand(action.command, action.unit)
|
||||
|
@@ -384,10 +384,15 @@ type TestUnitManager struct {
|
||||
enabled []string
|
||||
masked []string
|
||||
unmasked []string
|
||||
commands map[string]string
|
||||
commands []UnitAction
|
||||
reload bool
|
||||
}
|
||||
|
||||
type UnitAction struct {
|
||||
unit string
|
||||
command string
|
||||
}
|
||||
|
||||
func (tum *TestUnitManager) PlaceUnit(unit *system.Unit, dst string) error {
|
||||
tum.placed = append(tum.placed, unit.Name)
|
||||
return nil
|
||||
@@ -397,8 +402,7 @@ func (tum *TestUnitManager) EnableUnitFile(unit string, runtime bool) error {
|
||||
return nil
|
||||
}
|
||||
func (tum *TestUnitManager) RunUnitCommand(command, unit string) (string, error) {
|
||||
tum.commands = make(map[string]string)
|
||||
tum.commands[unit] = command
|
||||
tum.commands = append(tum.commands, UnitAction{unit, command})
|
||||
return "", nil
|
||||
}
|
||||
func (tum *TestUnitManager) DaemonReload() error {
|
||||
@@ -438,7 +442,7 @@ func TestProcessUnits(t *testing.T) {
|
||||
if err := processUnits(units, "", tum); err != nil {
|
||||
t.Fatalf("unexpected error calling processUnits: %v", err)
|
||||
}
|
||||
if _, ok := tum.commands["systemd-networkd.service"]; !ok {
|
||||
if len(tum.commands) != 1 || (tum.commands[0] != UnitAction{"systemd-networkd.service", "restart"}) {
|
||||
t.Errorf("expected systemd-networkd.service to be reloaded!")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user