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:
parent
7e4fa423e4
commit
9f38792d43
@ -130,7 +130,7 @@ func Apply(cfg CloudConfig, env *Environment) error {
|
||||
}
|
||||
|
||||
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.Printf("Wrote locksmith config file to filesystem")
|
||||
|
@ -40,10 +40,10 @@ func addStrategy(strategy string, root string) error {
|
||||
scanner := bufio.NewScanner(conf)
|
||||
|
||||
sawStrat := false
|
||||
stratLine := "STRATEGY="+strategy
|
||||
stratLine := "REBOOT_STRATEGY="+strategy
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.HasPrefix(line, "STRATEGY=") {
|
||||
if strings.HasPrefix(line, "REBOOT_STRATEGY=") {
|
||||
line = stratLine
|
||||
sawStrat = true
|
||||
}
|
||||
@ -60,8 +60,8 @@ func addStrategy(strategy string, root string) error {
|
||||
return os.Rename(tmp.Name(), etcUpdate)
|
||||
}
|
||||
|
||||
// WriteLocksmithEnvironment writes a drop-in unit for locksmith
|
||||
func WriteLocksmithEnvironment(strategy string, root string) error {
|
||||
// WriteLocksmithConfig updates the `update.conf` file with a REBOOT_STRATEGY for locksmith.
|
||||
func WriteLocksmithConfig(strategy string, root string) error {
|
||||
cmd := "restart"
|
||||
if strategy == "off" {
|
||||
err := system.MaskUnit(locksmithUnit, root)
|
||||
|
@ -12,11 +12,11 @@ const (
|
||||
GROUP=thegroupc`
|
||||
|
||||
configured = base + `
|
||||
STRATEGY=awesome
|
||||
REBOOT_STRATEGY=awesome
|
||||
`
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ func TestLocksmithEnvironmentMasked(t *testing.T) {
|
||||
defer os.RemoveAll(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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user