Skip to content

Commit

Permalink
fix: always start a provisioner task, even if there are no changes. (#…
Browse files Browse the repository at this point in the history
…3158)

This allows us to return any previously created outputs in case the
provisioner needs to recreate the resource graph
  • Loading branch information
jvmakine authored Oct 18, 2024
1 parent b41046e commit a398d0a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 36 deletions.
18 changes: 7 additions & 11 deletions backend/protos/xyz/block/ftl/v1beta1/provisioner/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ message ProvisionResponse {
enum ProvisionResponseStatus {
UNKNOWN = 0;
SUBMITTED = 1;
NO_CHANGES = 2;
}

string provisioning_token = 1;
Expand Down
4 changes: 0 additions & 4 deletions backend/provisioner/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func (t *Task) Start(ctx context.Context) error {
t.state = TaskStateFailed
return fmt.Errorf("error provisioning resources: %w", err)
}
if resp.Msg.Status == provisioner.ProvisionResponse_NO_CHANGES {
t.state = TaskStateDone
t.output = t.desired.Resources()
}
t.runningToken = resp.Msg.ProvisioningToken
return nil
}
Expand Down
6 changes: 0 additions & 6 deletions backend/provisioner/inmem_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ func (d *InMemProvisioner) Provision(ctx context.Context, req *connect.Request[p
}
}

if len(task.steps) == 0 {
return connect.NewResponse(&provisioner.ProvisionResponse{
Status: provisioner.ProvisionResponse_NO_CHANGES,
}), nil
}

token := uuid.New().String()
logger.Debugf("started a task with token %s", token)
d.running.Store(token, task)
Expand Down
8 changes: 5 additions & 3 deletions backend/provisioner/noop_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ func (d *NoopProvisioner) Plan(context.Context, *connect.Request[provisioner.Pla

func (d *NoopProvisioner) Provision(context.Context, *connect.Request[provisioner.ProvisionRequest]) (*connect.Response[provisioner.ProvisionResponse], error) {
return connect.NewResponse(&provisioner.ProvisionResponse{
Status: provisioner.ProvisionResponse_NO_CHANGES,
ProvisioningToken: "",
Status: provisioner.ProvisionResponse_SUBMITTED,
ProvisioningToken: "token",
}), nil
}

func (d *NoopProvisioner) Status(context.Context, *connect.Request[provisioner.StatusRequest]) (*connect.Response[provisioner.StatusResponse], error) {
panic("should not be called")
return connect.NewResponse(&provisioner.StatusResponse{
Status: &provisioner.StatusResponse_Success{},
}), nil
}
4 changes: 0 additions & 4 deletions cmd/devel-provisioner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ func main() {
if err != nil {
panic(err)
}
if resp.Msg.Status == provisioner.ProvisionResponse_NO_CHANGES {
println("no changes")
return
}

retry := backoff.Backoff{
Min: 100 * time.Millisecond,
Expand Down
4 changes: 3 additions & 1 deletion cmd/ftl-provisioner-cloudformation/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (c *CloudformationProvisioner) Provision(ctx context.Context, req *connect.
}
if !updated {
return connect.NewResponse(&provisioner.ProvisionResponse{
Status: provisioner.ProvisionResponse_NO_CHANGES,
// even if there are no changes, return the stack id so that any resource outputs can be populated
Status: provisioner.ProvisionResponse_SUBMITTED,
ProvisioningToken: *res.StackId,
}), nil
}
_, err = c.client.ExecuteChangeSet(ctx, &cloudformation.ExecuteChangeSetInput{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a398d0a

Please sign in to comment.