-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Windows: pkg.install returns failed for msiexec/instmsi exit code 3010 (ERROR_SUCCESS_REBOOT_REQUIRED) #33298
Comments
Tracing through the code, and I don't understand the reasoning for the error logic. The package is installed using It seems to me that |
Looks like it was changed from |
. |
this is also referred to here saltstack/salt-winrepo-ng#141 by @rterbush |
* Use `cmd.run_all` to capture the entire return dictionary. * Send `output_loglevel='quiet'` to `cmd.run_all` to suppress its outputting of errors on non-zero return codes. * Check the return code to determine whether the install failed. * Catch retcode == 3010 as a successful install that just requires a reboot. * Improve the error message when a package is not detected in the registry, particularly to mention packages that install as Windows updates. * Add a message to the return dictionary about successful vs failed installs. This helps minimize confusion where the package is not detected in the registry. Fixes saltstack#33298
@lorengordon thanks for submitting a PR. Its really appreciated! Once it gets merged we will go ahead and close the issue. |
Hi @lorengordon the PR looks great, but I wonder if more should be done. If using state.apply, to know if we one of the installs returned the 3010 error code, it looks like we have to search the output, but we shouldn't have to do that. There may be a much better way to do this using pillars or something (I'm not experienced enough with salt to know), but something we could do would be to use mod_init (the same way it's being used for refresh, so we only have to refresh once) to set some custom windows registry entry specifically for this case. After we'eve applied state are last state formula can run some module that checks for our registry entry, resets the entry and schedules a reboot in x seconds (using the windows task scheduler) if the custom registry entry is set. The new module should check
(see https://technet.microsoft.com/en-us/library/cc164360(v=exchg.80).aspx) There's doubtless much more than this that should be done but this is a start. BTW I've started to write a trivial module that checks and schedules a reboot if necessary but I doubt that it's up to the devels standards. |
@lorengordon, your PR doesn't need any changing but once it's merged then I think that some work should be done on salt.modules.state and some other appropriate run module to take advantage. alls i'm sayin' |
@lorengarden, One thing that I'm not happy about is that there's no way to check if 3010 is meaningful or not. It's only a windows installer code and could mean anything at all under other contexts. It could even hypothetically mean "no reboot required" for some other installer. We can't just check that msiexec is set to true either, because some exe's wrap an msi so the 3010 code is valid in that case as well. What should probably happen is we need to add a new entry to winrepo-ng formulas so we might see something like:
This way we can avoid hard coding the 3010 (it can still be hardcoded for when msiexec is True however). I don't think that this consideration should stop your PR from being merged but it's another next step. |
@hrumph, all good points, probably for one or more new issues. 😁 I was focused in the linked PR just on addressing the bug in the return code logic for a point release. Adding new features would typically go into the develop branch first for later inclusion in a new version. Also, I did consider that Shoot, now that I'm more familiar with win_pkg.py, I may try to tackle that myself. :) |
@lorengordon and anyone else interested, now that I think about it I think that there should be a default list of reboot exit codes namely the singleton list containing 3010. This will doubtless work with 99% of cases. But it should be overridable with win repo formulas in the manner I described, so we deal with other installers that really do use different exit codes. I've got more idiotic design suggestions pending so everyone brace yourselves. |
ok sorry if in advance if i'm too spammy. some of the ideas of been having are a bit more crystallised now. I'll try to cut back on making suggestions for a while if folks are getting annoyed. First of all no change to what i said about having [3010] as a default but we should still make allowance for other codes. This is where I'm getting more specific now.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\UpdateExeVolatile should also be checked and ther'es another one too. If any of these keys indicate that a reboot should be done then the state will schedule the reboot otherwise the state will exit without a reboot. Invocation of the state should look something like reboot if necessary: There are no requirements in the state invocation because we won't assume that anything succeeded. We just want it to go last. I understand that other folks have much more sophisticated ideas and that's great but I hope that something simple like this will move us forward for the time being. |
@hrumph thanks for all the thinking and effort I like it, I really do, but I also have concerns. I cannot ever see a windows tools such as salt minion being allowed to to an automatic restart, scheduled or not. As far asI am concerned any and every logic has to allow for a specific state to be applied that says something like, restart this and that machine IF it requires or is waiting for a restart, but for salt to try to do the logic and setup the schedule on it's own, I can't see a production site that will find that acceptable. I think salt can (and should) go as far as collecting that exit status at end of installers and work on using the standard windows built-in flags in the registry that allow software to flag the fact that a restart is required. And admins are then free to decide what their site logic and state runs are to be to deal wiht in actually reading this standard windows reboot required flag and acting on it. |
I think it would be quite valuable for salt to be able to signal that a package required a reboot and execute on that signal. However, that would be a new feature and I'd really recommend it be added as a new issue so it can continue to be tracked after this one is closed by the patch I submitted. |
Right now, what is perhaps the biggest (don't know this for a fact) third party windows deployment system has this feature and the instructions don't hesitate to tell you to use it. In fact (IIRC) for some reason they have you scheduling reboots on certain installs whether or not they're even required. This may be because of a lack of flexibility with their system (I don't really know enough to say but I nevertheless suspect). IIRC correctly their online examples shows them scheduling reboots for desktops but not for servers. People perhaps want to be more cautious with servers, but server reboots will have to be done anyway sooner or later. I don't want to mention this other third party closed source system by name but if you google you might identify what I'm talking about pretty quickly. |
@lorengordon You are right. I am going to start a new issue. Even though I really shouldn't have I invaded your issue I only did it because I wanted to be sure that everyone had a longer term vision in mind before committing to anything. |
@hrumph, no problem! I don't mind having the discussion here, I just don't want the feature request to get lost! 😀 |
* Update windows pkg.install error logic * Use `cmd.run_all` to capture the entire return dictionary. * Send `output_loglevel='quiet'` to `cmd.run_all` to suppress its outputting of errors on non-zero return codes. * Check the return code to determine whether the install failed. * Catch retcode == 3010 as a successful install that just requires a reboot. * Improve the error message when a package is not detected in the registry, particularly to mention packages that install as Windows updates. * Add a message to the return dictionary about successful vs failed installs. This helps minimize confusion where the package is not detected in the registry. Fixes #33298 * Update retcode logic of pkg.remove
going to go ahead and close this up since the PR was merged and another issue was opened for further discussion. |
Description of Issue/Question
When using
pkg.install
on Windows with a msiexec or instmsi installer, an exit code of 3010 (ERROR_SUCCESS_REBOOT_REQUIRED) is technically a successful install, butpkg.install
returns it as a failure.Versions Report
The text was updated successfully, but these errors were encountered: