-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Cleanup messages on podman load #2674
Conversation
@edsantiago PTAL |
cmd/podman/load.go
Outdated
@@ -81,7 +82,7 @@ func loadCmd(c *cliconfig.LoadValues) error { | |||
defer os.Remove(outFile.Name()) | |||
defer outFile.Close() | |||
|
|||
inFile, err := os.OpenFile(input, 0, 0666) | |||
inFile, err := os.OpenFile("/dev/stdin", 0, 0666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be c.Input instead of the unconditional "/dev/stdin"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is the case where the user did not specify a --input file, it will pull the image from stdin, create a temporary file and then send the temporary file to containers/storage.
cmd/podman/load.go
Outdated
|
||
if input == "" { | ||
if terminal.IsTerminal(int(os.Stdin.Fd())) { | ||
return errors.Errorf("can not use terminal, redirect the archive or using the --input flag required") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like @edsantiago to take a look at this line, the bit after the 'or' needs help. I'd suggest "or use the --input option as required"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions:
Cannot read from terminal. Use command-line redirection or the --input flag.
Will not read from terminal. Use the --input flag, or redirect from a file/pipe.
No archive file specified; use --input to specify one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with Ed's suggestion except 'flag' s/b 'optoin'. If you pull up the man page, you'll find --input listed under "options" not "flags"
commands.md
Outdated
@@ -34,7 +34,7 @@ | |||
| [podman-info(1)](/docs/podman-info.1.md) | Display system information |[![...](/docs/play.png)](https://asciinema.org/a/yKbi5fQ89y5TJ8e1RfJd4ivTD)| | |||
| [podman-inspect(1)](/docs/podman-inspect.1.md) | Display the configuration of a container or image |[![...](/docs/play.png)](https://asciinema.org/a/133418)| | |||
| [podman-kill(1)](/docs/podman-kill.1.md) | Kill the main process in one or more running containers |[![...](/docs/play.png)](https://asciinema.org/a/3jNos0A5yzO4hChu7ddKkUPw7)| | |||
| [podman-load(1)](/docs/podman-load.1.md) | Load an image from docker archive or oci |[![...](/docs/play.png)](https://asciinema.org/a/kp8kOaexEhEa20P1KLZ3L5X4g)| | |||
| [podman-load(1)](/docs/podman-load.1.md) | Load an image from container image archive |[![...](/docs/play.png)](https://asciinema.org/a/kp8kOaexEhEa20P1KLZ3L5X4g)| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/from container/from a container/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
docs/podman-load.1.md
Outdated
@@ -1,22 +1,24 @@ | |||
% podman-load(1) | |||
|
|||
## NAME | |||
podman\-load - Load an image from docker archive | |||
podman\-load - Load an image from container image archive into container storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/from container/from a container/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
docs/podman-load.1.md
Outdated
|
||
## DESCRIPTION | ||
**podman load** copies an image from either **docker-archive** or **oci-archive** stored | ||
on the local machine. **podman load** reads from stdin by default or a file if the **input** flag is set. | ||
**podman load** loads an image from either an **oci-archive** or **docker-archive** stored on the local machine into container storage. **podman load** reads from stdin by default or a file if the **input** flag is set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/flag is set/option is set/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
docs/podman-save.1.md
Outdated
@@ -1,14 +1,13 @@ | |||
% podman-save(1) | |||
|
|||
## NAME | |||
podman\-save - Save an image to docker-archive or oci-archive | |||
podman\-save - Save an image to container archive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/to container/to a container/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
41f4bd9
to
c0459d8
Compare
☔ The latest upstream changes (presumably #2643) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions, and one showstopper:
$ podman load <sdfsdfsdf pr/2674 (1)
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
github.com/containers/libpod/libpod/image.(*Runtime).pullGoalFromImageReference(0xc0008a5c50, 0x1894d00, 0xc0000d0038, 0x18a1a60, 0xc00026cda0, 0xc0006f9b0c, 0x4, 0xc0001058c0, 0x0, 0x0, ...)
/home/esm/go/src/github.com/containers/libpod/libpod/image/pull.go:188 +0xcf5
github.com/containers/libpod/libpod/image.(*Runtime).pullImageFromReference(0xc0008a5c50, 0x1894d00, 0xc0000d0038, 0x18a1a60, 0xc00026cda0, 0x1881a20, 0xc0000d4010, 0x0, 0x0, 0x0, ...)
/home/esm/go/src/github.com/containers/libpod/libpod/image/pull.go:229 +0x1b4
github.com/containers/libpod/libpod/image.(*Runtime).LoadFromArchiveReference(0xc0008a5c50, 0x1894d00, 0xc0000d0038, 0x18a1a60, 0xc00026cda0, 0x0, 0x0, 0x1881a20, 0xc0000d4010, 0x0, ...)
/home/esm/go/src/github.com/containers/libpod/libpod/image/image.go:182 +0x108
github.com/containers/libpod/libpod.(*Runtime).LoadImage(0xc0006f2620, 0x1894d00, 0xc0000d0038, 0x0, 0x0, 0x0, 0x0, 0x1881a20, 0xc0000d4010, 0x0, ...)
/home/esm/go/src/github.com/containers/libpod/libpod/runtime_img.go:264 +0x323
github.com/containers/libpod/pkg/adapter.(*LocalRuntime).LoadImage(0xc0001ba1a0, 0x1894d00, 0xc0000d0038, 0x0, 0x0, 0x28318a0, 0x58b327, 0xc0007badc0, 0xc0006f60c0, 0x17)
/home/esm/go/src/github.com/containers/libpod/pkg/adapter/runtime.go:329 +0xc4
main.loadCmd(0x28318a0, 0x0, 0x0)
/home/esm/go/src/github.com/containers/libpod/cmd/podman/load.go:103 +0x165
main.glob..func32(0x2689d80, 0x28524a8, 0x0, 0x0, 0x0, 0x0)
/home/esm/go/src/github.com/containers/libpod/cmd/podman/load.go:28 +0x7f
github.com/containers/libpod/vendor/github.com/spf13/cobra.(*Command).execute(0x2689d80, 0xc0000da010, 0x0, 0x0, 0x2689d80, 0xc0000da010)
/home/esm/go/src/github.com/containers/libpod/vendor/github.com/spf13/cobra/command.go:762 +0x473
github.com/containers/libpod/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x268e4c0, 0xc, 0x2854040, 0xc000774000)
/home/esm/go/src/github.com/containers/libpod/vendor/github.com/spf13/cobra/command.go:852 +0x2fd
github.com/containers/libpod/vendor/github.com/spf13/cobra.(*Command).Execute(0x268e4c0, 0xc000056420, 0xc0000bc058)
/home/esm/go/src/github.com/containers/libpod/vendor/github.com/spf13/cobra/command.go:800 +0x2b
main.main()
/home/esm/go/src/github.com/containers/libpod/cmd/podman/main.go:231 +0x3c
I don't have time right now to diagnose and track down the cause, sorry. I suspect it will be much easier for you to track down than for me, anyway.
(FWIW the sdfsdf
archive loads fine using the -i
flag)
cmd/podman/load.go
Outdated
_loadCommand = &cobra.Command{ | ||
Use: "load [flags] [PATH]", | ||
Short: "Load an image from docker archive", | ||
Use: "load [flags] [*name*[:*tag*]]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other Use lines, could you make this [NAME[:TAG]]
(caps)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
cmd/podman/load.go
Outdated
) | ||
|
||
var ( | ||
loadCommand cliconfig.LoadValues | ||
|
||
loadDescription = "Loads the image from docker-archive stored on the local machine." | ||
loadDescription = "Loads an image from container image archive stored on the local machine into container storage." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wording makes my brain hurt a bit. What would you think of any of these?
Loads a pre-saved image from a local file into container storage.
Loads an image from a locally stored archive (tar file) into container storage.
Loads a local archive file, containing a saved image, into container storage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIxed
cmd/podman/load.go
Outdated
|
||
if input == "" { | ||
if terminal.IsTerminal(int(os.Stdin.Fd())) { | ||
return errors.Errorf("can not use terminal, redirect the archive or using the --input flag required") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions:
Cannot read from terminal. Use command-line redirection or the --input flag.
Will not read from terminal. Use the --input flag, or redirect from a file/pipe.
No archive file specified; use --input to specify one.
cmd/podman/load.go
Outdated
input = "/dev/stdin" | ||
c.Input = input | ||
|
||
if input == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the reason I did len(input) == 0
is because of that usage three lines up. For the sake of consistency, and minimizing maintenance programmer confusion (like, someone some day wondering "why is it this way in one place and the other way in the other?"), could you consistentize those two?
Actually, I think it might be even more readable as
if (whichever way you choose to check if string is empty) {
if runtime.Remote {
return errors.New()
}
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually do not know why the runtime.Remote check is here. We should be able to support this on a remote system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd/podman/load.go
Outdated
@@ -92,7 +93,7 @@ func loadCmd(c *cliconfig.LoadValues) error { | |||
return errors.Errorf("error copying file %v", err) | |||
} | |||
|
|||
input = outFile.Name() | |||
c.Input = outFile.Name() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I set input
is because of the parse.ValidateFileName()
below. Will ""
validate? I can't test right now because I'm seeing a major crash in this form of usage and am very low on time right now (will have more time this afternoon).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed input altogether, now I just if c.Input > 0, then validate, otherwise I generate it from a stdin.
docs/podman-load.1.md
Outdated
on the local machine. **podman load** reads from stdin by default or a file if the **input** flag is set. | ||
The **quiet** flag suppresses the output when set. | ||
**podman load** loads an image from either an **oci-archive** or **docker-archive** stored on the local machine into container storage. **podman load** reads from stdin by default or a file if the **input** option is set. | ||
You can also specify a name for the image if the archive does not contain a named reference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still find the name option confusing. It is always ignored AFAICT (probably because my saved archive includes a name). Would this make more sense?
If the archive does not include a name (FIXME: why would that be? Is that OCI vs Docker format?), you can specify a **name** and optional **tag**; these will be silently ignored if the archive already specifies them.
(And, in the spirit of not silently ignoring, would it be possible for the code to check for this condition, and say "I am completely ignoring the name:tag you gave me"?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this happens, and could not figure it out from the code. Who coded this up originally?
Update: so the catch is here: // checking if loading from pipe
if !fi.Mode().IsRegular() { This triggers in a pipe: Although I realize this can look like duplication, I humbly suggest that one reasonable fix is to un-delete lines 68-69, the ones in which I set both I think if you accept my suggestion about moving the |
5c324cf
to
155554c
Compare
@edsantiago Take a look again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passes everything I can try. LGTM aside from my request in the Use message; and I think @baude should confirm whether the -remote
check should stay or go because it might require code changes in the client.
cmd/podman/load.go
Outdated
loadDescription = "Loads an image from a locally stored archive (tar file) into container storage." | ||
|
||
_loadCommand = &cobra.Command{ | ||
Use: "load [flags] [*NAME*[:*TAG*]]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you get rid of the asterisks? No other usage message includes them; that's a convention in .md
files.
Well, I've run into a snag but it doesn't seem to be related to your code. First:
Again, podman 1.1.2 behaves the same way, I'm just wondering if that's the intention. The NAME:TAG argument still confuses me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cmd/podman/load.go
Outdated
|
||
fi, err := os.Stdin.Stat() | ||
inFile, err := os.OpenFile("/dev/stdin", 0, 0666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For portability, can you read from os.Stdin rather than opening /dev/stdin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually that simplifies the code. Thanks @jwhonce.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A 2-For!
If user does not specify file or redirect for stdin, then throw an error Signed-off-by: Daniel J Walsh <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, jwhonce, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
New: - podman exec - podman load (requires containers#2674) - CLI parsing (regression test for containers#2574) Improved: - help: test "podman NoSuchCommand", and subcommands - help: test "podman cmd" without required args - pod: start with --infra=false; this allows running rootless - log: also run 'logs' after container is run - log: test -f with two containers Also, use helpful descriptions for skip_if_rootless Tested on f29, root and rootless. As soon as podman-remote supports rm, I'll start testing that too. Signed-off-by: Ed Santiago <[email protected]>
If user does not specify file or redirect for stdin, then
throw an error
Signed-off-by: Daniel J Walsh [email protected]