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

Add the initial destruction of cookbooks out of basic retention #1

Merged
merged 2 commits into from
Sep 29, 2016

Conversation

brentm5
Copy link
Member

@brentm5 brentm5 commented Sep 29, 2016

Adds a function to remove cookbooks that are not being used. It essentially does the following:

  1. Loads all cookbook versions for a single cookbook
  2. Looks at each version in order and marks all the versions until the first version that is used by a node
  3. Deletes all of them.

Things to consider.

  • The most recent version is taken out of this check so the latest version can not be deleted.
  • Does it make sense to include a number of extra versions to keep around? (like X unused versions are kept)
  • What about if there is outdated node data and the version really isn't used?

@brentm5
Copy link
Member Author

brentm5 commented Sep 29, 2016

@jonathanmorley care to take a look? Would like some feedback on how we can get this to the same place our other package retention policies run.


def version_info_for_cookbook(cookbook_name)
nodes = all_nodes_for_cookbook(cookbook_name)
versions = Chef::CookbookVersion.available_versions(cookbook_name).map! do |version|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why map!, compared to map ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what happens when you refactor and miss something


def version_info_for_cookbook(cookbook_name)
nodes = all_nodes_for_cookbook(cookbook_name)
versions = Chef::CookbookVersion.available_versions(cookbook_name).map! do |version|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to assign to unused variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used

@brentm5 brentm5 changed the title Add the initial destruction of cookbooks Add the initial destruction of cookbooks out of basic retention Sep 29, 2016
@brentm5 brentm5 merged commit 28501e9 into master Sep 29, 2016
@brentm5 brentm5 deleted the bm-add-retention-of-cookbook branch September 29, 2016 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants