Skip to content

Commit

Permalink
amend this commit plz
Browse files Browse the repository at this point in the history
  • Loading branch information
billyb2 committed Aug 26, 2024
1 parent 6390a73 commit 60a7198
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions internal/build/imgsrc/depot.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func depotBuild(ctx context.Context, streams *iostreams.IOStreams, opts ImageOpt
streams.StopProgressIndicator()
return nil, buildErr
}
buildState.BuilderMeta.DepotBuildId = build.ID

Check failure on line 119 in internal/build/imgsrc/depot.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest-m)

buildState.BuilderMeta.DepotBuildId undefined (type *fly.BuilderMetaInput has no field or method DepotBuildId)

Check failure on line 119 in internal/build/imgsrc/depot.go

View workflow job for this annotation

GitHub Actions / test (macos-latest-xl)

buildState.BuilderMeta.DepotBuildId undefined (type *fly.BuilderMetaInput has no field or method DepotBuildId)

Check failure on line 119 in internal/build/imgsrc/depot.go

View workflow job for this annotation

GitHub Actions / test_build

buildState.BuilderMeta.DepotBuildId undefined (type *fly.BuilderMetaInput has no field or method DepotBuildId)

Check failure on line 119 in internal/build/imgsrc/depot.go

View workflow job for this annotation

GitHub Actions / test (windows-latest-l)

buildState.BuilderMeta.DepotBuildId undefined (type *fly.BuilderMetaInput has no field or method DepotBuildId)
defer func() {
buildkit.Release()
build.Finish(buildErr)
Expand Down
56 changes: 40 additions & 16 deletions internal/command/deploy/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"reflect"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -103,7 +102,6 @@ func (md *machineDeployment) appState(ctx context.Context, existingAppState *App
}
}

// TODO: could this be a list of machine id -> config?
appState := &AppState{
Machines: machineSliceToMap(machines),
}
Expand Down Expand Up @@ -198,17 +196,12 @@ func (md *machineDeployment) updateMachinesWRecovery(ctx context.Context, oldApp
machineLogger.initFromMachinePairs(machineTuples)

appStateFSM := stateless.NewStateMachine(updateNotStarted)
appStateFSM.SetTriggerParameters(triggerUpdateMachines, reflect.TypeOf(machineTuples), reflect.TypeOf(poolSize))

appStateFSM.Configure(updateNotStarted).Permit(triggerUpdateMachines, updatedMachines)
appStateFSM.Configure(updatingMachines).OnEntry(func(ctx context.Context, args ...any) error {
machPairs := args[0].([]machinePairing)
poolSize := args[1].(int)

return md.acquireLeases(ctx, machPairs, poolSize, machineLogger)
return md.acquireLeases(ctx, machineTuples, poolSize, machineLogger)
}).OnExit(func(ctx context.Context, args ...any) error {
machPairs := args[0].([]machinePairing)
return md.releaseLeases(ctx, machPairs, machineLogger)
return md.releaseLeases(ctx, machineTuples, machineLogger)
})

attempts := 0
Expand Down Expand Up @@ -333,7 +326,7 @@ func (md *machineDeployment) updateMachinesWRecovery(ctx context.Context, oldApp
})

for {
if updateErr := appStateFSM.FireCtx(ctx, triggerUpdateMachines, machineTuples, poolSize); updateErr != nil {
if updateErr := appStateFSM.FireCtx(ctx, triggerUpdateMachines); updateErr != nil {
// if we return an error when triggering machines failed, it means we're done
if err := appStateFSM.FireCtx(ctx, triggerUpdateMachinesFailed, updateErr); err != nil {
return appStateFSM.FireCtx(ctx, triggerUpdateFailed)
Expand Down Expand Up @@ -518,14 +511,45 @@ func compareConfigs(ctx context.Context, oldConfig, newConfig *fly.MachineConfig
return isEqual
}

func (md *machineDeployment) updateMachineWChecks(ctx context.Context, oldMachine, newMachine *fly.Machine, sl statuslogger.StatusLine, io *iostreams.IOStreams, healthcheckResult *healthcheckResult) error {
ctx, span := tracing.GetTracer().Start(ctx, "update_machine_w_checks", trace.WithAttributes(
attribute.Bool("smoke_checks", healthcheckResult.smokeChecksPassed),
attribute.Bool("machine_checks", healthcheckResult.machineChecksPassed),
attribute.Bool("regular_checks", healthcheckResult.regularChecksPassed),
))
type machineFsmState string

const (
machineUpdateNotStarted machineFsmState = "machineUpdateNotStarted"
machineCreated machineFsmState = "machineCreated"
machineReplaced machineFsmState = "machineReplaced"
machineDestroyed machineFsmState = "machineDestroyed"
machineConfigUpdateFailedBadFlaps machineFsmState = "machineConfigUpdateFailedBadFlaps "
machineConfigUpdated machineFsmState = "machineUpdated"
machineGoodStatus machineFsmState = "machineGoodStatus"
machineGoodSmokeChecks machineFsmState = "machineGoodSmokeChecks"
machineGoodMachineChecks machineFsmState = "machineGoodSmokeChecks"
machineGoodHealthChecks machineFsmState = "machineGoodHealthChecks"
machineUpdateComplete machineFsmState = "machineUpdateComplete"
)

type machineFsmTrigger string

const (
triggerMachineEnsureCreated machineFsmState = "triggerMachineCreated"
triggerMachineConfigUpdated machineFsmState = "triggerMachineConfigUpdated"
triggerMachineGoodStatus machineFsmState = "triggerMachineGoodStatus"
triggerMachineGoodSmokeChecks machineFsmState = "triggerMachineGoodSmokeChecks"
triggerMachineGoodMachineChecks machineFsmState = "triggerMachineGoodMachineChecks"
triggerMachineGoodHealthChecks machineFsmState = "triggerMachineGoodHealthChecks"
triggerMachineUpdateComplete machineFsmState = "triggerMachineUpdateComplete"
)

func (md *machineDeployment) updateMachineWChecks(ctx context.Context, oldMachine, newMachine *fly.Machine, sl statuslogger.StatusLine, io *iostreams.IOStreams) error {
ctx, span := tracing.GetTracer().Start(ctx, "update_machine_w_checks")
defer span.End()

machineStateFSM := stateless.NewStateMachine(machineUpdateNotStarted)
machineStateFSM.Configure(machineUpdateNotStarted).Permit(triggerMachineEnsureCreated, machineCreated)
machineStateFSM.Configure(machineCreated).OnEntry(func(ctx context.Context, args ...any) error {

return nil
})

var machine *fly.Machine
var lease *fly.MachineLease

Expand Down

0 comments on commit 60a7198

Please sign in to comment.