Commit Graph

888 Commits

Author SHA1 Message Date
Brian Cain 2901dae948
Add option for docker executor to handle stderr from results
Instead of always joining stdout and stderr, only join the two if the
caller explicitly asks for it. Otherwise, only return stdout.
2019-11-22 12:04:09 -08:00
Brian Cain 4d70856b8a
Enhance docker build matching for determining built container ID
Prior to this commit, docker would look for a container ID based on
"Successfully built" string. This output does not exist if a user has
enabled the experimental feature buildkit. This commit updates the build
behavior to match against both kinds of outputs, and instead of using
`scan`, it uses MatchData and groups the container id with match group
name `:id` instead of making hard assumptions with the matches being
contained inside arrays from scan.
2019-11-19 10:59:28 -08:00
Juha Ruotsalainen 4fc8b07974
Removed the word 'done'.
There are cases, when 'done' is prefix with a duration, like `... 0.1s done`.
2019-11-19 10:02:03 -08:00
Rumpu-Jussi f3629ebd09
Buildkit-based output processed a bit differently. 2019-11-19 10:02:03 -08:00
Juha Ruotsalainen 8041d0ae78
Build quietly and capture the image hash
At least on macOS combo Catalina + Docker engine 19.03.4 + Docker desktop 2.1.0.4 + vagrant 2.2.6 the original `matches = result.scan(/Successfully built (.+)$/i)` -line fails to generate a match. With this change I can `vagrant up --provider=docker` successfully.
2019-11-19 10:02:03 -08:00
Dan Čermák 435a32684f
Only return interfaces where addr is not nil
tunnel interfaces on Linux have addr set to nil which makes the function
list_interfaces fail with a backtrace.
2019-10-10 10:49:03 -07:00
Brian Cain e6d47329ee
Add note about removing prefix workaround 2019-10-09 16:07:21 -07:00
Brian Cain 8458a21657
Determine prefix with netmask 2019-10-09 15:40:36 -07:00
Brian Cain 62b7e35169
Fixes #11094: Determine prefix for docker public networks
Prior to this commit, the docker action was using the method `prefix` on
an IPv4 and IPv6 address. This works fine for ruby versions 2.5 and
newer, however the ruby shipped with Vagrant is before 2.5, and
therefore the IPv4 and IPv6 classes do not have the prefix method,
resulting in an error. This commit fixes that by using a different
method of determining the prefix.
2019-10-09 09:56:59 -07:00
Brian Cain f1ea4eaac0
Ensure build_args are passed into docker compose config file
Prior to this commit, the docker compose build method would not properly
set build_args if given in a Vagrantfile. This commit fixes that by
using the passed in key `extra_args` from the docker build action.
2019-10-07 12:48:59 -07:00
Brian Cain 96e275451c
Merge pull request #10938 from andersk/virtualbox-usable
virtualbox: Fix usability test to reject bad installs without crashing
2019-10-07 09:04:24 -07:00
Anders Kaseorg 4afd370d6a virtualbox: Fix usability test to reject bad installs without crashing
If VirtualBox is installed but the kernel module is missing or the
service is stopped, the usability test should fail without crashing so
we can fall back to other providers.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-04 15:56:10 -07:00
Brian Cain 8f856949f2
Merge pull request #10978 from mrshanahan/fix-issue-10973
Fixes issue hashicorp#10973: checks that VMMS WMI reference is null & throws appropriately
2019-10-01 11:12:41 -07:00
Anders Kaseorg 5b4dcf9443
providers/docker: Fix usability check
In commit 7980178d19 (#10879) I added a
`usable?` class method to `VagrantPlugins::DockerProvider::Provider`.
However, commit 34e53a5a4b (#10890)
incorrectly changed it to an instance method.  This rendered it
ineffective because it’s called on the class, not an instance.  Change
it back to a class method.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-09-10 15:10:43 -07:00
Brian Cain 09af983caa
Fixes #11051: Only use host vm if specified
Prior to this commit, the docker login action assumed that if there was
a password to authenticate with, Vagrant was using a host vm to run
docker. This is likely due to some legacy decisions with how Vagrant
used to manage running docker. This commit fixes that by only grabbing a
host_vm lock if the host_vm is actually in use, otherwise login
normally.
2019-09-05 14:54:40 -07:00
Matt Shanahan 6caa7bfa86 Fixes issue hashicorp#10973: checks that VMMS WMI reference is null & throws appropriately 2019-07-19 07:48:03 +02:00
Brian Cain fb80e8da9f
Merge pull request #10890 from briancain/add-usability-check-for-docker-plus-tests
Add usability check for docker plus tests
2019-06-05 07:58:23 -07:00
Brian Cain 34e53a5a4b
Add docker provider class test
This commit introduces aa provider_test class for the Docker provider
2019-06-04 13:24:07 -07:00
Anders Kaseorg 7980178d19 providers/docker: Add usability test
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-05-30 13:13:43 -07:00
Brian Cain ca0fd64ded
Fixes #10798: Enhance how docker compose driver path expands
Prior to this commit, the docker compose driver would _always_ path
expand a host volume no matter what. This is not always the correct
option, for example if that host volume is actually a reference to a key
inside a `volumes` hash instead of a path on disk. This commit changes
that by looking to see if the requested host volume is actually a
defined key inside the compose config, and if not, it will path expand
it like before. Otherwise it will leave the key "as is".
2019-04-29 16:14:37 -07:00
Brian Cain 75d4aa42a1
Ensure non-existent machines do not attempt to list snapshots
Prior to this commit, if a snapshot restore was run on an entire
environment with some non-existent guests, Vagrant would attempt to list
their snapshots with a nil id. This commit fixes that by returning an
empty list of snapshots if the machine has not been created yet.
2019-04-09 13:11:19 -07:00
Brian Cain 4f80a9e6d5
Add test for requesting public ip range for docker network provider 2019-03-22 09:02:40 -07:00
Brian Cain 6bffdca972
Add beginning of connect network tests for docker provider 2019-03-21 16:06:24 -07:00
Brian Cain 88a18fe2c5
Add public network tests for docker provider 2019-03-21 16:06:11 -07:00
Brian Cain 82700d95b3
Ensure subnet is used if specified from user config options 2019-03-21 15:29:04 -07:00
Brian Cain 8c169714c5
Ensure variable names exist in method 2019-03-21 11:39:16 -07:00
Brian Cain 96a19aa00c
Fix how options to cli args are handled
Since options could also be defined as strings, convert it all to string
and compare those instead
2019-03-21 11:15:41 -07:00
Brian Cain 5215354d16
Fix missing docker error classes, and finish out initial #call tests 2019-03-21 10:50:45 -07:00
Brian Cain 1027636e41
Split up and rename unit tests for docker network operations 2019-03-20 15:14:39 -07:00
Brian Cain eb75431c4a
Update docker driver and docker driver unit tests 2019-03-20 14:50:28 -07:00
Chris Roberts 623a1815ae Allow use of subnet option when defining private network with dhcp type 2019-03-19 14:35:40 -07:00
Chris Roberts 670bef6596 Allow custom subnet to be provided when private network type is dhcp 2019-03-19 14:20:14 -07:00
Chris Roberts afb6c20581 Fix option mask to be expected netmask 2019-03-19 14:03:03 -07:00
Chris Roberts a1c7eec441 Include synchronization as the environment lock is per process only 2019-03-19 13:46:14 -07:00
Chris Roberts a645ce3c25 Docker provider networking support updates
Use `mask` option for defining subnet on network configuration. Allow
options to be passed through using hash scoping and docker_network and
docker_connect prefixes. Enable public networks. Allow configuration
to define pre-existing networks by name.
2019-03-19 11:44:33 -07:00
Chris Roberts 1224622387 Remove container inspection caching and Exception rescue
Container inspection is caching data on first lookup. This will
result in incorrect data being returned on subsequent lookups if
a different `cid` value is provided. Also removed rescue of
the `Exception` class as this generally should never happen; rescue
of StandardError will be enough.
2019-03-19 11:44:22 -07:00
Chris Roberts c251e090b3 Remove Mutex for synchronization. Environment#lock satisfies requirement. 2019-03-19 11:44:02 -07:00
Brian Cain 6664936c0b
Make ignored vagrant network options a constant 2019-03-12 10:40:58 -07:00
Brian Cain 5ed5868067
Inspect networks before creating new ones
This commit updates the behavior of how the docker provider creates new
docker networks. It looks at each existing network to see if the
requested subnet has already been configured in the docker engine. If
so, Vagrant will use that network rather than creating a new one. This
includes networks not created by Vagrant. Vagrant will not clean up
these networks if created outside of Vagrant.
2019-03-12 10:36:57 -07:00
Brian Cain b78dada2c7
Fix docker driver handling cli flags
Make opts argument set to nil instead of splat to make Travis Ruby 2.3
happy
2019-03-05 10:57:05 -08:00
Brian Cain cccbedf4ce
Update how docker network handles processing options to cli arguments
Add an "ignored option" array rather than a big if-statement expression
2019-03-04 14:19:40 -08:00
Brian Cain 953a380371
Fix how Vagrant assigns cli arguments for the create command
This commit inlines the flag assignments so that arguments are properly
assigned to flags rather than arguments to the subcommand.
2019-03-04 13:44:21 -08:00
Brian Cain efb9fd7b65
Move strings into locales file 2019-03-04 13:33:08 -08:00
Brian Cain a1b48ed1bb
Raise proper class if invalid options given for docker network 2019-03-04 13:17:14 -08:00
Brian Cain 0b28580105
Move out cli argument generation to own function 2019-03-04 10:33:24 -08:00
Brian Cain 81fa7036be
Rename cli argument method 2019-03-04 10:28:49 -08:00
Brian Cain 6c7c74be5a
Fix if statement from `=` to `==` 2019-03-04 10:28:05 -08:00
Brian Cain 4080f9e64d
Log warning if docker network inspect fails to return json 2019-03-04 10:25:10 -08:00
Brian Cain 5adffb608d
Only allow private_network for docker network provider 2019-03-01 16:34:43 -08:00
Brian Cain 29696b0f73
Allow for ipv6 networks in docker 2019-03-01 16:20:16 -08:00