Skip to content
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

Exit when reboot is detected - w/350 for pending & w/1604 on dependency package requiring reboot #1038

Closed
Apteryx0 opened this issue Nov 3, 2016 · 13 comments

Comments

@Apteryx0
Copy link

Apteryx0 commented Nov 3, 2016

As per https://groups.google.com/forum/#!topic/chocolatey/jP4cv8TDUcU, it's probably a good idea to add a switch so that install/upgrade will halt if a dependency requires a reboot. For example, I have a package that has a dependency on PowerShell 3+ - chocolately installed PowerShell v5 but then logged this and then continued to install packages with PowerShell 2 (and subsequently failed):

2016-11-02 12:05:55,829 [INFO ] - PowerShell.5.0 has been installed.
2016-11-02 12:05:55,829 [INFO ] -
2016-11-02 12:05:55,844 [WARN ] - WARNING: PowerShell.5.0 requires a reboot to complete the installation.
2016-11-02 12:05:55,844 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\PowerShell\tools\ChocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '3010'.
2016-11-02 12:05:55,844 [DEBUG] - Calling command ['"C:\Windows\System32\shutdown.exe" /a']
2016-11-02 12:05:55,870 [DEBUG] - Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'

@ferventcoder ferventcoder changed the title Contribution suggestion: switch to halt install if dependency requires a reboot Feature/switch to halt install if dependency requires a reboot Nov 3, 2016
@ferventcoder ferventcoder added this to the 0.10.x milestone Nov 3, 2016
@ferventcoder
Copy link
Member

ferventcoder commented Nov 3, 2016

Thanks!

Release Notes

To turn on this feature, please run choco feature enable --name="'exitOnRebootDetected'"

When Package Exit codes are turned on (#512), we'll exit indicating reboot necessary but not complete:

  • Pending Reboot discovered prior to running - 350 (ERROR_FAIL_NOACTION_REBOOT - "No action was taken as a system reboot is required.")
  • Some work completed - 1604 (ERROR_INSTALL_SUSPEND - "Installation suspended, incomplete.")

Both mean reboot and then run again.

@jberezanski
Copy link

Similar to #913, would probably share most of the implementation.

@ferventcoder
Copy link
Member

When finding a pending reboot before doing anything, we will fail with 350 - https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes--0-499-

ERROR_FAIL_NOACTION_REBOOT

350 (0x15E)

No action was taken as a system reboot is required.

@ferventcoder
Copy link
Member

Currently we are looking for what exit code to use when we've installed some dependencies, but have not installed everything because there is a reboot required in the middle. We've come to 3011, 3017, and a couple of others, but none are ideal in the definition.

https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes--1700-3999-

ERROR_SUCCESS_REBOOT_REQUIRED

3010 (0xBC2)

The requested operation is successful. Changes will not be effective until the system is rebooted.

ERROR_SUCCESS_RESTART_REQUIRED

3011 (0xBC3)

The requested operation is successful. Changes will not be effective until the service is restarted.

ERROR_FAIL_REBOOT_REQUIRED

3017 (0xBC9)

The requested operation failed. A system reboot is required to roll back changes made.

ERROR_FAIL_REBOOT_INITIATED

3018 (0xBCA)

The requested operation failed. A system reboot has been initiated to roll back changes made.

@ferventcoder
Copy link
Member

1602 could be an option, but it could also be indicative of other areas where a user cancels the install.

@ferventcoder
Copy link
Member

https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes--1300-1699-

ERROR_INSTALL_USEREXIT

1602 (0x642)

User cancelled installation.

ERROR_INSTALL_FAILURE

1603 (0x643)

Fatal error during installation.

ERROR_INSTALL_SUSPEND

1604 (0x644)

Installation suspended, incomplete.

@ferventcoder
Copy link
Member

1604 looks like a Winner here

@AdmiringWorm
Copy link
Member

@ferventcoder
Copy link
Member

See above, we've already identified 350

@AdmiringWorm
Copy link
Member

Sorry, I missed that one.

@ferventcoder
Copy link
Member

No worries. We have identified two codes - 350 for exit without doing anything, and 1604 for exit if some work has been completed, but not finished. Both mean reboot and then run again.

@ferventcoder
Copy link
Member

Updated #1038 (comment) above

gep13 added a commit to gep13/choco that referenced this issue Mar 5, 2019
There is now both a parameter and a feature flag which will allow
halting the install/upgrade/uninstall of a package, when a reboot
request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, and the
package exit code, either 1641 (restart initiated), or 3010 (restart
requested) will be returned.  This could then be inspected to decide
when a reboot should actually be performed, before continuing with
the remainder of the installation.

The implementation of this ability followed closely to how the
stoponfirstfailure parameter and feature flag are implemented.
gep13 added a commit to gep13/choco that referenced this issue Mar 6, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.

The initial implementation of this ability followed closely to how the
stoponfirstfailure parameter and feature flag are implemented, and then
subsequent changes added to the implementation.
gep13 added a commit to gep13/choco that referenced this issue Mar 7, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.

The initial implementation of this ability followed closely to how the
stoponfirstfailure parameter and feature flag are implemented, and then
subsequent changes added to the implementation.
gep13 added a commit to gep13/choco that referenced this issue Mar 8, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.

The initial implementation of this ability followed closely to how the
stoponfirstfailure parameter and feature flag are implemented, and then
subsequent changes added to the implementation.
gep13 added a commit to gep13/choco that referenced this issue Mar 8, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.

The initial implementation of this ability followed closely to how the
stoponfirstfailure parameter and feature flag are implemented, and then
subsequent changes added to the implementation.
gep13 added a commit to gep13/choco that referenced this issue Mar 8, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.

The initial implementation of this ability followed closely to how the
stoponfirstfailure parameter and feature flag are implemented, and then
subsequent changes added to the implementation.
gep13 added a commit to gep13/choco that referenced this issue Mar 9, 2019
When executing Chocolatey commands, it is well known that a pending
reboot requirement can prevent a succesful operation. This adds the
ability to enable detection of a pending reboot (implemented as a global
validation), which will then halt execution of the command.

This addition doesn't require that the usePackageExitCodes feature be
enabled, but rather, it inspecting the current state of the system, via
the registry to determine if a reboot is required.  These checks will
only be performed when running on the Windows Operating System.
gep13 added a commit to gep13/choco that referenced this issue Mar 9, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.
gep13 added a commit to gep13/choco that referenced this issue Mar 11, 2019
When executing Chocolatey commands, it is well known that a pending
reboot requirement can prevent a succesful operation. This adds the
ability to enable detection of a pending reboot (implemented as a global
validation), which will then halt execution of the command.

This addition doesn't require that the usePackageExitCodes feature be
enabled, but rather, it inspecting the current state of the system, via
the registry to determine if a reboot is required.  These checks will
only be performed when running on the Windows Operating System.
gep13 added a commit to gep13/choco that referenced this issue Mar 11, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.
ferventcoder pushed a commit that referenced this issue Mar 11, 2019
When executing Chocolatey commands, it is well known that a pending
reboot requirement can prevent a succesful operation. This adds the
ability to enable detection of a pending reboot (implemented as a global
validation), which will then halt execution of the command.

This addition doesn't require that the usePackageExitCodes feature be
enabled, but rather, it inspecting the current state of the system, via
the registry to determine if a reboot is required.  These checks will
only be performed when running on the Windows Operating System.
ferventcoder pushed a commit that referenced this issue Mar 11, 2019
There are now parameters and a feature flag which will allow
halting/overriding the install/upgrade/uninstall of a package, when
a reboot request is returned from one of it's dependencies.

When this occurs, an ApplicationException will be thrown, along with
a specific exit code, either 350 (pending reboot discovered prior to
running), or 1604 (some work completed prior to restart request) will be
returned.  This could then be inspected to decide when a reboot should
actually be performed, before continuing with the remainder of the
installation.
ferventcoder added a commit that referenced this issue Mar 11, 2019
* stable:
  (GH-1655) make virtual methods for outdated / package service
  (GH-1747) Fix: passing timeout switch of 0 is ignored
  (GH-1746) Update XML comments / formatting
  (GH-1746) update logging for validation
  (GH-1038) Stop operation on package reboot request
  (GH-1038) Stop execution if pending reboot
  (GH-1746) Add concept of global validation
  (maint) Corrected white space
@ferventcoder
Copy link
Member

This has been completed and will be released with 0.10.12.

@ferventcoder ferventcoder changed the title Feature/switch to halt install if dependency requires a reboot Halt install if dependency requires a reboot Mar 13, 2019
@ferventcoder ferventcoder changed the title Halt install if dependency requires a reboot Exit 350/1602 when a reboot is detected - 350 (pending) / 1602 (based on dependency package) Mar 14, 2019
@ferventcoder ferventcoder changed the title Exit 350/1602 when a reboot is detected - 350 (pending) / 1602 (based on dependency package) Exit when a reboot is detected - w/350 for pending & w/1602 on dependency package requiring reboot Mar 14, 2019
@ferventcoder ferventcoder changed the title Exit when a reboot is detected - w/350 for pending & w/1602 on dependency package requiring reboot Exit when reboot is detected - w/350 for pending & w/1602 on dependency package requiring reboot Mar 14, 2019
@ferventcoder ferventcoder changed the title Exit when reboot is detected - w/350 for pending & w/1602 on dependency package requiring reboot Exit when reboot is detected - w/350 for pending & w/1604 on dependency package requiring reboot Mar 14, 2019
ferventcoder added a commit that referenced this issue Mar 15, 2019
For exit on reboot detected, it's actually best to have it on as it
makes things more reliable for installations. Remove the note that
mentions otherwise.
ferventcoder added a commit that referenced this issue Mar 15, 2019
* stable:
  (doc) add exit codes to gen doc headings
  (doc) update generated docs
  (version) 0.10.12
  (doc) fix grammar
  (GH-1038) remove note on off recommendation
  (GH-1746) allow shutting off validation warnings
  (doc) update release notes for licensed extension
  (maint) whitespace
  (doc) update release notes
  (maint) formatting
  (GH-1758)(doc) provide exit code docs
  (doc) info - add usage / examples
  (doc) outdated - note ignore unfound
  (doc) scripting - point to scripting reference
  (doc) scripting - how to get exit code w/powershell
  (GH-1724) search - exit 2 on no results
  (GH-1758) control enhanced exit codes w/feature
  (doc) update release notes for 0.10.12 release
  (doc) update older release notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants