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

launch: always high-availability #3562

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions internal/command/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ var CommonFlags = flag.Set{
Default: false,
Hidden: true,
},
flag.Bool{
Name: "ha",
Description: "Create spare machines that increases app availability",
Default: true,
},
flag.Bool{
Name: "smoke-checks",
Description: "Perform smoke checks during deployment",
Expand Down Expand Up @@ -192,6 +187,11 @@ func New() *Command {
flag.App(),
flag.AppConfig(),
// Not in CommonFlags because it's not relevant to a first deploy
flag.Bool{
Name: "ha",
Description: "Create spare machines that increases app availability",
Default: true,
},
flag.Bool{
Name: "update-only",
Description: "Do not create Machines for new process groups",
Expand Down
9 changes: 0 additions & 9 deletions internal/command/launch/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ func (state *launchState) Launch(ctx context.Context) error {
return err
}

org, err := state.Org(ctx)
if err != nil {
return err
}
if !planValidateHighAvailability(ctx, state.Plan, org, !state.warnedNoCcHa) {
state.Plan.HighAvailability = false
state.warnedNoCcHa = true
}

app, err := state.createApp(ctx)
if err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions internal/command/launch/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ type LaunchPlan struct {
AppName string `json:"name"`
OrgSlug string `json:"org"`

RegionCode string `json:"region"`
HighAvailability bool `json:"ha"`
RegionCode string `json:"region"`
// Deprecated: The UI exposes this for now so we'll honor it, but we're moving towards always HA for Fly Launch apps
HighAvailability bool `json:"ha"`

// Deprecated: The UI currently returns this instead of Compute, but new development should use Compute.
CPUKind string `json:"vm_cpukind,omitempty"`
Expand Down
33 changes: 7 additions & 26 deletions internal/command/launch/plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ const recoverableSpecifyInUi = "must be specified in UI"
// Doing this can lead to double-calculation, especially of scanners which could
// have a lot of processing to do. Hence, a cache :)
type planBuildCache struct {
appConfig *appconfig.Config
sourceInfo *scanner.SourceInfo
warnedNoCcHa bool // true => We have already warned that deploying ha is impossible for an org with no payment method
appConfig *appconfig.Config
sourceInfo *scanner.SourceInfo
}

func appNameTakenErr(appName string) error {
Expand Down Expand Up @@ -184,7 +183,7 @@ func buildManifest(ctx context.Context, recoverableErrors *recoverableErrorBuild
AppName: appName,
OrgSlug: org.Slug,
RegionCode: region.Code,
HighAvailability: flag.GetBool(ctx, "ha"),
HighAvailability: true,
Compute: compute,
CPUKind: guest.CPUKind,
CPUs: guest.CPUs,
Expand All @@ -207,13 +206,8 @@ func buildManifest(ctx context.Context, recoverableErrors *recoverableErrorBuild
}

buildCache := &planBuildCache{
appConfig: appConfig,
sourceInfo: srcInfo,
warnedNoCcHa: false,
}

if planValidateHighAvailability(ctx, lp, org, true) {
buildCache.warnedNoCcHa = true
appConfig: appConfig,
sourceInfo: srcInfo,
}

if srcInfo != nil {
Expand Down Expand Up @@ -264,11 +258,9 @@ func stateFromManifest(ctx context.Context, m LaunchManifest, optionalCache *pla
var (
appConfig *appconfig.Config
copiedConfig bool
warnedNoCcHa bool
)
if optionalCache != nil {
appConfig = optionalCache.appConfig
warnedNoCcHa = optionalCache.warnedNoCcHa
} else {
appConfig, copiedConfig, err = determineBaseAppConfig(ctx)
if err != nil {
Expand Down Expand Up @@ -348,9 +340,8 @@ func stateFromManifest(ctx context.Context, m LaunchManifest, optionalCache *pla
},
env: envVars,
planBuildCache: planBuildCache{
appConfig: appConfig,
sourceInfo: srcInfo,
warnedNoCcHa: warnedNoCcHa,
appConfig: appConfig,
sourceInfo: srcInfo,
},
cache: map[string]interface{}{},
}, nil
Expand Down Expand Up @@ -652,13 +643,3 @@ func determineCompute(ctx context.Context, config *appconfig.Config, srcInfo *sc
}
return []*appconfig.Compute{guestToCompute(guest)}, reason, nil
}

func planValidateHighAvailability(ctx context.Context, p *plan.LaunchPlan, org *fly.Organization, print bool) bool {
if !org.Billable && p.HighAvailability {
if print {
fmt.Fprintln(iostreams.FromContext(ctx).ErrOut, "Warning: This organization has no payment method, turning off high availability")
}
return false
}
return true
}
Loading