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

move some of plan.go into a proper FSM #3875

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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ require (
github.com/prometheus/blackbox_exporter v0.25.0
github.com/prometheus/client_golang v1.19.1
github.com/prometheus/client_model v0.6.1
github.com/qmuntal/stateless v1.7.0
github.com/r3labs/diff v1.1.0
github.com/samber/lo v1.47.0
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/qmuntal/stateless v1.7.0 h1:Gzw/TUfmSQxoof7TSQ4kCa4DYwnDD5szeAI29BAR/jY=
github.com/qmuntal/stateless v1.7.0/go.mod h1:n1HjRBM/cq4uCr3rfUjaMkgeGcd+ykAZwkjLje6jGBM=
github.com/r3labs/diff v1.1.0 h1:V53xhrbTHrWFWq3gI4b94AjgEJOerO1+1l0xyHOBi8M=
github.com/r3labs/diff v1.1.0/go.mod h1:7WjXasNzi0vJetRcB/RqNl5dlIsmXcTTLmF5IoH6Xig=
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8 h1:xe+mmCnDN82KhC010l3NfYlA8ZbOuzbXAzSYBa6wbMc=
Expand Down
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 @@
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
18 changes: 11 additions & 7 deletions internal/command/deploy/machines_deploymachinesapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func (md *machineDeployment) updateExistingMachinesWRecovery(ctx context.Context
}

newAppState := *oldAppState
newAppState.Machines = lo.Map(updateEntries, func(e *machineUpdateEntry, _ int) *fly.Machine {
newAppState.Machines = machineSliceToMap(lo.Map(updateEntries, func(e *machineUpdateEntry, _ int) *fly.Machine {
newMach := e.leasableMachine.Machine()
if !e.launchInput.SkipLaunch {
newMach.State = "started"
Expand All @@ -590,7 +590,7 @@ func (md *machineDeployment) updateExistingMachinesWRecovery(ctx context.Context
}
newMach.Config = e.launchInput.Config
return newMach
})
}))

switch md.strategy {
case "bluegreen":
Expand All @@ -611,15 +611,19 @@ func (md *machineDeployment) updateExistingMachinesWRecovery(ctx context.Context
skipLeaseAcquisition: false,
})
case "canary":
var canaryMachID string

for machID, _ := range oldAppState.Machines {
canaryMachID = machID
break
}

// create a new app state with just a single machine being updated, then the rest of the machines
canaryAppState := *oldAppState
canaryAppState.Machines = []*fly.Machine{oldAppState.Machines[0]}
canaryAppState.Machines = machineSliceToMap([]*fly.Machine{oldAppState.Machines[canaryMachID]})

newCanaryAppState := newAppState
canaryMach, _ := lo.Find(newAppState.Machines, func(m *fly.Machine) bool {
return m.ID == oldAppState.Machines[0].ID
})
newCanaryAppState.Machines = []*fly.Machine{canaryMach}
newCanaryAppState.Machines = machineSliceToMap([]*fly.Machine{newAppState.Machines[canaryMachID]})

if err := md.updateMachinesWRecovery(ctx, &canaryAppState, &newCanaryAppState, nil, updateMachineSettings{
pushForward: true,
Expand Down
Loading
Loading