Add podman run --gpus flag for compatibility

- Add log message for --gpus flag
- Add test

Signed-off-by: Sebastian Jug <seb@stianj.ug>
This commit is contained in:
Sebastian Jug
2021-05-21 10:39:19 -04:00
parent e48aa8c82f
commit 738a8fe637
2 changed files with 14 additions and 0 deletions

View File

@ -77,6 +77,11 @@ func runFlags(cmd *cobra.Command) {
flags.StringVar(&runOpts.DetachKeys, detachKeysFlagName, containerConfig.DetachKeys(), "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-cf`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`") flags.StringVar(&runOpts.DetachKeys, detachKeysFlagName, containerConfig.DetachKeys(), "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-cf`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
_ = cmd.RegisterFlagCompletionFunc(detachKeysFlagName, common.AutocompleteDetachKeys) _ = cmd.RegisterFlagCompletionFunc(detachKeysFlagName, common.AutocompleteDetachKeys)
gpuFlagName := "gpus"
flags.String(gpuFlagName, "", "This is a Docker specific option and is a NOOP")
_ = cmd.RegisterFlagCompletionFunc(gpuFlagName, completion.AutocompleteNone)
_ = flags.MarkHidden("gpus")
if registry.IsRemote() { if registry.IsRemote() {
_ = flags.MarkHidden("preserve-fds") _ = flags.MarkHidden("preserve-fds")
_ = flags.MarkHidden("conmon-pidfile") _ = flags.MarkHidden("conmon-pidfile")
@ -204,5 +209,8 @@ func run(cmd *cobra.Command, args []string) error {
logrus.Errorf("%s", errorhandling.JoinErrors(rmErrors)) logrus.Errorf("%s", errorhandling.JoinErrors(rmErrors))
} }
} }
if cmd.Flag("gpus").Changed {
logrus.Info("--gpus is a Docker specific option and is a NOOP")
}
return nil return nil
} }

View File

@ -113,4 +113,10 @@ var _ = Describe("Podman run device", func() {
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
Expect(session.OutputToString()).To(Equal("/dev/kmsg1")) Expect(session.OutputToString()).To(Equal("/dev/kmsg1"))
}) })
It("podman run --gpus noop", func() {
session := podmanTest.Podman([]string{"run", "--gpus", "all", ALPINE, "ls", "/"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
}) })