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

knife tarsnap ending in ERROR: TypeError: can't convert nil into String #12

Closed
cescalante opened this issue Sep 14, 2013 · 9 comments
Closed

Comments

@cescalante
Copy link

ERROR: TypeError: can't convert nil into String

Appreciate everything that you've done but I'm having some issues getting rolling. I can't seem to get any of the knife functions to perform. They all end with that same error. I couldn't get it to create a key, show backup etc etc.

Here is output with -VVV

knife tarsnap backup show sql.beyond9.co -VVV
DEBUG: Signing the request as tidrion
DEBUG: Sending HTTP Request via GET to api.opscode.com:443/organizations/beyond9/data/tarsnap_keys/sql_beyond9_co
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: server: ngx_openresty
DEBUG: date: Sat, 14 Sep 2013 00:32:38 GMT
DEBUG: content-type: application/json
DEBUG: transfer-encoding: chunked
DEBUG: connection: close
DEBUG: x-ops-api-info: flavor=hec;version=11.0.0;oc_erchef=0.21.26
DEBUG: content-encoding: gzip
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: decompressing gzip response
ERROR: TypeError: can't convert nil into String

Knife username is in .chef/knife.rb I even manually created the data bag for that server manually and put the key in there after I generated it manually on the server. Any help is greatly appreciated.

@ghost
Copy link

ghost commented Sep 14, 2013

It appears the error is coming from a missing value in your databag. Can you double check you have your databag setup correct? See https://github.com/jssjr/chef-tarsnap#tarsnap-keys for the required setup.

I wonder if /root/tarsnap.key exists? Since you didn't have the databag created on the first run, it may be possible the key was created but the databag entry was never saved to chef server.

@cescalante
Copy link
Author

{
"id": "sql_beyond9_co",
"node": "sql.beyond9.co",
"key": "# START OF TARSNAP KEY FILE\ndGFyc25hc(REDACTED)"
}

^^ is the databag file, the tarsnap.key file exists and tarsnap runs great on the server, just fails from knife with that error.

Appreciate your help.

@cescalante
Copy link
Author

Also want to mention:

knife tarsnap key list
status node
registered sql.beyond9.co

Shows it as registered, originally was pending.

@ghost
Copy link

ghost commented Sep 14, 2013

I haven't been able to reproduce this. Do other knife tarsnap commands work? For example knife tarsnap key list or knife tarsnap key show node? I'm not sure if the readme actually states this, but you need a copy of tarsnap on the machine you are running knife. Sorry if none of this of any help, but that error doesn't give me a lot to go on.

@ghost
Copy link

ghost commented Sep 14, 2013

Oh looks like you answered my main question while I was replying. Let me sleep on this, I'll get back to you tomorrow.

@cescalante
Copy link
Author

Get sleep, I'm digging too, knife is a nice add on, just glad I've got an automatic tarsnap backup on the server. Here is the output from show node

knife tarsnap key show sql.beyond9.co
ERROR: TypeError: can't convert nil into String

and obligatory show node -VVV

$ knife tarsnap key show sql.beyond9.co -VVV
DEBUG: Signing the request as tidrion
DEBUG: Sending HTTP Request via GET to api.opscode.com:443/organizations/beyond9/data/tarsnap_keys/sql_beyond9_co
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: server: ngx_openresty
DEBUG: date: Sat, 14 Sep 2013 04:06:21 GMT
DEBUG: content-type: application/json
DEBUG: transfer-encoding: chunked
DEBUG: connection: close
DEBUG: x-ops-api-info: flavor=hec;version=11.0.0;oc_erchef=0.21.26
DEBUG: content-encoding: gzip
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: decompressing gzip response
ERROR: TypeError: can't convert nil into String

@ghost
Copy link

ghost commented Sep 14, 2013

OK, that narrowed down the issue for me. For whatever reason it isn't able to fetch the key from the databag.

Take a look here https://github.com/jssjr/chef-tarsnap/blob/master/knife-tarsnap/lib/chef/knife/tarsnap/core.rb#L118

If you run knife data bag show tarsnap_keys sql_beyond9_co do you see the key? If That doesn't work check I have guessed the correct name by looking at knife data bag show tarsnap_keys

Off to bed now, hope that will lead you down the right path at least. Please let me know if you find anything out.

@cescalante
Copy link
Author

Got it! Really sorry mate, this ended up having nothing to do with your script. I didn't realize I had some additional setup I needed to do for encrypted data bags. I generated a secret file and then set that in the knife.rb file. Then I copied that secret file out to the server to /etc/chef/encrypted_data_bag_secret after that everything clicked and on a new instance for testing I got:

$ knife tarsnap backup show sqld.beyond9.co
mysql-db-201309140530UTC-daily
mysql-db-201309140530UTC-monthly
mysql-db-201309140530UTC-weekly

Thanks for all your efforts. Sorry I led us down a rabbit hole.

@ghost
Copy link

ghost commented Sep 14, 2013

Glad you got it. In the future if you have a line like this in your knife.rb

encrypted_data_bag_secret "#{current_dir}/databag.key"

When you do a knife bootstrap the secret key is automatically copied over.

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

1 participant