624 Commits

Author SHA1 Message Date
Adrien Delorme
14f2d1c132 ListenRangeConfig:Listen: use the retry pkg to wait a bit in between opens 2019-05-01 12:27:32 +02:00
Adrien Delorme
e14d1b8b0b add a timeout trying to open a random port 2019-05-01 12:01:34 +02:00
Adrien Delorme
2fd7adffc4 add tests for ListenRangeConfig.Listen 2019-05-01 11:46:48 +02:00
Adrien Delorme
d9e5145de9 Shadow the flock pkg & add a noop filelock so that at least the solaris binary can be built
Without this the following error occurs:

$ GOOS=solaris go build .
# github.com/hashicorp/packer/vendor/github.com/gofrs/flock
vendor/github.com/gofrs/flock/flock_unix.go:28:22: undefined: syscall.LOCK_EX
vendor/github.com/gofrs/flock/flock_unix.go:39:22: undefined: syscall.LOCK_SH
vendor/github.com/gofrs/flock/flock_unix.go:56:12: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:66:12: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:96:12: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:96:42: undefined: syscall.LOCK_UN
vendor/github.com/gofrs/flock/flock_unix.go:118:21: undefined: syscall.LOCK_EX
vendor/github.com/gofrs/flock/flock_unix.go:130:21: undefined: syscall.LOCK_SH
vendor/github.com/gofrs/flock/flock_unix.go:149:9: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:149:44: undefined: syscall.LOCK_NB
vendor/github.com/gofrs/flock/flock_unix.go:149:44: too many errors
2019-04-30 16:01:23 +02:00
Adrien Delorme
5d9d43c01d add tests for ListenRangeConfig.Listen 2019-04-30 15:42:59 +02:00
Adrien Delorme
fd63ec9a6c ListenRangeConfig.Listen: move trying port log after fslock trylock for less logs 2019-04-30 15:35:22 +02:00
Adrien Delorme
79ae62801f ListenRangeConfig: default network ( protocol ) to tcp 2019-04-30 14:55:38 +02:00
Adrien Delorme
65be2be38b step_download: force copy of local files only on windows 2019-04-29 09:39:21 +02:00
Adrien Delorme
200e26ea85 Step download: always copy local files
instead of symlinking to fix #7534. The longer term fix for this would be to change the go-getter so that it can leave the source file where it is & tell us where it is.

We will do this when the right time comes.
2019-04-26 10:35:18 +02:00
Adrien Delorme
9f1136db77 retry: encapsulate & return the last seen error in a RetryExhaustedError 2019-04-24 14:19:23 +02:00
Megan Marsh
e69d95eb37 when retries were exhausted in the retry Run, we were returning nil instead of an error. 2019-04-23 13:48:30 -07:00
Adrien Delorme
5f0259fe89 step download: don't fail when checksum_type is not set 2019-04-16 18:09:54 +02:00
Adrien Delorme
4dc12701d3 step_download: display clearer error messages, also when the checksum is not set
Usually the builder validation should error when the checksum is empty, but for the virtualbox-ovf builder this is not validated. Which is something I didn't see when refactoring for go-getter incorporation/refactor.
2019-04-15 14:34:09 +02:00
Megan Marsh
78cf1405ab
Merge pull request #7480 from BobSilent/fix-hyperv-multiple-hostadapter-same-switch
Fixes "Host IP for the HyperV machine: False" if more than one VMNetworkAdapter is found
2019-04-12 14:06:46 -07:00
Adrien Delorme
9ac8d8aed8 step download: ovf files usually point to a file in the same directory, using them in place is the only way 2019-04-12 16:51:57 +02:00
Adrien Delorme
63f5bbbc73 use our own copy of iochan.LineReader 2019-04-11 14:25:24 +02:00
Adrien Delorme
d72040f4fa move retry code into the common/retry pkg and make retry context aware 2019-04-09 17:46:38 +02:00
BobSilent
5b289f67fe Update hyperv.go
maybe also a fix for issue #5023
at least I got same error like there, incl. VM response
==> hyperv-iso: Host IP for the HyperV machine: False

although #4947 is marked as duplicate but shows different error output
==> hyperv-iso: Error getting host adapter ip address: PowerShell error: Get-VMNetworkAdapter : No network adapter is found with the given input.
2019-04-09 07:36:52 +02:00
Adrien Delorme
f555e7a9f2 allow a provisioner to timeout
* I had to contextualise Communicator.Start and RemoteCmd.StartWithUi
NOTE: Communicator.Start starts a RemoteCmd but RemoteCmd.StartWithUi will run the cmd and wait for a return, so I renamed StartWithUi to RunWithUi so that the intent is clearer.
Ideally in the future RunWithUi will be named back to StartWithUi and the exit status or wait funcs of the command will allow to wait for a return. If you do so please read carrefully https://golang.org/pkg/os/exec/#Cmd.Stdout to avoid a deadlock
* cmd.ExitStatus to cmd.ExitStatus() is now blocking to avoid race conditions
* also had to simplify StartWithUi
2019-04-08 20:09:21 +02:00
Adrien Delorme
a81abd297b Merge remote-tracking branch 'origin/master' into context_provisioner 2019-04-08 20:09:01 +02:00
Megan Marsh
3e72e65a6c
Merge pull request #7456 from hashicorp/do_5770
introduce the clean_resource_name to clean image/var names
2019-04-05 09:12:20 -07:00
Megan Marsh
217a93fc30 fix build_test.go on windows. This code needs to not be run in parallel, or else there can be race conditions with the post-processors all trying to access the same file at once. Additionally, I changed the test template itself so that it is valid code on either bash or cmd. Finally, I found and fixed a small bug in naming the file extensions in shell local inline scripts. 2019-04-04 14:57:56 -07:00
Adrien Delorme
c4f3dccc14 rename interpolation context from ctx to ictx and contexts to ctx to avoid conflicts 2019-04-03 15:56:15 +02:00
Adrien Delorme
82c4b76639 [Builder|Build|PostProcessor|Provisioner|Hook]Server: context cancel using a RPC cancel method 2019-04-03 15:55:55 +02:00
Adrien Delorme
14048b1e11 Revert "WIP: go towards context cancelled rpc pkg"
This reverts commit e4609b4a6a4ba2ec76a45ad67d50d180f1a914f9.
2019-04-03 15:55:55 +02:00
Adrien Delorme
9e3a179c0d WIP: go towards context cancelled rpc pkg 2019-04-03 15:55:55 +02:00
Adrien Delorme
829851fc8a change hooks to be passed a context for cancellation
we have to as it is what calls our provisioners
2019-04-03 15:55:54 +02:00
Adrien Delorme
9836dad0c9 introduce the clean_resource_name to clean image names and deprecate the old ones 2019-04-03 11:25:51 +02:00
Adrien Delorme
91cc7e1091 net.ListenRangeConfig.Listen: don't swap ports if max < min 2019-03-26 10:53:52 +01:00
Adrien Delorme
a4a83be2b9 net.ListenRangeConfig.Listen: allow to have a port rage of zero 2019-03-26 10:52:07 +01:00
Adrien Delorme
cd39aa9988 net.ListenRangeConfig.Listen: log tried ports a bit earlier in the process
so we know tried ports every time
2019-03-26 10:45:32 +01:00
Adrien Delorme
5a6dffde9a use port as ints 2019-03-19 15:01:12 +01:00
Adrien Delorme
c214f6735b make everything a uint 2019-03-19 12:54:15 +01:00
Adrien Delorme
51294287fa StepHTTPServer: display error if we could not connect 2019-03-19 12:54:15 +01:00
Adrien Delorme
6df4128517 StepHTTPServer: use the common/net pkg 2019-03-19 12:54:12 +01:00
Adrien Delorme
1685a1c4c0 add common/net package that can listen on a random port in a range 2019-03-19 12:53:56 +01:00
Adrien Delorme
6ab28ba89c
Update common/shell/shell.go
be more descriptive
2019-03-15 12:21:27 +01:00
Adrien Delorme
b4ec6e2ed2 Create exit_code_test.go 2019-03-14 13:32:46 +01:00
Adrien Delorme
eedf5e4387 Update shell.go
remove typo
2019-03-14 12:50:19 +01:00
Adrien Delorme
f0a23bb81d common shell provisioner: define a ValidExitCode func 2019-03-14 12:46:32 +01:00
Adrien Delorme
30a65c858a regroup shell provisioner params into a common struct 2019-03-14 11:57:54 +01:00
Adrien Delorme
9f82b75e57 Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 12:11:58 +01:00
Vadym Haidamaka
f736e2aba5 Print VerifyChecksum log for the download as ui.Message output 2019-03-11 22:33:46 +02:00
Megan Marsh
3dc1dafe58
Merge pull request #7287 from stephen-fox/ephemeral-ssh-key-pair-issue-7225
virtualbox: create ephemeral SSH key pair for build process
2019-03-04 14:25:04 -08:00
Stephen Fox
56c17941fe Added comment to authorized_keys 'sed' calls per review. 2019-02-28 10:54:14 -05:00
Megan Marsh
2a9f49a5c6 make sure we don't try to load an iso into memory because of a user mistake 2019-02-13 16:21:55 -08:00
xinau
36c1e8d838 moved adapter to common package 2019-02-12 07:10:57 +00:00
Stephen Fox
354fcc5cc6 Merge branch 'master' into 'ephemeral-ssh-key-pair-issue-7225'. 2019-02-05 16:16:51 -05:00
Stephen Fox
e40aa515f2 Added TODO about public key removal logic. 2019-02-05 12:00:01 -05:00
Megan Marsh
2d3f84abf0
Merge pull request #7271 from hashicorp/make_generate
make generate
2019-02-04 13:11:24 -08:00