Skip to content

Commit ef58457

Browse files
bemesa21gwuah
andauthored
Send release metadata while updating the release (#3798)
* Send release metadata while updating the release --------- Co-authored-by: gwuah <[email protected]>
1 parent 0c5cf93 commit ef58457

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ require (
7272
github.com/spf13/pflag v1.0.5
7373
github.com/spf13/viper v1.19.0
7474
github.com/stretchr/testify v1.9.0
75-
github.com/superfly/fly-go v0.1.19
75+
github.com/superfly/fly-go v0.1.21
7676
github.com/superfly/graphql v0.2.4
7777
github.com/superfly/lfsc-go v0.1.1
7878
github.com/superfly/macaroon v0.2.14-0.20240702184853-b8ac52a1fc77
@@ -85,7 +85,7 @@ require (
8585
go.opentelemetry.io/otel/sdk v1.28.0
8686
go.opentelemetry.io/otel/trace v1.28.0
8787
golang.org/x/crypto v0.25.0
88-
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
88+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
8989
golang.org/x/mod v0.19.0
9090
golang.org/x/net v0.27.0
9191
golang.org/x/sync v0.7.0
@@ -258,7 +258,7 @@ require (
258258
go.uber.org/multierr v1.11.0 // indirect
259259
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
260260
golang.org/x/oauth2 v0.21.0 // indirect
261-
golang.org/x/tools v0.22.0 // indirect
261+
golang.org/x/tools v0.23.0 // indirect
262262
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
263263
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
264264
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
@@ -272,5 +272,5 @@ require (
272272
replace (
273273
github.com/loadsmart/calver-go => github.com/ndarilek/calver-go v0.0.0-20230710153822-893bbd83a936
274274
github.com/nats-io/nats.go => github.com/btoews/nats.go v0.0.0-20240401180931-476bea7f4158
275-
github.com/superfly/fly-go => github.com/superfly/fly-go v0.1.19-0.20240724162007-8bcc00062656
275+
github.com/superfly/fly-go => github.com/superfly/fly-go v0.1.21
276276
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
629629
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
630630
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
631631
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
632-
github.com/superfly/fly-go v0.1.19-0.20240724162007-8bcc00062656 h1:eCn5Ip114F1EdDzEwhdYA9j6ionM2edgWBEupWH7h4U=
633-
github.com/superfly/fly-go v0.1.19-0.20240724162007-8bcc00062656/go.mod h1:JQke/BwoZqrWurqYkypSlcSo7bIUgCI3eVnqMC6AUj0=
632+
github.com/superfly/fly-go v0.1.21 h1:+UEmy+4jZ0f/lUWxF1u/y54qbodOCqcrvuL92ANMePo=
633+
github.com/superfly/fly-go v0.1.21/go.mod h1:JQke/BwoZqrWurqYkypSlcSo7bIUgCI3eVnqMC6AUj0=
634634
github.com/superfly/graphql v0.2.4 h1:Av8hSk4x8WvKJ6MTnEwrLknSVSGPc7DWpgT3z/kt3PU=
635635
github.com/superfly/graphql v0.2.4/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
636636
github.com/superfly/lfsc-go v0.1.1 h1:dGjLgt81D09cG+aR9lJZIdmonjZSR5zYCi7s54+ZU2Q=
@@ -717,8 +717,8 @@ golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU
717717
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
718718
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
719719
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
720-
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
721-
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
720+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
721+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
722722
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
723723
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
724724
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
@@ -833,8 +833,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
833833
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
834834
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
835835
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
836-
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
837-
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
836+
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
837+
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
838838
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
839839
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
840840
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

internal/command/deploy/machines.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,17 +553,21 @@ func (md *machineDeployment) createReleaseInBackend(ctx context.Context) error {
553553
return nil
554554
}
555555

556-
func (md *machineDeployment) updateReleaseInBackend(ctx context.Context, status string) error {
556+
func (md *machineDeployment) updateReleaseInBackend(ctx context.Context, status string, metadata *fly.ReleaseMetadata) error {
557557
ctx, span := tracing.GetTracer().Start(ctx, "update_release_in_backend", trace.WithAttributes(
558558
attribute.String("release_id", md.releaseId),
559559
attribute.String("status", status),
560560
))
561561
defer span.End()
562562

563-
_, err := md.apiClient.UpdateRelease(ctx, fly.UpdateReleaseInput{
563+
input := fly.UpdateReleaseInput{
564564
ReleaseId: md.releaseId,
565565
Status: status,
566-
})
566+
Metadata: metadata,
567+
}
568+
569+
_, err := md.apiClient.UpdateRelease(ctx, input)
570+
567571
if err != nil {
568572
tracing.RecordError(span, err, "failed to update machine release")
569573
return err

internal/command/deploy/machines_deploymachinesapp.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
fly "github.com/superfly/fly-go"
2020
"github.com/superfly/flyctl/helpers"
2121
"github.com/superfly/flyctl/internal/appconfig"
22+
"github.com/superfly/flyctl/internal/buildinfo"
2223
machcmd "github.com/superfly/flyctl/internal/command/machine"
2324
"github.com/superfly/flyctl/internal/flapsutil"
2425
"github.com/superfly/flyctl/internal/flyerr"
@@ -48,7 +49,7 @@ func (md *machineDeployment) DeployMachinesApp(ctx context.Context) error {
4849

4950
onInterruptContext := context.WithoutCancel(ctx)
5051

51-
if err := md.updateReleaseInBackend(ctx, "running"); err != nil {
52+
if err := md.updateReleaseInBackend(ctx, "running", nil); err != nil {
5253
tracing.RecordError(span, err, "failed to update release")
5354
return fmt.Errorf("failed to set release status to 'running': %w", err)
5455
}
@@ -61,6 +62,12 @@ func (md *machineDeployment) DeployMachinesApp(ctx context.Context) error {
6162
}
6263

6364
var status string
65+
metadata := &fly.ReleaseMetadata{
66+
PostDeploymentInfo: fly.PostDeploymentInfo{
67+
FlyctlVersion: buildinfo.Info().Version.String(),
68+
},
69+
}
70+
6471
switch {
6572
case err == nil:
6673
status = "complete"
@@ -71,10 +78,11 @@ func (md *machineDeployment) DeployMachinesApp(ctx context.Context) error {
7178
ctx, cancel = context.WithTimeout(onInterruptContext, time.Second)
7279
defer cancel()
7380
default:
81+
metadata.PostDeploymentInfo.Error = err.Error()
7482
status = "failed"
7583
}
7684

77-
if updateErr := md.updateReleaseInBackend(ctx, status); updateErr != nil {
85+
if updateErr := md.updateReleaseInBackend(ctx, status, metadata); updateErr != nil {
7886
if err == nil {
7987
err = fmt.Errorf("failed to set final release status: %w", updateErr)
8088
} else {

0 commit comments

Comments
 (0)