fly
: add background
option to execute
command
#8856
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed by this PR
This patch adds a new
-b/--background
option tofly execute
. This option tellsfly
to create the build, and exit just before watching the logs. It also means that outputs can't be retrieved. Instead, the build ID is printed, and logs can then be followed withfly watch
.Rationale
I self-host Gitea and Drone. The application I'm making also needs some worker pool to spawn short-lived processes, and I thought it would be cool to only have one generic job framework to do both. But Drone is not flexible enough for that; besides it has been bought and shut down. I don't want to use frameworks that would lock me in K8S.
So, let's give Concourse a try! CICD works fine, however my jobs are triggered out of nowhere so I can't rely on resource checks to launch them. Although... maybe a custom resource type listing pending jobs with
version: every
could have somewhat worked, but can't be parallelized... Anyway, I feel spawning one-off tasks fits more to the idea.I've seen on some pages that ATC's REST API is private, and on some other pages it's somewhat private only because it hasn't been documented yet. Well, my app will communicate through the API for sure, regardless of its privacy! I can't rely on spawning a process and waiting for it, my app can be restarted anytime, and jobs should not depend of that. So I prefer to independently spawn a job, and retrieve its logs.
I thought this workflow could be useful to CLI users too. Build ID is printed so that spawner process can use it (works with Bash and PowerShell).
Note that I don't need to fetch outputs back (yet), but CLI users could benefit from the complete split workflow:
fly execute --background
+fly watch
+ to-be-donefly outputs
.Notes to reviewer
I don't master
flyIn
. It would have been better to test afterwards thatfly watch <buildID>
would have yield the same outputs as the preceding test, but then test times out. Maybe it's expected thatwatch
keeps running if it's spawned while the build is running too, but I vaguely recall that it exits as soon as the build is completed.Besides I'm new to Go, so I tried to fit in the code style, but have no idea how idiomatic it is.
Alternative name could have been
-d/--daemon
(likedocker run
does), but it implies the process is long-lasting, while it shouldn't.Release Note
fly execute
gets new-b/--background
option to create builds without watching them.