fix(initialize): use REBOOT_STRATEGY in update.conf

Change from STRATEGY to REBOOT_STRATEGY and update the function names to
reflect that this is a config now.
This commit is contained in:
Brandon Philips 2014-05-06 18:11:28 -07:00
parent 7e4fa423e4
commit 9f38792d43
3 changed files with 9 additions and 9 deletions

View File

@ -130,7 +130,7 @@ func Apply(cfg CloudConfig, env *Environment) error {
} }
if s, ok := cfg.Coreos.Update["reboot-strategy"]; ok { if s, ok := cfg.Coreos.Update["reboot-strategy"]; ok {
if err := WriteLocksmithEnvironment(s, env.Root()); err != nil { if err := WriteLocksmithConfig(s, env.Root()); err != nil {
log.Fatalf("Failed to write locksmith config to filesystem: %v", err) log.Fatalf("Failed to write locksmith config to filesystem: %v", err)
} }
log.Printf("Wrote locksmith config file to filesystem") log.Printf("Wrote locksmith config file to filesystem")

View File

@ -40,10 +40,10 @@ func addStrategy(strategy string, root string) error {
scanner := bufio.NewScanner(conf) scanner := bufio.NewScanner(conf)
sawStrat := false sawStrat := false
stratLine := "STRATEGY="+strategy stratLine := "REBOOT_STRATEGY="+strategy
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
if strings.HasPrefix(line, "STRATEGY=") { if strings.HasPrefix(line, "REBOOT_STRATEGY=") {
line = stratLine line = stratLine
sawStrat = true sawStrat = true
} }
@ -60,8 +60,8 @@ func addStrategy(strategy string, root string) error {
return os.Rename(tmp.Name(), etcUpdate) return os.Rename(tmp.Name(), etcUpdate)
} }
// WriteLocksmithEnvironment writes a drop-in unit for locksmith // WriteLocksmithConfig updates the `update.conf` file with a REBOOT_STRATEGY for locksmith.
func WriteLocksmithEnvironment(strategy string, root string) error { func WriteLocksmithConfig(strategy string, root string) error {
cmd := "restart" cmd := "restart"
if strategy == "off" { if strategy == "off" {
err := system.MaskUnit(locksmithUnit, root) err := system.MaskUnit(locksmithUnit, root)

View File

@ -12,11 +12,11 @@ const (
GROUP=thegroupc` GROUP=thegroupc`
configured = base + ` configured = base + `
STRATEGY=awesome REBOOT_STRATEGY=awesome
` `
expected = base + ` expected = base + `
STRATEGY=etcd-lock REBOOT_STRATEGY=etcd-lock
` `
) )
@ -44,7 +44,7 @@ func TestLocksmithEnvironmentWrittenToDisk(t *testing.T) {
} }
} }
if err := WriteLocksmithEnvironment("etcd-lock", dir); err != nil { if err := WriteLocksmithConfig("etcd-lock", dir); err != nil {
t.Fatalf("Processing of LocksmithEnvironment failed: %v", err) t.Fatalf("Processing of LocksmithEnvironment failed: %v", err)
} }
@ -77,7 +77,7 @@ func TestLocksmithEnvironmentMasked(t *testing.T) {
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
setupFixtures(dir) setupFixtures(dir)
if err := WriteLocksmithEnvironment("off", dir); err != nil { if err := WriteLocksmithConfig("off", dir); err != nil {
t.Fatalf("Processing of LocksmithEnvironment failed: %v", err) t.Fatalf("Processing of LocksmithEnvironment failed: %v", err)
} }