Compare commits

...

4 Commits

Author SHA1 Message Date
Alex Crawford
8d76c64386 coreos-cloudinit: bump to 0.9.6 2014-09-02 17:48:45 -07:00
Alex Crawford
1b854eb51e Merge pull request #218 from crawford/units
units: Ensure that the units are executed in order
2014-09-02 17:40:37 -07:00
Alex Crawford
9fcf338bf3 units: Ensure that the units are executed in order 2014-09-02 17:15:32 -07:00
Alex Crawford
fda72bdb5c coreos-cloudinit: bump to 0.9.5+git 2014-09-02 10:10:59 -07:00
2 changed files with 12 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ import (
)
const (
version = "0.9.5"
version = "0.9.6"
datasourceInterval = 100 * time.Millisecond
datasourceMaxInterval = 30 * time.Second
datasourceTimeout = 5 * time.Minute

View File

@@ -291,7 +291,11 @@ func Apply(cfg CloudConfig, env *Environment) error {
// disk, masking/unmasking units, or invoking systemd
// commands against units. It returns any error encountered.
func processUnits(units []system.Unit, root string, um system.UnitManager) error {
commands := make(map[string]string, 0)
type action struct {
unit string
command string
}
actions := make([]action, 0, len(units))
reload := false
for _, unit := range units {
dst := unit.Destination(root)
@@ -329,9 +333,9 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
}
if unit.Group() == "network" {
commands["systemd-networkd.service"] = "restart"
actions = append(actions, action{"systemd-networkd.service", "restart"})
} else if unit.Command != "" {
commands[unit.Name] = unit.Command
actions = append(actions, action{unit.Name, unit.Command})
}
}
@@ -341,13 +345,13 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
}
}
for unit, command := range commands {
log.Printf("Calling unit command '%s %s'", command, unit)
res, err := um.RunUnitCommand(command, unit)
for _, action := range actions {
log.Printf("Calling unit command '%s %s'", action.command, action.unit)
res, err := um.RunUnitCommand(action.command, action.unit)
if err != nil {
return err
}
log.Printf("Result of '%s %s': %s", command, unit, res)
log.Printf("Result of '%s %s': %s", action.command, action.unit, res)
}
return nil