From 41096f5c97e2b7aa4ceb48a21e8d020df8e57b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Tue, 16 Jul 2024 17:35:50 -0300 Subject: [PATCH] `fly m run` support for spot-price restart policy and gpu bid price --- go.mod | 2 +- go.sum | 4 ++-- internal/command/machine/run.go | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9a07baf190..f55f13e30a 100644 --- a/go.mod +++ b/go.mod @@ -70,7 +70,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 diff --git a/go.sum b/go.sum index ead036ea15..5667686357 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/command/machine/run.go b/internal/command/machine/run.go index 83e0cf3a99..a400ce2090 100644 --- a/internal/command/machine/run.go +++ b/internal/command/machine/run.go @@ -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.", @@ -734,6 +739,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.