Commit graph

145 commits

Author SHA1 Message Date
cdoern c721acf082 podman machine starting test
add a test to make sure machines are not running while still starting
in order to do this, I added a parameter to `run()` to delineate whether
or not the command should block or not. The non blocking run allows for tests
to get and use the `machineSession` pointer and check the exit code to see if it has finished.

also fix a bug (created by #13996) that before started, the machines would
always say "LastUp" and "Created" Less than one second ago

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-04-27 20:12:43 -04:00
OpenShift Merge Robot e7c30d855f
Merge pull request #13996 from cdoern/machine
machine starting status
2022-04-26 09:08:31 -04:00
OpenShift Merge Robot ace6672bf1
Merge pull request #13908 from n1hility/win-mounts
Implement Windows volume/mount support
2022-04-26 08:38:33 -04:00
Jason T. Greene b0d36f6351 Implements Windows volume/mount support
Based on WSL2 9p support: remaps windows paths to /mnt/<drive> locations for
both podman and Docker API clients.

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-25 13:52:27 -05:00
cdoern d441a711e5 machine starting status
podman machine was using the file modification time to get the running status
add three new config entries Starting (bool) Created (time) LastUp (time) to actually
keep track of when these events happened. This means we can use the config file
to actually store this data and not mess up the created/last-up time.

This fixes the issues where the machine would report running 15 seconds before it was up.
Also fixes the issue of modifying the file manually and saying the machine is "up"

[NO NEW TESTS NEEDED]

resolves #13711

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-04-25 14:14:45 -04:00
Brent Baude 833456e079 Add podman machine test suite
This PR introduces a test suite for podman machine.  It can currently be
run on developers' local machines and is not part of the official CI
testing; however, the expectation is that any work on machine should
come with an accompanying test.

At present, the test must be run on Linux.  It is untested on Darwin.
There is no Makefile target for the test.  It can be run like `ginkgo -v
pkg/machine/test/.`.  It should be run as a unprivileged user.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-25 13:05:35 -05:00
OpenShift Merge Robot 09ef4f2e22
Merge pull request #13978 from Luap99/unparam
enable unparam linter
2022-04-25 13:43:57 -04:00
Ashley Cui 1260bf631f Revert "Switch all rootful to rootfull"
This reverts commit cc3790f332.

We can't change rootful to rootfull because `rootful` is written into the machine config. Changing this will break json unmarshalling, which will break existing machines.

[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-04-25 09:14:04 -04:00
Paul Holzinger c7b16645af
enable unparam linter
The unparam linter is useful to detect unused function parameters and
return values.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-25 13:23:20 +02:00
Paul Holzinger 5b4af0584d
replace golint with revive linter
golint, scopelint and interfacer are deprecated. golint is replaced by
revive. This linter is better because it will also check for our error
style: `error strings should not be capitalized or end with punctuation or a newline`

scopelint is replaced by exportloopref (already endabled)
interfacer has no replacement but I do not think this linter is
important.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 15:12:33 +02:00
OpenShift Merge Robot 22500d797a
Merge pull request #13972 from Luap99/staticcheck
enable staticcheck linter
2022-04-22 08:26:31 -04:00
Paul Holzinger 2a8e435671
enable staticcheck linter
Fix many problems reported by the staticcheck linter, including many
real bugs!

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:29 +02:00
Daniel J Walsh cc3790f332
Switch all rootful to rootfull
We are inconsistent on the name, we should stick with rootfull.

[NO NEW TESTS NEEDED] Existing tests should handle this and no tests for
machines exists yet.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-21 17:05:16 -04:00
Jason T. Greene a4798ab4ef Respect "Rootful" when starting WSL API Forwarding
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-15 00:14:49 -05:00
Brent Baude 8710197e85 Introduce machine inspect
Allow users to inspect their podman virtual machines. This will be
helpful for debug and development alike, because more details about the
machine can be collected.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-12 15:51:39 -05:00
Aditya R 8fb9dbdb4e
machine,rm: Ignore ENOENT while cleaning machine
Certain paths like `../containers/podman/machine/my-test/podman.sock`
do not exist when machine is not started, so removing a machine before
starting it will result in ENOENT which we should ignore cause these
paths do not exists

Closes: https://github.com/containers/podman/issues/13834

[NO TESTS NEEDED]
[NO NEW TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2022-04-12 16:44:29 +05:30
OpenShift Merge Robot f838333b7e
Merge pull request #13798 from n1hility/fix-docker-sock
Fix mac docker socket handling
2022-04-07 07:17:35 -04:00
Jason T. Greene 356d534344 Fix docker socket handling
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-06 23:06:57 -05:00
Jason T. Greene 90ac1ba2a6 Prevent set command from updating a running instance
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-06 20:39:59 -05:00
Brent Baude 9c72ea3434 machine refactor 3: add symlinks for sockets
to avoid errors on macos, we use symlinks to long socket names.

Fixes: #12751
Fixes: #13609

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-05 13:14:28 -05:00
OpenShift Merge Robot 48c4015ac1
Merge pull request #13655 from n1hility/dual-pipes
Prefer registering both machine and global pipe on Win
2022-04-04 08:06:02 -04:00
Brent Baude a06df4fc1a Machine refactor part 2
This PR further implements a more structured approach to handling the
files needed by machine.  More files are now made as MachineFile which
can then have a symlink (using a shorter path) to them.  Also added Set
and Get methods for many of the files.

The next part of the refactor will implement the use of symlinks on
MacOS.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-30 09:22:40 -05:00
Jason T. Greene b60854e8bc Prefer registering both machine and global pipe
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-03-29 17:31:50 -04:00
Brent Baude 6e0e1cbddd Migrate machine configs
If podman detects a Machinev1 config, it will automatically migrate it
to the new format.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]
2022-03-28 14:54:19 -05:00
Brent Baude 2ac897aa0d Machine refactor - part 1
the way machine was written was very adjunct and as such is in dire need
of refactoring to better structures and structure methods where
appropriate.  the weekest part is specifically around all the files that
machine requires and how some are just dynamically built on the fly.

this pr defines a new machinefile type which allows us to work with the
file and also takes into account the use of symlinks which are going to
be needed on macos due to its relatively short file length restriction.

also, added unit tests for new methods as well as anywhere else I saw a
need.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-28 09:12:08 -05:00
Daniel J Walsh d106b294b4
Switch all calls to filepath.Walk to filepath.WalkDir
WalkDir should be faster the Walk, since we often do
not need to stat files.

[NO NEW TESTS NEEDED] Existing tests should find errors.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-27 07:18:25 -04:00
Daniel J Walsh 7680211ede
Remove error stutter
When podman gets an error it prints out "Error: " before
printing the error string.  If the error message starts with
error, we end up with

Error: error ...

This PR Removes all of these stutters.

logrus.Error() also prints out that this is an error, so no need for the
error stutter.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-25 21:47:04 -04:00
OpenShift Merge Robot c61b06c46c
Merge pull request #13620 from Luap99/qemu-path
podman machine start: lookup qemu path again if not found
2022-03-24 18:11:45 +01:00
Paul Holzinger da58911306
fix podman machine start log level detection
Use logrus.IsLevelEnabled because this will cover all levels below it as
well. Currently this condition would fail for the trace log level.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-23 19:10:58 +01:00
Paul Holzinger 59dc70bb42
podman machine start: lookup qemu path again if not found
We store the full path to qemu in the machine config. When the path
changes on the host the machine can longer be started. To fix it we get
the path again when we fail to start the machine due the missing binary.

We want to store and use the full path first because otherwise existing
machines can break when the qemu version changed.

[NO NEW TESTS NEEDED] We still have no machine tests.

Fixes #13394

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-23 19:10:51 +01:00
Burt Holzman cdda1924a0 Explicitly use IPv4 to check if podman-machine VM is listening
When starting a VM that has been configured with volume mounts, the
podman client attempts to connect via TCP to localhost, which runs
gvproxy to proxy an ephemeral port to the VM's ssh port.  Previously,
gvproxy was listening on all interfaces and IP addresses, but this
behavior has changed to listening only on the IPv4 loopback address.

Without this change, if a newer build of gvproxy is used, a podman
machine configured with volume mounts will hang forever after "podman
machine start" with "Waiting for VM ...".

[NO NEW TESTS NEEDED]

Signed-off-by: Burt Holzman <burt@fnal.gov>
2022-03-23 12:48:17 -05:00
Valentin Rothberg 06dd9136a2 fix a number of errcheck issues
Numerous issues remain, especially in tests/e2e.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:15:28 +01:00
Valentin Rothberg 6c030cd573 fix a number of godot issues
Still an unknown number remains but I am running out of patience.
Adding dots is not the best use of my time.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg 0f12b6fe55 linter: enable nilerr
A number of cases looked suspicious, so I marked them with `FIXME`s to
leave some breadcrumbs.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg 026bd9b205 bump golangci-lint to v1.45.0
* supports Go 1.18
* disable a number of new linters
* fix minor stylecheck issues

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-21 10:42:53 +01:00
OpenShift Merge Robot b0fefb3e8f
Merge pull request #13523 from n1hility/tolerate-old-machine
Tolerate old machine images, but warn they should be recreated
2022-03-18 12:38:40 +01:00
Valentin Rothberg ea08765f40 go fmt: use go 1.18 conditional-build syntax
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-18 09:11:53 +01:00
Jason T. Greene 3c968c3d22 Handle incompatible machines
Start in a reduced mode for recovery, warn, and provide instructions to recreate them

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-03-18 01:16:34 -05:00
Paul Holzinger 30bf065c3f
Use github.com/vbauerster/mpb/v7 in pkg/machine
We already use v7 in c/image so podman should use the same version to
prevent duplication.

This saves 170 KB binary size.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-09 20:02:10 +01:00
OpenShift Merge Robot 41e2c9943e
Merge pull request #13465 from n1hility/improve-install-msg
Improve agent install message to add restart instructions
2022-03-09 09:25:57 -05:00
Jason T. Greene a7c4691bff Improve agent install message to add restart instructions
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-03-08 21:54:48 -06:00
Brent Baude 5b51b42cc8 machine rm -f stops and removes machine
If you want to remove a running machine, you can now pass the --force/-f
to podman machine rm and the machine will be stopped and removed without
confirmations.

Fixes: #13448

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-08 15:47:32 -06:00
Brent Baude cdb6deb148 MacOS improvements
* Enable support of virtfs in Podman and darwin.  At the time of this writing, it requires a special patch not yet included in upstream qemu.
* Prefer to use a specially built qemu to support virtfs.  The qemu is installed under libexec/podman.

[NO NEW TESTS NEEDED]
Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-03-07 14:05:06 -06:00
Thibault Gagnaux 01514f33ba
Fixes: #13301 ("machine rm removes the mounted socket file on macos")
[NO NEW TESTS NEEDED]
Signed-off-by: Thibault Gagnaux <tgagnaux@gmail.com>
2022-03-06 16:24:56 +01:00
Jason T. Greene 50fbe52f49 Update to podman4 copr stream
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-02-16 03:49:17 -06:00
Jason T. Greene c74f8f04fd Introduce podman machine init --root=t|f and podman machine set --root=t|f
Switch default to rootless for mac and windows

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-02-16 03:49:17 -06:00
Jason T. Greene 8f5ba05ec4 Initial implementation of mac forwarding using a privileged docker sock claim helper
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-02-16 03:49:17 -06:00
OpenShift Merge Robot 5977fd5095
Merge pull request #13209 from esendjer/main
ignition: propagate proxy settings from a host into a vm
2022-02-14 15:50:38 -05:00
esendjer a8928a3caa ignition: propagate proxy settings from a host into a vm
Set proxy settings (such as `HTTP_PROXY`, and others)
for the whole guest OS with setting up `DefaultEnvironment`
with a `systemd` configuration file `default-env.conf`,
a `profile.d` scenario file - `default-env.sh` and
a `environment.d` configuration file `default-env.conf`

The **actual** environment variables are read by podman
at a start, then they are encrypted with base64 into
a single string and after are provided into a VM through
QEMU Firmware Configuration (fw_cfg) Device

Inside a VM a systemd service `envset-fwcfg.service`
reads the providead encrypted string from fw_cfg, decrypts
and then adds to the files
 - `/etc/systemd/system.conf.d/default-env.conf`
 - `/etc/profile.d/default-env.sh`
 - `/etc/environment.d/default-env.conf`
At the end this service execute  `systemctl daemon-reload`
to propagate new variables for systemd manager

[NO NEW TESTS NEEDED]

Closes #13168

Signed-off-by: esendjer <esendjer@gmail.com>
2022-02-12 21:24:15 +05:00
Brent Baude 73f35ff2ae Temporarily pull machine images from side repo
Until podman4 is in the fcos trees, we need to pull the machine images
from a side repository.  There is a hard coded bit that forces the
side repo download right now.  Simple comment or removal of the bit will
revert to normal download behavior.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-02-11 17:04:18 -06:00