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

KeyError : KeyNotFound #62

Open
amolr opened this issue Mar 25, 2015 · 9 comments
Open

KeyError : KeyNotFound #62

amolr opened this issue Mar 25, 2015 · 9 comments

Comments

@amolr
Copy link

amolr commented Mar 25, 2015

I am running a knife ec restore command and I see the below error. Anyone knows why this could be happening

DEBUG: No chefignore file found at /home/xyzuser/server_backup/organizations/xyz/chefignore no files will be ignored
/opt/opscode/embedded/lib/ruby/gems/1.9.1/gems/knife-ec-backup-2.0.1/lib/chef/tsorter.rb:17:in fetch': key not found: "000000000000f5e4fe07d6a9c5953a09" (KeyError) from /opt/opscode/embedded/lib/ruby/gems/1.9.1/gems/knife-ec-backup-2.0.1/lib/chef/tsorter.rb:17:intsort_each_child'
from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:203:in each_strongly_connected_component_from' from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:209:inblock in each_strongly_connected_component_from'
from /opt/opscode/embedded/lib/ruby/gems/1.9.1/gems/knife-ec-backup-2.0.1/lib/chef/tsorter.rb:17:in each' from /opt/opscode/embedded/lib/ruby/gems/1.9.1/gems/knife-ec-backup-2.0.1/lib/chef/tsorter.rb:17:intsort_each_child'
from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:203:in each_strongly_connected_component_from' from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:182:inblock in each_strongly_connected_component'
from /opt/opscode/embedded/lib/ruby/gems/1.9.1/gems/knife-ec-backup-2.0.1/lib/chef/tsorter.rb:13:in each_key' from /opt/opscode/embedded/lib/ruby/gems/1.9.1/gems/knife-ec-backup-2.0.1/lib/chef/tsorter.rb:13:intsort_each_node'
from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:180:in each_strongly_connected_component' from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:148:intsort_each'
from /opt/opscode/embedded/lib/ruby/1.9.1/tsort.rb:135:in `tsort'

@stevendanna
Copy link
Contributor

@amolr I think it may be that you have a group which references a non-existent group. Can you check:

  1. In the organization where this failed, does groups/000000000000f5e4fe07d6a9c5953a09.json exist?
  2. What is the output of grep -r 000000000000f5e4fe07d6a9c5953a09 groups/*.json

@amolr
Copy link
Author

amolr commented Mar 25, 2015

Yes, I see that this json exists

@stevendanna
Copy link
Contributor

@amolr Would you mind sharing the contents of that file and the output of the second command I mentioned?

@amolr
Copy link
Author

amolr commented Mar 25, 2015

grep output
groups/users.json: "000000000000f5e4fe07d6a9c5953a09",

Content of the file 000000000000f5e4fe07d6a9c5953a09.json
{
"users": [
"xyz"
]
}

@amolr
Copy link
Author

amolr commented Mar 26, 2015

Any update on this?

@stevendanna
Copy link
Contributor

@amolr What server version and knife-ec-backup version created your backup data? The contents of 000000000000f5e4fe07d6a9c5953a09.json should include a "name" field like the following example:

{
  "name": "000000000000ba049827f07dff369cfe",
  "users": [
    "rapidfire"
  ]

@amolr
Copy link
Author

amolr commented Mar 26, 2015

I did a "cat chef-server-running.json" and it shows version 12.0.0
"hidden_services": [
"opscode-chef-mover"
],
"api_version": "12.0.0",

For knife-ec backup, I simply ran the gem install knife ec backup. I hope that should get the latest version

@stevendanna
Copy link
Contributor

@amolr So far, I haven't been able to find what resulted in your groups not having a "name" attribute. The following script should be able to help fix up your existing backup so that it can be uploaded:

#!/usr/bin/env ruby
require 'json'

Dir.glob("organizations/*/groups/*.json").each do |filename|
  j = JSON.parse(File.read(filename))
  j["name"] = File.basename(filename).sub(/\.json$/, '')
  File.write(filename, JSON.pretty_generate(j))
end

You can run this from the top level of your backup directory and it should rewrite your group files to have a name attribute everywhere.

@amolr
Copy link
Author

amolr commented Apr 14, 2015

Hey Steve,

Thanks for the hack. This worked however, after i restored with --with-user-sql option (have used this when doing the backup as well), I see that users are not able to login with their username, password. I also tried creating a new user and associating it with an organization. But still not able to login with that user. Any idea why this could be happening?

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

No branches or pull requests

2 participants