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

Attempting to install file only if it is downloaded and/or modified #73

Merged
merged 3 commits into from Aug 13, 2015

Conversation

Projects
None yet
2 participants
@arifcse019
Copy link
Contributor

commented Aug 7, 2015

No description provided.

@arifcse019

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2015

Solves issue #72

@JonathanTron

This comment has been minimized.

Copy link
Contributor

commented Aug 7, 2015

Hi @arifcse019, thanks for the PR, it's indeed always a chicken and egg problem with downloaded resources and installation.

Here's a scenario I've encountered a lot, let's say we've downloaded the file but chef run was kill afterwards, then we already have the file, on the next run package_file.updated_by_last_action? will be false and we will not install it at all.
Now I understand your problem, because it's also something I've encountered a number of time.

About the only_if { package_file.updated_by_last_action? } I would prefer a notifies :install, "dpkg_package[grafana-#{node['grafana']['version']}], :immediately".

This would cover the install when file has been downloaded, but not the install also if file has been downloaded but not installed by last run. For this, we could tackle it by adding a guard like you did, but on the downloaded file existance: only_if { File.exist? "#{node['grafana']['file']['url']}_#{node['grafana']['version']}_amd64.deb" }.

What do you think?

@arifcse019

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2015

Sounds like a really good idea. I am going to give it a try and report back

@arifcse019

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2015

On a second thought, I am not sure if the solution above will prevent chef from installing the package even if the package is already installed. I think repeating the same guard for both downloading and installation is the best way.

I have captured the guard string in a separate variable such that we do not have to update it in two places if needed

@JonathanTron JonathanTron merged commit 990251f into sous-chefs:master Aug 13, 2015

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
@JonathanTron

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2015

Hello @arifcse019, thanks for your work and your thoughts on this issue, I've merged your commits and switch back to remote_file to action :create adding the package checksum.

It's a little more work when changing the Grafana version, but I've found it's the best way to prevent all kind of problems (file re-download, partial file, wrong file, etc).

Thanks again for your participation!

@arifcse019

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2015

My pleasure and pride to be a contributor. Thank you!

@lock

This comment has been minimized.

Copy link

commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.