-
Notifications
You must be signed in to change notification settings - Fork 230
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
Implement autosuspend #3733
Implement autosuspend #3733
Conversation
@@ -223,11 +224,22 @@ func (md *machineDeployment) deployCreateMachinesForGroups(ctx context.Context, | |||
} | |||
|
|||
services := groupConfig.AllServices() | |||
autostopSetting := fly.MachineAutostopSuspend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't fly.MachineAutostopOff
the default? below logic doesn't play well when there are no services; it will default to include the group in groupsWithAutosuspendEnabled.
I don't follow why you insist in using a out-of-loop variable (the autostopSetting
) instead of something like:
for _, s := range services {
switch v := s.AutostopMachines; {
case v == nil || *v == fly.MachineAutostopOff:
// skip
case *v == fly.MachineAutostopStop:
groupsWithAutostopEnabled[name] = true
case *v == fly.MachineAutostopSuspend:
groupsWithAutosuspendEnabled[name] = true
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agh, thanks, I goofed this again!
I'm trying to take the minimum of the autostop settings across all of the process group's services, because that is what the proxy will use to decide how to downscale the group. E.g. if the process group has three services, two with auto_stop_machines = true
and one with auto_stop_machines = false
, then the proxy will take no action because of the third, not-autostoppable service. But (if I understand correctly) the existing logic would print that autostop is enabled anyway.
500302c
to
bb37439
Compare
if len(services) > 0 { | ||
// The proxy will use the most restrictive (which, in terms | ||
// of the fly.MachineAutostop type, is the least) autostop | ||
// setting across all of the group's services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Ready to approve and merge? asking because the merged fly-go changes make it difficult to work on some changes I am trying to add :) |
This updates fly-go and switches flyctl to using the new tri-state fly.MachineAutostop type for the `auto_stop_machines` setting. Autosuspend can be enabled by setting `auto_stop_machines = "suspend"`. (Note that `fly.toml` parsing continues to support the original boolean settings for this field.)
This flag now accepts the new string values for autostop ("off", "stop", "suspend") in addition to the original boolean ones.
@dangra apologies for the delay—I think this is ready now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
* test: waiting for a minute is not enough for `fly pg import` `fly pg import` makes an ephemeral machine which could linger for more than a minute sometimes. * test: TestAppsV2Example was broken The test is broken since #3733. * test: don't skip TestAppsV2Example This might be the reason the test was broken.
Change Summary
What and Why:
Add autosuspend support:
auto_suspend_machines
in fly.toml now accepts"off"
,"stop"
, and"suspend"
in addition to boolean values.--autostop
flag forfly machines create
/fly machines run
/fly machines update
acceptsoff
,stop
, andsuspend
in addition to boolean values.Note that these changes should be backward compatible.
How:
fly.MachineAutostop
type, and make the necessary changes to use it.fly machines
commands'--autostop
flag to a string, and parse it so as to accept the new values as well as the old boolean values.Related to:
Documentation