Compare commits

..

5 Commits

Author SHA1 Message Date
Alex Crawford
ec4bfbc8fc coreos-cloudinit: bump to 0.10.9 2014-12-02 17:31:49 -08:00
Alex Crawford
de35d27bfc Merge pull request #274 from crawford/networkd
initialize: restart networkd before other units
2014-12-02 17:30:47 -08:00
Alex Crawford
f0dea2475d initialize: restart networkd before other units 2014-12-02 17:21:31 -08:00
Alex Crawford
62918a28ce coreos-cloudinit: bump to 0.10.8 2014-12-02 13:07:44 -08:00
Alex Crawford
8c936f10c5 initialize: only restart networkd once per config
Regression introduced by 9fcf338bf3.

Networkd was erroneously being restarted once per network unit. It
should only restart once for the entire config.
2014-12-02 13:04:55 -08:00
3 changed files with 20 additions and 6 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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!")
}