Skip to content

Commit

Permalink
fix tests and potential segfault in `configureLaunchInputForReleaseCo…
Browse files Browse the repository at this point in the history
…mmand`
  • Loading branch information
alichay committed Apr 5, 2023
1 parent ea12756 commit 463f0c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/command/deploy/deploy.go
Expand Up @@ -71,7 +71,7 @@ var CommonFlags = flag.Set{
flag.Int{
Name: "release-command-memory",
Description: "Set release command machine memory to a number of megabytes",
Default: 256,
Default: DefaultReleaseCommandMemoryMb,
},
flag.Bool{
Name: "force-nomad",
Expand Down
8 changes: 6 additions & 2 deletions internal/command/deploy/machines.go
Expand Up @@ -27,8 +27,9 @@ import (
)

const (
DefaultWaitTimeout = 120 * time.Second
DefaultLeaseTtl = 13 * time.Second
DefaultWaitTimeout = 120 * time.Second
DefaultLeaseTtl = 13 * time.Second
DefaultReleaseCommandMemoryMb = 256
)

type MachineDeployment interface {
Expand Down Expand Up @@ -504,6 +505,9 @@ func (md *machineDeployment) configureLaunchInputForReleaseCommand(launchInput *
if _, present := launchInput.Config.Env["RELEASE_COMMAND"]; !present {
launchInput.Config.Env["RELEASE_COMMAND"] = "1"
}
if launchInput.Config.Guest == nil {
launchInput.Config.Guest = &api.MachineGuest{}
}
launchInput.Config.Guest.MemoryMB = md.releaseCommandMemory
return launchInput
}
Expand Down
11 changes: 9 additions & 2 deletions internal/command/deploy/machines_test.go
Expand Up @@ -16,8 +16,9 @@ func stabMachineDeployment(appConfig *appconfig.Config) (*machineDeployment, err
ID: "my-dangling-org",
},
},
img: "super/balloon",
appConfig: appConfig,
img: "super/balloon",
appConfig: appConfig,
releaseCommandMemory: 891,
}
var err error
md.processConfigs, err = md.appConfig.GetProcessConfigs()
Expand Down Expand Up @@ -161,6 +162,9 @@ func Test_resolveUpdatedMachineConfig_ReleaseCommand(t *testing.T) {
DNS: &api.DNSConfig{
SkipRegistration: true,
},
Guest: &api.MachineGuest{
MemoryMB: 891,
},
},
}, md.resolveUpdatedMachineConfig(nil, true))

Expand Down Expand Up @@ -204,6 +208,9 @@ func Test_resolveUpdatedMachineConfig_ReleaseCommand(t *testing.T) {
DNS: &api.DNSConfig{
SkipRegistration: true,
},
Guest: &api.MachineGuest{
MemoryMB: 891,
},
},
}, md.resolveUpdatedMachineConfig(origMachine, true))
}
Expand Down

0 comments on commit 463f0c2

Please sign in to comment.