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

Hold pending check for 10 seconds / provide means of explicitly overriding the transactional install cleanup #822

Closed
pauxus opened this issue Jun 22, 2016 · 14 comments

Comments

@pauxus
Copy link

pauxus commented Jun 22, 2016

Original title: no longer able to run choco commands from chocolateyInstall.ps1

Since 0.9.10, with the cleanup of unfinished packages, it is no longer possible to run choco commands from inside a chocolateyInstall.ps1

Our rationale for that is that we have a kickstarter package, which resides on an uprotected feed. This package asks for username and password and configures the chocolatey sources to point to our feed aggregator (nexus), using the user credentials.

This stopped working with 0.9.10, since any run of the choco command seems to clean the currently installing package from the lib folder, resulting in an unsuccessful installation.

In order to fix this, we would either need to:

  • provide a way to tell commands not to clean up pending packages
  • mark a package a "uncleanable"
  • exempt the cleanup from certain unrelated commands (like choco source)
  • provide cmdlets for common tasks to use form inside an install script (i.e. changeChocoSource or something)
@ferventcoder
Copy link
Member

Related to #198.

@ferventcoder
Copy link
Member

This is an interesting side effect of ensuring a pending install.

The way to handle this is to delete the .pending file in the package directory.

@ferventcoder
Copy link
Member

ferventcoder commented Jun 22, 2016

  • provide a way to tell commands not to clean up pending packages

Right now the answer is to delete the .chocolateyPending file in the top of the package directory prior to calling any choco commands.

  • mark a package a "uncleanable"

Interesting

  • exempt the cleanup from certain unrelated commands (like choco source)

This could be confusing in what commands would trigger the pending cleanup

  • provide cmdlets for common tasks to use form inside an install script (i.e. changeChocoSource or something)

This could be the best option.

This is quite an interesting way of going about it. Another option is to look at the timestamp for that .pending file and only react if it is over say 2 minutes old?

@ferventcoder ferventcoder added this to the 0.9.10.3 milestone Jun 22, 2016
@ferventcoder ferventcoder self-assigned this Jun 22, 2016
@pauxus
Copy link
Author

pauxus commented Jun 22, 2016

The workaround works for now. However, just for anyone needing this in the meantime:

The filename is .chocolateyPending, not .pending

@ferventcoder
Copy link
Member

After thinking about this some more, 2 minutes is way too long. 20 seconds is more reasonable be default. I think we will also allow you to drop a file to skip pending. Does that seem reasonable?

@ferventcoder
Copy link
Member

FYI, one of the things we are moving towards is only allowing one choco process at a time.

@ferventcoder
Copy link
Member

Include an empty .chocolateyPendingSkip in the package.

@ferventcoder ferventcoder changed the title no longer able to run choco commands from chocolateyInstall.ps1 Hold pending check for 10 seconds / provide means of explicitly overriding the transactional install cleanup Jun 22, 2016
@ferventcoder
Copy link
Member

This will be released in 0.9.10.3

ferventcoder added a commit that referenced this issue Jun 23, 2016
When a pending file is created, it needs to be at least 10 seconds old
before choco will automatically remove the unfinished pacakge. This
allows running choco functions inside of a package (as long as they are
done quickly).

If someone needs to override the functionality of the removal of a
package due to the pending file, choco will also look for a
.chocolateyPendingSkip and skip the removal if that file is found.
ferventcoder added a commit that referenced this issue Jun 23, 2016
* stable:
  (GH-826) SYSTEM user always uses machine TEMP
  (GH-808) Allow silent args as array
  (GH-821) ValidExitCodes not recognized return 0
  (GH-818) Allow disk to catch up - sleep
  (GH-822) Provide pending override and file wait
  (GH-818) Wait for processes to exit + 2 seconds
  (maint) formatting
  (GH-819) Fix - NotSilent install failure binding
  (GH-775) remove 7za
  (GH-775) Use 7z instead of 7za
@masaeedu
Copy link

From the command line, is it possible to start multiple chocolatey install scripts without interfering with each other? The current default of nuking the in-progress install seems unreasonable. Either:

  • the new invocation of choco install should proceed without trying to delete the in-progress package. If either fails due to MSI reservation conflicts so be it
  • or the new invocation should wait until the pending installation is complete before doing anything, and should notify the user it is waiting
  • or an error should be produced informing the user a pending install is in progress and no action will be taken
  • or the user should be prompted to make an explicit decision to abort and remove the pending install

"Pending" installs and their removal isn't as clean as it may seem at first glance, since choco has no idea what artifacts the package has already inserted into the system, and unceremoniously removing the package does not even allow the user the ability to run the package's uninstall script to try and clean up. In most cases it just ends up irrevocably borking the package on that system.

@ferventcoder
Copy link
Member

@masaeedu can you give me a really good use case for running choco in parallel?

@ferventcoder
Copy link
Member

What you are stating here would probably be best as a new "Improve pending operations" enhancement ticket.

@masaeedu
Copy link

A product is being installed via chocolatey. I open a terminal and try to check what packages are installed:

choco list -lo

This dumps the existing install, but not before it has proceeded far enough that reattempts to install the package fail. I cannot uninstall because the package is not installed. I cannot force install because that doesn't work. I must know what the package does to the system and undo it manually, or dump and rebuild the system.

Substitute listing packages with trying to install process explorer, checking the version of a package, enabling a chocolatey feature etc. etc. etc.

@ferventcoder
Copy link
Member

  • choco list -lo - this could be incorrect because an install is happening right then.

I can see other things that maybe should not trigger pending checks, but other installs would. Again, Please create a new ticket with the title "Improve Package Pending Operations" - perhaps one thing we can do is put a process lock on the file and if a lock is found, we simply skip that pending operation.

@ferventcoder
Copy link
Member

@pauxus I think you are going to love what we did in #943.

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

4 participants