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

Cannot clean up unless 'creates' is specified. #328

Closed
ljkimmel opened this issue Apr 13, 2018 · 7 comments · Fixed by #474
Closed

Cannot clean up unless 'creates' is specified. #328

ljkimmel opened this issue Apr 13, 2018 · 7 comments · Fixed by #474

Comments

@ljkimmel
Copy link

It appears that the archive file will not be cleaned up unless the 'creates' parameter is used AND the file that is specified by that parameter exists after extraction.

I think it would be useful to be able to cleanup even if this parameter is not specified or does not seem to exist. Is there reasoning behind not doing this?

@miterion
Copy link

As a workaround it is possible to specify the downloaded archive as the file used for the create parameter.

@ljkimmel
Copy link
Author

ljkimmel commented Jun 19, 2018

That's a good workaround that I was not aware of. This does help me in one scenario that I have. However, consider the following scenario:

I use the archive type to retrieve and extract an archive to install some software. The software is extracted to a temporary directory. Later an 'exec', or other provider, is run to install software from that temporary directory. I'd like to utilize the archive provider's 'creates' parameter to point to a file which WILL exist after this other provider runs but not immediately after the archive provider runs. In this way we can get idempotency out of the archive provider. Using the creates parameter in this way does, in fact work, but the down side is that the archive file does not get cleaned up.

While this is probably an edge case I think being able to clean up the archive file without having a valid 'creates' file configured makes general sense.

@miterion
Copy link

I agree with you, this is just a workaround if you really need this functionality now.

@pillarsdotnet
Copy link
Contributor

I noticed today that, if a checksum is provided, and the downloaded archive file (stored in the C:\Windows\Temp folder) doesn't match that checksum, cleanup likewise fails to happen.

This resulted in completely filling the O/S disk of several of our test VM's. Worse, since the tempfile name is randomly-generated, I can't simply follow up with a File { $tempfile: ensure => absent }

@pillarsdotnet
Copy link
Contributor

@ljkimmel -- Your second scenario may be alleviated by adding a custom extract command to the archive resource, instead of using a separate exec.

@pillarsdotnet
Copy link
Contributor

That said, this bug has been open for over four years; it's high time to fix it. I will dig into the code and see what I can do...

@pillarsdotnet
Copy link
Contributor

I have permission to spend some workhours to remediate the following:

  • If the checksum does not match, the randomly-named temporary file is not deleted, regardless of the "cleanup" parameter setting.
  • If the extract command fails, the downloaded archive file is not deleted, regardless of the "cleanup" parameter setting.

Once I have code that works for my employer, I will try to extract a general solution and submit a PR back to the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants