Add --container and --no-container to fly machine exec - #5077
Open
dangra wants to merge 1 commit into
Open
Conversation
`fly machine exec` had no way to choose where a command runs: it never set a container, so it landed in whatever the platform picked first. --container names one. --no-container asks for the machine's own namespace instead, matching the flag `fly ssh console` uses for the same choice. Passing both is an error.
This was referenced Aug 13, 2026
There was a problem hiding this comment.
Pull request overview
Adds explicit targeting for where fly machine exec runs a command by introducing --container (run inside a named container) and --no-container (run in the machine’s own namespace), with a mutual-exclusion check.
Changes:
- Add
--containerand--no-containerflags tofly machine exec. - Validate the flags are mutually exclusive.
- Populate the exec request with
Container/Machineselection fields.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
93
to
+97
| in := &fly.MachineExecRequest{ | ||
| Cmd: command, | ||
| Timeout: timeout, | ||
| Cmd: command, | ||
| Container: container, | ||
| Machine: noContainer, | ||
| Timeout: timeout, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fly machine exechas never had a way to choose where a command runs. It sets no container on the request, so on a machine with containers it lands in whichever one the platform picks first, and there is no way to reach the machine itself.This adds both halves of that choice:
--containernames one.--no-containerasks for the machine's own namespace instead — the same flag, meaning the same thing, as onfly ssh console(#5075). Passing both is an error.Behaviour
--no-containeris ignored and the command runs in a container as it does today. That is the one silent case in this change: the request field is simply unknown to the older API, so it cannot report the mismatch. The platform-side support needs to have rolled out before this is relied on.Depends on superfly/fly-go#276 for the
machinerequest field; CI here fails onunknown field Machine in struct literal of type fly.MachineExecRequestuntil that lands and the go.mod bump follows.