-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Add -on-error command line argument to allow preserving artifacts on builder errors #3885
Conversation
Looks interesting! This is missing some documentation. (Currently the build is busted, you can ignore Travis) |
6d51023
to
897463e
Compare
@@ -157,7 +157,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe | |||
ui.Message(fmt.Sprintf("temp admin password: '%s'", b.config.Password)) | |||
} | |||
|
|||
b.runner = b.createRunner(&steps, ui) | |||
b.runner = packerCommon.NewRunner(steps, b.config.PackerConfig, ui) |
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 really like how this code is simplified for every builder.
Azure stuff LGTM. Thanks for the contribution. |
d584c09
to
3381f96
Compare
|
Done. Is the PR still missing some documentation? |
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.
Everything works really great! I just have some comments about text and appearance. After they have been adjusted/discussed I would like to merge this, but I'd like the other maintainers to have a few days to also add their input.
steps[i] = askStep{step, ui} | ||
} | ||
default: | ||
ui.Error(fmt.Sprintf("Ignoring -on-error=%q argument: unknown on-error value", config.PackerOnError)) |
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 should instead make packer exit.
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 have already deleted the default clause since it can no longer happen. Now enumflag
makes packer exit with an error like invalid value "ASK" for flag -on-error: expected one of ["cleanup" "abort" "ask"]
- `-only=foo,bar,baz` - Only build the builds with the given | ||
comma-separated names. Build names by default are the names of their | ||
builders, unless a specific `name` attribute is specified within | ||
the configuration. | ||
|
||
- `-parallel=false` - Disable parallelization of multiple builders (on by | ||
default). |
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.
👍
- `-on-error=cleanup` (default), `-on-error=abort`, `-on-error=ask` - Selects | ||
what to do when the build fails. `cleanup` cleans up after the previous | ||
steps, deleting temporary files and virtual machines. `abort` exits without | ||
any cleanup, but the next build may require `-force`. `ask` presents a |
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.
abort
exits without any cleanup, but the next build may require-force
.
Maybe rephrase to:
abort
exits without any cleanup, which might require the next build to use -force
.
|
||
func askPrompt(ui packer.Ui) askResponse { | ||
for { | ||
line, err := ui.Ask("[C]lean up and exit, [a]bort without cleanup, or [r]etry step (build may fail even if retry succeeds)?") |
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.
[C]lean up and exit, [a]bort without cleanup, or [r]etry step (build may fail even if retry succeeds)?
I think I ratter liked it to look like:
[c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?
Which makes it a bit more easy to read.
@@ -284,6 +288,9 @@ Options: | |||
-except=foo,bar,baz Build all builds other than these | |||
-force Force a build to continue if artifacts exist, deletes existing artifacts | |||
-machine-readable Machine-readable output | |||
-on-error=abort If the build fails, abort without cleanup | |||
-on-error=ask If the build fails, prompt for action | |||
-on-error=cleanup If the build fails, clean up and exit (the default) |
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 would prefer if they where on the same line, maybe:
-on-error=[cleanup|ask|abort] If the build fails do: clean up (default), ask, or abort
I think it's clear enough and the details are in the docs.
No except for the comments I just gave I think this is done (and great). |
LGTM Thanks for this great improvement! |
thanks @orivej 👍 |
Hi, This was merged into master 25 days ago, and the last release v0.10.2 was cut 16 days ago, but this update is not in the release 0.10.2 on the site, or in homebrew. I had to build from source to get it. Is this a known issue? |
It's not an issue, it's just read the CHANGELOG.md 😉 or: $ git log1 --graph --decorate=full -10 v0.10.2 v0.10.1 14s Sat Oct 15 22:25:18 2016
* 9e8a3fa (tag: refs/tags/v0.10.2) bump gem deps and www version
* fb1c968 Cut version 0.10.2
* 1414401 Cut version 0.10.2
* bb92eef Cut version 0.10.2
* 489c75a Go\'s -X linker flag now requires only one argument (#3540)
* 7bbc29d Fix go vet casing issue
* 8e7bb5e Change version.go to 0.10.1 release
| * 4e5f651 (tag: refs/tags/v0.10.1) Cut version 0.10.1
| * 2c27461 Change version.go to 0.10.1 release
|/
* aa47c90 Udpdated test/race timeouts to 2m because AWS seems to be taking a while v0.10.2 is a rebuild of v0.10.1. |
Ah ok, will pay more attention to the change logs!. Will await 0.10.3. Also this feature works great. 👍 |
@gregorskii Thanks! Which mode do you use: |
Currently ask, as I am debugging some |
It would be great if -on-error=ask spit out a SSH key and IP addresses along with the prompt. This would make it easy to jump into the build to do some debugging prior to selecting cleanup or abort. |
Similarly, for Windows, if the communicator is |
Given that the main conversation on this branch happened last year, it's a lot easier for us to track feature requests if you open a new ticket -- or, even better, a PR :) |
This pull request resolves #409 by providing an option to delay or skip cleanup after unsuccessful
packer build
:Running with
-on-error=ask
: