Git Product home page Git Product logo

knife-tidy's Introduction

knife tidy

Gem Version Build status

Umbrella Project: Knife

Project State: Active

Issues Response Time Maximum: 14 days

Pull Request Response Time Maximum: 14 days

Summary

NOTE: If you're a first-time or inexperienced knife-tidy user, we recommend you read through this blog post before proceeding with the rest of this documentation: https://blog.chef.io/2017/10/16/migrating-chef-server-knife-ec-backup-knife-tidy/

This Chef Knife plugin provides:

  • Reports on the state of Chef Server objects that can be tidied up
  • Removal of stale nodes (and associated clients and ACLs) identified by the above Reports
  • A knife-ec-backup companion tool that will clean up data integrity issues in an object backup

Requirements

A current Chef Client. Can easily be installed via Chef DK

Installation

Via Rubygems

gem install knife-tidy

Via Source

git clone https://github.com/chef-customers/knife-tidy.git
cd knife-tidy
gem build knife-tidy.gemspec && gem install knife-tidy-*.gem --no-ri --no-rdoc

Common Options

The following options are supported across all subcommands:

  • --orgs ORG1,ORG2: Only apply to objects in the named organizations (default: all orgs)

$ knife tidy server report --help

Cookbooks and nodes account for the largest objects in your Chef Server. If you want to keep it lean and mean and easy to port the object data, you must tidy these unused objects up!

Options

  • --node-threshold NUM_DAYS Maximum number of days since last checkin before node is considered stale (default: 30)

  • --keep-versions MIN Minimum number of versions of each cookbook to keep (default: 0)

Example:

knife tidy server report --orgs brewinc,acmeinc --node-threshold 50

Notes

server report generates json reports as such:

File Name Contents
org_threshold_numdays_stale_nodes.json Nodes in that org that have not checked in for the number of days specified.
org_cookbook_count.json Number of cookbook versions for each cookbook that that org.
org_unused_cookbooks.json List of cookbooks and versions that do not appear to be in-use for that org. This is determined by checking the versioned run list of each of the nodes in the org.

The intended interpretation of the data in the above files is as such:

  1. Determine a threshold of number of days since last check-in that is acceptable to deem a node "unused" and eligible for deletion. Use that number for --node-threshold NUM_DAYS
  2. Delete those nodes older than threshold and the unused cookbooks from the unused cookbooks list.
  3. Re-run the report and this time more cookbooks might show up on the unused list after having cleared out the "stale" nodes.
  4. Delete the unused cookbooks from the updated list of unused cookbooks.

Repeat the above periodically.

$ knife tidy server clean --help

Remove stale nodes that haven't checked-in to the Chef Server as defined by the --node-threshold NUM_DAYS option when the reports were generated.. The associated client and ACLs are also removed.

Options

  • --backup-path /path/to/an-ec-backup The location to the last backup of the target Chef Server. It is not recommended to run the clean command without first taking a current backup using knife-ec-backup

  • --only-cookbooks Only deletes the unused cookbooks from the target Chef Server. NOTE: Cannot be specified if --only-nodes is already specified

  • --only-nodes Only deletes the stale nodes, associated clients, and ACLs from the target Chef Server. NOTE: Cannot be specified if --only-cookbooks is already specified

  • --dry-run Do not perform any actual deletion, only report on what would have been deleted.

Example:

knife tidy server clean --orgs brewinc,acmeinc

$ knife tidy backup clean --help

Options

  • --backup-path /path/to/an-ec-backup: The Chef Repo to tidy up (such as one created from a knife-ec-backup

  • --gsub-file /path/to/gsub/file: The path to the file used for substitutions. If non-existent, a boiler plate one will be created.

Run the following example before attempting the knife ec backup restore operation:

knife tidy backup clean --gen-gsub
INFO: Creating boiler plate gsub file: 'substitutions.json'
knife tidy backup clean --backup-path backups/ --gsub-file substitutions.json

Notes

Global file substitutions can be performed when --gsub-file option is used. Several known issues are corrected and others can be added with search/replace pairings. The following boiler plate file is created for you when --gen-gsub is used:

{
  "io-read-version-and-readme.md":{
    "organizations/*/cookbooks/*/metadata.rb":[
      {
        "pattern":"^version +IO.read.* 'VERSION'.*",
        "replace":"version !COOKBOOK_VERSION!"
      },
      {
        "pattern":"^long_description +IO.read.* 'README.md'.*",
        "replace":"#long_description \"A Long Description..\""
      }
    ]
  }
}

$ knife tidy notify

The knife tidy notifycommand is used to send a summary of the reports generated by knife tidy server report to your organization admins.

When run from the directory containing your reports, it will iterate through the reports for each organization in turn, and query the Chef server specified in your knife.rb for all admins of that organization.

It will then generate a summary email from your knife tidy reports, and email it to all admins for that organization.

This command assumes you have access to an SMTP server you can use for sending outgoing emails.

Options

  • --smtp_server : The SMTP Server to use (defaults to localhost)
  • --smtp_port : The SMTP Port to be used (defaults to 25)
  • --smtp_username : The SMTP Username to be used
  • --smtp_password : The SMTP Password to be used
  • --smtp_from : The From email address to be used when sending email reports
  • --smtp_enable_tls : Whether or not to enable TLS when sending reports via SMTP (defaults to false)
  • --smtp_helo : The SMTP HELO to be used (defaults to localhost)

Run the following example before attempting the knife ec backup restore operation:

$> knife tidy notify --smtp_server smtp.myserver.com --smtp_port 587  --smtp_from [email protected] --smtp_username myuser --smtp_password mypassword --smtp_use_tls

Reading from /home/myuser/knife_tidy/reports directory
Fetching report data for organization mytestorg
  Parsing file /home/myuser/knife_tidy/reports/mytestorg_unused_cookbooks.json
  Parsing file /home/myuser/knife_tidy/reports/mytestorg_cookbook_count.json
  Parsing file /home/myuser/knife_tidy/reports/mytestorg_stale_nodes.json
Fetching admins users for organization mytestorg
Sending email reports for organization mytestorg

Summary and Credits

  • Server Report was ported from Nolan Davidson's chef-cleanup

knife-tidy's People

Contributors

ashiqueps avatar chef-ci avatar chef-expeditor[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar dheerajd-msys avatar itmustbejj avatar jblaine avatar jeremymv2 avatar jonlives avatar kasif-adnan avatar markgibbons avatar mskdenigma avatar nikhil2611 avatar skeshari12 avatar tas50 avatar tduffield avatar thelunaticscripter avatar tyler-ball avatar vkarve-chef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knife-tidy's Issues

knife-tidy-2.0.9/lib/chef/tidy_acls.rb:205:in `[]': no implicit conversion of Symbol into Integer (TypeError)

Version:

2.0.9

Environment:

RHEL7

Scenario:

Running 👍 /opt/chef/embedded/bin/knife tidy backup clean --orgs aaa --backup-path /app/chef_restore -c /etc/chef/local_knife.rb -VV

and getting:

INFO: validating org aaa invites in /app/chef_restore/organizations/aaa/invitations.json
INFO: validating all clients for org aaa exist in clients group
INFO: Loading users
INFO: Loading members for aaa
INFO: Loading clients for aaa
INFO: Loading groups for aaa
INFO: aaa Actors loaded!
Traceback (most recent call last):
14: from /opt/chef/embedded/bin/knife:23:in <main>' 13: from /opt/chef/embedded/bin/knife:23:in load'
12: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.14.29/bin/knife:24:in <top (required)>' 11: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.14.29/lib/chef/application/knife.rb:161:in run'
10: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.14.29/lib/chef/knife.rb:226:in run' 9: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.14.29/lib/chef/knife.rb:455:in run_with_pretty_exceptions'
8: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.14.29/lib/chef/local_mode.rb:44:in with_server_connectivity' 7: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.14.29/lib/chef/knife.rb:456:in block in run_with_pretty_exceptions'
6: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/knife/tidy_backup_clean.rb:53:in run' 5: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/knife/tidy_backup_clean.rb:53:in each'
4: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/knife/tidy_backup_clean.rb:60:in block in run' 3: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/tidy_acls.rb:203:in validate_user_acls'
2: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/tidy_acls.rb:203:in each' 1: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/tidy_acls.rb:205:in block in validate_user_acls'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/knife-tidy-2.0.9/lib/chef/tidy_acls.rb:205:in `[]': no implicit conversion of Symbol into Integer (TypeError)

Supermarket.chef.io

Any chance this plugin could be published on the supermarket.chef.io tools page. It's hard to find here.

Thanks,
Mark

Sort the clients in the clients group object

Describe the Enhancement

I want to get the clients group sorted

Describe the Need

In older versions of chef-server, in my case 12.17.33, when you do a knife-ec-backup your groups/client.json might not come out sorted correctly. When restoring into a chef-automate 2 server the ordering of the objects matter and the restore process is no longer idempotent. You can't run a restore more than once.

Current Alternative

Manually sort the clients using your favorite json library and scripting language

Can We Help You Implement This?

I plan on implementing it myself but could use help testing this across different versions of chef-server

crashes on FFI_Yajl::ParseError

If there are any invalid json files, tidy crashes with FFI_Yajl::ParseError with no output to determine which file is invalid.

org deleted while tidy report is running should not abort

Using knife-tidy 1.0.0

REPRO:

  • knife tidy server report --node-threshold 365
  • chef-server-ctl org-delete findme
  Organization: findme
ERROR: The object you are looking for could not be found
Response: organization 'findme' does not exist.

The report should be able to log the error and move on. It should not cause the report function to abort.

users that are in the admins group and do not exist in the users group should be skipped over

In our chef server, we had one org that had a user listed in their admins group. However, further examination revealed that this admin user did not exist in the users group. This condition caused knife-tidy to abort with this error:

Fetching admins users for organisation ORGNAME
  Cannot fetch admin users for organisation ORGNAME as it does not exist on the server
ERROR: knife encountered an unexpected error
This may be a bug in the 'tidy notify' knife command or plugin
Please collect the output of this command with the `-VV` option before filing a bug report.
Exception: NoMethodError: undefined method `map' for nil:NilClass

This GET resulted in a 404 error:
DEBUG: Initiating GET to https://chef.domain.com/organizations/ORGNAME/users/USERNAME

knife tidy backup clean throws an error with chef-dk/ws that includes chef >= 15.0.293

Version:

Knife-Tidy version: 2.0.1
Chef Workstation version: 0.9.42
Chef Infra Client version: 15.3.14

Environment:

Test in Linux and OSX with Chef-Server 13

Scenario:

knife tidy backup clean no longer works on backups with an organization that has more than one version of the same cookbook. Removing all but the latest versions of the cookbooks from the backup allows it to finish without an error.

I suspect that the changes in chef/chef#7794 are the cause of this. It removes support for multiple cookbooks with the same cookbook name in the same cookbook_path, which is what happens when knife ec backup downloads a copy of each cookbook version.

The call to the code that triggers the error is https://github.com/chef/knife-tidy/blob/master/lib/chef/knife/tidy_backup_clean.rb#L167

Stacktrace of the error:

Traceback (most recent call last):
	19: from /Users/wfisher/.gem/ruby/2.6.3/bin/knife:23:in `<main>'
	18: from /Users/wfisher/.gem/ruby/2.6.3/bin/knife:23:in `load'
	17: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/bin/knife:24:in `<top (required)>'
	16: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/application/knife.rb:162:in `run'
	15: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/knife.rb:222:in `run'
	14: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/knife.rb:474:in `run_with_pretty_exceptions'
	13: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/local_mode.rb:42:in `with_server_connectivity'
	12: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/knife.rb:475:in `block in run_with_pretty_exceptions'
	11: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:53:in `run'
	10: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:53:in `each'
	 9: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:65:in `block in run'
	 8: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:165:in `load_cookbooks'
	 7: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:315:in `for_each_cookbook_basename'
	 6: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:315:in `each'
	 5: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:319:in `block in for_each_cookbook_basename'
	 4: from /Users/wfisher/.gem/ruby/2.6.3/gems/knife-tidy-2.0.3/lib/chef/knife/tidy_backup_clean.rb:167:in `block in load_cookbooks'
	 3: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/cookbook_loader.rb:87:in `load_cookbook'
	 2: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/cookbook_loader.rb:173:in `cookbook_version_loaders'
	 1: from /Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/cookbook_loader.rb:173:in `each'
/Users/wfisher/.gem/ruby/2.6.3/gems/chef-15.3.14/lib/chef/cookbook_loader.rb:177:in `block in cookbook_version_loaders': Cookbook merging is no longer supported, the cookbook named test can only appear once in the cookbook_path (Chef::Exceptions::CookbookMergingError)

Steps to Reproduce:

  1. Follow the instructions from https://blog.chef.io/migrating-chef-server-knife-ec-backup-knife-tidy/ to create a backup using knife ec backup backup_directory -c /etc/opscode/pivotal.rb
  2. Run knife tidy backup clean --backup-path backup_directory
  3. Command throws an error

Expected Result:

knife tidy backup clean should complete successfully

Actual Result:

An error is thrown: ERROR: Chef::Exceptions::CookbookMergingError: Cookbook merging is no longer supported, the cookbook named test can only appear once in the cookbook_path

backup path can be empty and clean can still proceed

This assertion was made for a different issue: #79 (comment)

However, this assertion fails, because the code is only checking that the directory exists and is a directory. The directory can actually be empty and the destructive action can still proceed. From what I could find, these are the only two validation checks pertaining to the backup path: https://github.com/chef-customers/knife-tidy/blob/master/lib/chef/knife/tidy_server_clean.rb#L48-L56

Failing spec tests

Version:

Master

Environment:

Buildkite CI

Scenario:

Spec failures are occurring in the specs that check for output:


Failures:



  1) Chef::Knife::TidyBackupClean completion_message lets the user know we're Finished

     �[31mFailure/Error: �[0m�[32mexpect�[0m { t.completion_message }.to output(�[31m�[1;31m"�[0m�[31m** Finished **�[1;35m\n�[0m�[31m�[1;31m"�[0m�[31m�[0m).to_stdout�[0m

     �[31m�[0m

     �[31m  expected block to output "** Finished **\n" to stdout, but output nothing�[0m

     �[31m  Diff:�[0m�[0m

     �[31m  �[0m�[34m@@ -1,2 +1 @@�[0m

     �[31m  �[0m�[31m-** Finished **�[0m

     �[31m  �[0m�[0m

     �[36m# ./spec/chef/knife/tidy_backup_clean_spec.rb:21:in `block (3 levels) in <top (required)>'�[0m



  2) Chef::Knife::TidyBase completion_message lets the user know we're Finished

     �[31mFailure/Error: �[0m�[32mexpect�[0m { t.completion_message }.to output(�[31m�[1;31m"�[0m�[31m** Finished **�[1;35m\n�[0m�[31m�[1;31m"�[0m�[31m�[0m).to_stdout�[0m

     �[31m�[0m

     �[31m  expected block to output "** Finished **\n" to stdout, but output nothing�[0m

     �[31m  Diff:�[0m�[0m

     �[31m  �[0m�[34m@@ -1,2 +1 @@�[0m

     �[31m  �[0m�[31m-** Finished **�[0m

     �[31m  �[0m�[0m

     �[36m# ./spec/chef/knife/tidy_base_spec.rb:22:in `block (3 levels) in <top (required)>'�[0m



Finished in 0.01192 seconds (files took 0.8182 seconds to load)

�[31m6 examples, 2 failures�[0m



Failed examples:



�[31mrspec ./spec/chef/knife/tidy_backup_clean_spec.rb:20�[0m �[36m# Chef::Knife::TidyBackupClean completion_message lets the user know we're Finished�[0m

�[31mrspec ./spec/chef/knife/tidy_base_spec.rb:21�[0m �[36m# Chef::Knife::TidyBase completion_message lets the user know we're Finished�[0m

FATAL: Cannot find subcommand for: 'tidy backup clean'

Following the instructions for installing knife-tidy, to get rid of the chef sugar errors during restore, I am executing the following steps:

$chef gem install knife-tidy
or
$git clone https://github.com/chef-customers/knife-tidy.git
$cd knife-tidy
$cp conf/substitutions.json.example conf/substitutions.json
$knife tidy backup clean --backup-path /path/to/your/backup --gsub-file conf/substitutions.json
As for the last command, i get:

-bash-4.1# knife tidy backup clean --backup-path ../backup_8_28_2017_315PM --gsub-file conf/substitutions.json
FATAL: Cannot find subcommand for: 'tidy backup clean --backup-path ../backup_8_28_2017_315PM --gsub-file conf/substitutions.json'
Available subcommands: (for details, knife SUB-COMMAND --help)

notify subcommand ignores --orgs option

knife tidy notify --help indicates that --orgs is an option for this subcommand. However, running it with the explicit intention to only notify one or more specified orgs is ignored. The process proceeds to send notifiations to all chef orgs in my chef server reports folder.

REPRO:

  1. Ensure there are files generated in the reports folder
  2. Run knife tidy notify --orgs <org_name>

The notifications are sent out for all chef orgs. It appears --orgs option is ignored.

knife-tidy version 0.6.1

A stale search index can generate inaccurate tidy reports

Currently we rely on search to populate the node lists from which we generate our tidy reports.

We should do some minimal verification such as comparing the node count in the search index vs what is in the database (knife status vs knife node list) to make sure the index is up-to-date when we generate an org's reports.

knife tidy server clean - org names with _

on the current release of knife tidy the command 'knife tidy server clean' is not properly reading Orgs with _ in the name for example corp_xxx, tries to delete corp

Installs, doesn't run

$ sudo gem install knife-tidy
Successfully installed knife-tidy-1.1.0
Parsing documentation for knife-tidy-1.1.0
Done installing documentation for knife-tidy after 0 seconds
1 gem installed

$ sudo knife tidy server report --orgs xxx --node-threshold 50
FATAL: Cannot find subcommand for: 'tidy server report --orgs xxx --node-threshold 50'

the backup-path should default to current working directory

When running the reports subcommand, --backup-path defaults to the current working directory. However, this behavior is not mirrored when running the clean subcommand. Instead, tidy will prompt the user for the backup path.

REPRO:

knife tidy server report --orgs myorg --node-threshold 90
~$ knife tidy server clean --only-cookbooks
It is not recommended to run this command without specifying a current backup directory.
Please specify a backup directory:

ERROR: Errno::ENAMETOOLONG: File name too long @ rb_sysopen

Version:

knife-tidy (2.0.12)

chef -v

Chef Workstation version: 0.18.3
Chef Infra Client version: 15.10.12
Chef InSpec version: 4.18.111
Chef CLI version: 2.0.10
Test Kitchen version: 2.5.0
Cookstyle version: 6.3.4

Environment:

Linux RHEL 7

Scenario:

Trying to mail the report associated to a tidy run

knife tidy notify -c ~user/.chef/knife.rb --smtp_from [email protected]

Steps to Reproduce:

knife tidy notify -c ~user/.chef/knife.rb --smtp_from [email protected]

Expected Result:

A mail is sent to all admins emails

Actual Result:

knife tidy notify -c ~user/.chef/knife.rb --smtp_from [email protected]

Reading from /reports directory
Fetching report data for organization xxxxx
Parsing file /reports/xxxxx_unused_cookbooks.json
ERROR: Errno::ENAMETOOLONG: File name too long @ rb_sysopen - {
"cookbook_one": [
"0.1.44",
"0.1.45",
"0.1.49",
"0.1.50",
"0.1.51"
],
"cookbook_two": [

Clean up references to tidy methods

Some of the tidy methods refer to tidy.method because the method is not located inside tidy_base.rb. If we can move all the referenced methods, we can simplify the code.

knife tidy backup clean --gen-gsub fails due to missing file

Version:

2.0.12

Environment:

CentOS 7

Scenario:

I'm trying to generate a substitution json as seen in the readme

Steps to Reproduce:

knife tidy backup clean --gen-gsub

Expected Result:

INFO: Creating boiler plate gsub file: 'substitutions.json'

Actual Result:

INFO: Creating boiler plate gsub file: 'substitutions.json'
ERROR: Errno::ENOENT: No such file or directory @ rb_sysopen - /root/.chefdk/gem/ruby/2.6.0/gems/knife-tidy-2.0.12/lib/chef/../../conf/substitutions.json.example

ERROR: SystemStackError: stack level too deep

Getting the following error running knife tidy server report --node-threshold 60 after a knife tidy clean has been run.
Currently the xxxorg has 0 nodes in it.

Organization: xxxorg
ERROR: SystemStackError: stack level too deep

knife tidy server report should handle missing read permission

When there is 1 or more orgs that a user does not have read permission to, we need to provide a better user experience.

$ knife tidy server report
Writing to /Users/matt/reports directory
ERROR: You authenticated successfully to https://chef.xyz.com/chef as chef_admin but you are not authorized for this action.
Response:  missing read permission

Ideally, we'd rescue on that error and complete iterating through any orgs that the user does have read permissions to. Additionally, we'd suggest to them how to add the missing read permission:
ie. knife opc org user add <ORG> <USER> -a

Dependabot can't parse your Gemfile

Dependabot couldn't parse the Gemfile found at /Gemfile.

The error Dependabot encountered was:

Dependabot only supports uninterpolated string arguments to eval_gemfile. Got `__FILE__ + ".local"`

Add option to attach raw JSON report files to the email notification

We'd like to attach the JSON reports when the notify command is executed. The email format is great, but the JSON will encourage our engineers to use the reports in an automated fashion (i.e., loop through the stale nodes report and delete their stale nodes, or loop through the unused cookbook versions report and delete them.

notifications fail for chef orgs containing an underscore

Chef orgs with an underscore in the name are causing the notifications to abort. The tidy report will get all the way through until the actual sending of email. Then, it fails with this Cannot fetch admin users for organisation csa as it does not exist on the server. The chef org in this example is actually called csa_taxonomy.

specifying backup directory with tab completion doesn't complete

The knife tidy tool asks for a backup directory. I first created it with mkdir -p <path> and then tried to use tab completion at the CLI to specify the backup directory I had just created. Tab completion did not seem to work; it simply moved the tab about 15 spaces to the right with no text being completed.

Also, after I ran knife tidy server clean --orgs <org> --only-cookbooks and specified a backup directory when a Warning prompted me to, the cookbooks were cleaned up but nothing is in the backup directory.

Tidy removing needed/required/used cookbook versions

Version:

2.1.0

Environment:

Amazon Linux AMI
4.14.181-140.257.amzn2.x86_64

Scenario:

We've a production Chef-infra where an 'export' is produced.
On a new Chef-infra (that will eventually replace our old production Chef-Infra) we are wanting to 'import' to this new server and this works OK.
Since our old Chef-Infra server is 3 years old, it has a LOT of old and unused cookbook versions we'd like to remove/clean up so we want to run 'tidy' to remove unneeded cookbooks.
Unfortunately, required/used cookbook versions are being removed.

Steps to Reproduce:

On our new Chef-infra server the 'export' from our current Chef-infra is placed in /tmp/export.
We then run:

  • /usr/bin/knife tidy backup clean --backup-path /tmp/export
  • /usr/bin/knife ec restore /tmp/Agilent-CS-Chef-Infra-Server-export --with-user-sql --with-key-sql -c /etc/opscode/pivotal.rb --yes
  • cd /tmp
  • /usr/bin/knife tidy server report
  • /usr/bin/knife tidy server clean --backup-path /tmp/reports --yes
    and required cookbook versions get removed.

Expected Result:

We have environments pinned to certain roles which contain absolute pinnings for all included cookbooks.
All of our nodes are assigned a role and an environment, so the environment pinning points to a specific role version which in turn points to specific cookbook versions.

When I look at /tmp/reports/ORG_unused_cookbooks.json I see, for example, that for 'windows' it is saying that version '5.3.1' is OK to delete even though we've a role cookbook with absolute pinnings requiring this version.

As a workaround, I can edit /tmp/reports/ORG_unused_cookbooks.json removing 5.3.1 from the 'windows' list, but I shouldn't have to do this.

Actual Result:

Required and needed versions or cookbooks are deleted.

generate_new_metadata in tidy_backup_clean.rb needs to preserve metadata.json

If the cookbook has a metadata.json that file should never be stripped, removed or tampered with at all (no matter if metadata.rb exists or not, client programs should never attempt to regenerate metadata.json from the metadata.rb in the cookbook if it is present, the metadata.json file MUST be considered authoritative. The metadata.rb file MAY require build time artifacts which are not present in the shipping cookbook and trying to recompile it after the metadata.json has been generated is guaranteed to fail on some cookbooks.

If the cookbook has a metadata.rb file that should also not be tampered with, but it should also be ignored completely if the metadata.json file is present (so if the metadata.json and metadata.rb files are present then nothing should be done with either file THE metadata.rb file may not be parseable and THIS IS NOT A BUG TO FIX -- downstream utilities must be modified to prefer the metadata.json file.

ONLY IF one of the files exists and the other does not should knife tidy attempt to generate or reconstruct one from the other.

I can't sort out precisely what knife tidy is actually doing, but I'm reasonably confident it isn't following these guidelines.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.