Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheduled machines to fly.toml #3640

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/appconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Config struct {

// Fields that are process group aware must come after Processes
Processes map[string]string `toml:"processes,omitempty" json:"processes,omitempty"`
Schedules map[string]string `toml:"schedules,omitempty" json:"schedules,omitempty"`
Mounts []Mount `toml:"mounts,omitempty" json:"mounts,omitempty"`
HTTPService *HTTPService `toml:"http_service,omitempty" json:"http_service,omitempty"`
Services []Service `toml:"services,omitempty" json:"services,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions internal/appconfig/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ func (c *Config) updateMachineConfig(src *fly.MachineConfig) (*fly.MachineConfig
mConfig.Guest = guest
}

// Schedule
mConfig.Schedule = c.Schedules[processGroup]

// Restart Policy
mConfig.Restart = nil

Expand Down
5 changes: 5 additions & 0 deletions internal/appconfig/processgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ func (c *Config) Flatten(groupName string) (*Config, error) {
return dst.flattenGroupMatches(groupName, k)
})

// [schedules]
dst.Schedules = lo.PickBy(dst.Schedules, func(k, v string) bool {
return k == groupName
lillian-b marked this conversation as resolved.
Show resolved Hide resolved
})

// [checks]
dst.Checks = lo.PickBy(dst.Checks, func(_ string, check *ToplevelCheck) bool {
return matchesGroups(check.Processes)
Expand Down
8 changes: 4 additions & 4 deletions internal/command/deploy/machines_deploymachinesapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ func suggestChangeWaitTimeout(err error, flagName string) error {

func (md *machineDeployment) waitForMachine(ctx context.Context, e *machineUpdateEntry) error {
lm := e.leasableMachine
// Don't wait for SkipLaunch machines, they are updated but not started
if e.launchInput.SkipLaunch {
// Don't wait for SkipLaunch or scheduled machines, they are updated but not started
if e.launchInput.SkipLaunch || e.launchInput.Config.Schedule != "" {
lillian-b marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

Expand Down Expand Up @@ -839,8 +839,8 @@ func (md *machineDeployment) spawnMachineInGroup(ctx context.Context, groupName
statuslogger.Logf(ctx, "Machine %s was created", md.colorize.Bold(lm.FormattedMachineId()))
defer lm.ReleaseLease(ctx)

// Don't wait for SkipLaunch machines, they are created but not started
if launchInput.SkipLaunch {
// Don't wait for SkipLaunch or scheduled machines, they are created but not started
if launchInput.SkipLaunch || launchInput.Config.Schedule != "" {
return lm, nil
}

Expand Down
Loading