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

Support for spot-price restart policy and GPU bid price #3745

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/superfly/fly-go v0.1.19-0.20240716210409-e3d434ec3f18
github.com/superfly/fly-go v0.1.19-0.20240722210612-a53ef77115d0
github.com/superfly/graphql v0.2.4
github.com/superfly/lfsc-go v0.1.1
github.com/superfly/macaroon v0.2.14-0.20240702184853-b8ac52a1fc77
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/superfly/fly-go v0.1.19-0.20240716210409-e3d434ec3f18 h1:lXtwecpu2Ynwm1mkSl7pcJFFM86HzJNUsrNC4vswrYg=
github.com/superfly/fly-go v0.1.19-0.20240716210409-e3d434ec3f18/go.mod h1:JQke/BwoZqrWurqYkypSlcSo7bIUgCI3eVnqMC6AUj0=
github.com/superfly/fly-go v0.1.19-0.20240722210612-a53ef77115d0 h1:wm4EJAxGKSyk+8QOHS2kWUMl7a6jQXUSmamspSHeQRs=
github.com/superfly/fly-go v0.1.19-0.20240722210612-a53ef77115d0/go.mod h1:JQke/BwoZqrWurqYkypSlcSo7bIUgCI3eVnqMC6AUj0=
github.com/superfly/graphql v0.2.4 h1:Av8hSk4x8WvKJ6MTnEwrLknSVSGPc7DWpgT3z/kt3PU=
github.com/superfly/graphql v0.2.4/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
github.com/superfly/lfsc-go v0.1.1 h1:dGjLgt81D09cG+aR9lJZIdmonjZSR5zYCi7s54+ZU2Q=
Expand Down
2 changes: 2 additions & 0 deletions internal/command/deploy/machines_launchinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func skipLaunch(origMachineRaw *fly.Machine, mConfig *fly.MachineConfig) bool {
return true
}
}
case mConfig.Restart != nil && mConfig.Restart.Policy == fly.MachineRestartPolicySpotPrice:
return true
}
return false
}
15 changes: 14 additions & 1 deletion internal/command/machine/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ var sharedFlags = flag.Set{
Description: `Set the restart policy for a Machine. Options include 'no', 'always', and 'on-fail'.
Default is 'on-fail' for Machines created by 'fly deploy' and Machines with a schedule. Default is 'always' for Machines created by 'fly m run'.`,
},
flag.Float64{
Name: "gpu-bid-price",
Description: `Set the GPU price to bid for (HELP!)`,
Hidden: true,
},
flag.StringSlice{
Name: "standby-for",
Description: "For Machines without services, a comma separated list of Machine IDs to act as standby for.",
Expand Down Expand Up @@ -404,8 +409,11 @@ func runMachineRun(ctx context.Context) error {
return nil
}

input.SkipLaunch = (len(machineConf.Standbys) > 0 || isCreate)
input.Config = machineConf
input.SkipLaunch = (len(machineConf.Standbys) > 0 || isCreate)
if machineConf.Restart != nil && machineConf.Restart.Policy == fly.MachineRestartPolicySpotPrice {
input.SkipLaunch = true
}

machine, err := flapsClient.Launch(ctx, input)
if err != nil {
Expand Down Expand Up @@ -734,6 +742,11 @@ func determineMachineConfig(
machineConf.Restart = &fly.MachineRestart{
Policy: fly.MachineRestartPolicyAlways,
}
case "spot-price":
machineConf.Restart = &fly.MachineRestart{
Policy: fly.MachineRestartPolicySpotPrice,
GPUBidPrice: float32(flag.GetFloat64(ctx, "gpu-bid-price")),
}
case "":
if flag.IsSpecified(ctx, "restart") {
// An empty policy was explicitly requested.
Expand Down
Loading