Torrent hash is same for every torrent after the first

Given a list of torrents:

default[:unattended][:driverpack][:torrents] = [
[“DP_Bluetooth_wnt5_x86-32_910.7z”,
“1bc4d487fae0c0b963e8f5a98778fe5ebd07ce403d0b6bc48f748a8363e0caaf”,
“DP_Bluetooth_wnt5_x86-32_910.torrent”,
http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent”],
[“DP_Chipset_wnt5_x86-32_1108.7z”,
“fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432”,
“DP_Chipset_wnt5_x86-32_1108.torrent”,
http://driverpacks.net/driverpacks/windows/xp/x86/chipset/11.08/download/torrent”],
( …and so on…)
]

I try to download them

node[‘unattended’][‘driverpack’][‘torrents’].each do
|driver_file,t_sha256,t_file,t_url|
local_torrent_file = "#{cache_dir}torrents/#{t_file}"
local_driver_file = “#{cache_dir}drivers/#{driver_file}”

remote_file local_torrent_file do
source t_url
backup false
mode "0755"
checksum t_sha256
end

transmission_torrent_file local_driver_file do
torrent local_torrent_file
continue_seeding true
rpc_username tuser
rpc_password tpass
action :create
end
end

However I get

DEBUG: transmission_torrent_file[anyfile] torrent hash =
4551e4bcfcd85ec04e0c28d5a151a0c1829fec19

for any of my torrent after the first one.

Anything obviously wrong with my approach?

[Mon, 29 Aug 2011 21:53:55 +1200] DEBUG: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
on breeze.local
[Mon, 29 Aug 2011 21:53:55 +1200] INFO: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
action create (unattended::default line 143)
[Mon, 29 Aug 2011 21:53:55 +1200] DEBUG:
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
checking for changes
[Mon, 29 Aug 2011 21:53:55 +1200] DEBUG: Sending HTTP Request via GET
to driverpacks.net:80/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Streaming download from
http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent
to tempfile /tmp/chef-rest20110829-19668-1u5n9nx-0
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG:
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
checking for file existence of
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG:
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
creating /var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
[Mon, 29 Aug 2011 21:53:57 +1200] INFO:
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
updated
[Mon, 29 Aug 2011 21:53:57 +1200] INFO:
remote_file[/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent]
mode changed to 755
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
on breeze.local
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
action create (unattended::default line 150)
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Caching a copy of torrent
file /var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:57 +1200] INFO:
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] created
file /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
[Mon, 29 Aug 2011 21:53:57 +1200] INFO:
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] mode
changed to 755
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Caching a copy of torrent
file /var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Setting
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] to the
state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG:
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Caching a copy of torrent
file /var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Setting
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] to the
state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
in swarm with name of ‘DP_Bluetooth_wnt5_x86-32_910.7z’ and status of
’SEED’
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]…100%
complete
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] on
breeze.local
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] on
breeze.local
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] on
breeze.local
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
on breeze.local
[Mon, 29 Aug 2011 21:53:57 +1200] INFO: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
action create (unattended::default line 143)
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG:
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checking for changes
[Mon, 29 Aug 2011 21:53:57 +1200] DEBUG: Sending HTTP Request via GET
to driverpacks.net:80/driverpacks/windows/xp/x86/chipset/11.08/download/torrent
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Streaming download from
http://driverpacks.net/driverpacks/windows/xp/x86/chipset/11.08/download/torrent
to tempfile /tmp/chef-rest20110829-19668-1g5saov-0
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG:
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checking for file existence of
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG:
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
creating /var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
[Mon, 29 Aug 2011 21:53:59 +1200] INFO:
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
updated
[Mon, 29 Aug 2011 21:53:59 +1200] INFO:
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
mode changed to 755
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
on breeze.local
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
action create (unattended::default line 150)
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Caching a copy of torrent
file /var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:59 +1200] INFO:
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] created file
/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
[Mon, 29 Aug 2011 21:53:59 +1200] INFO:
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] mode changed
to 755
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG:
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Caching a copy of torrent
file /var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Setting
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] to the state
of the prior file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
in swarm with name of ‘DP_Bluetooth_wnt5_x86-32_910.7z’ and status of
’SEED’
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]…100%
complete
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
[Mon, 29 Aug 2011 21:53:59 +1200] DEBUG: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_CPU_wnt5_x86-32_1005.torrent]
on breeze.local
[Mon, 29 Aug 2011 21:53:59 +1200] INFO: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_CPU_wnt5_x86-32_1005.torrent]
action create (unattended::default line 143)

The short of it

I’m forced to opscode transmission cookbook on local files as the
cookbook requires urls that end it .torrent. (Not that big of a deal,
but I’m unsure of a clean solution)
Every transmission_torrent_file[] after the first one, reports the
torrent hash of the first, keeping it from being loaded into
transmission.
I’m unsure how to debug or proceed.

Possibly useful background

The opscode transmission cookbook will only treat torrents as remote
files if the start with ‘http’ and end with ‘.torrent’.

The urls I have for the torrents I want to use don’t follow that logic:

However the driverpack urls do have the filename in the
Content-Disposition header.

To help decide the local target filename I decided parse the body/blob
of the torrent file to give us the name of the file that will result
from running the torrent:

  • resp.body.bdecode[“info”][“name”]

So I wrote a script to generate the the default attributes:

Which results in a somewhat readable dictionary.

That looks something like this:
default[:unattended][:driverpack][:torrents] = [
{:url=>“http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent”,
:sha256=>“1bc4d487fae0c0b963e8f5a98778fe5ebd07ce403d0b6bc48f748a8363e0caaf”,
:content_filename=>“DP_Bluetooth_wnt5_x86-32_910.7z”,
:torrent_filename=>“DP_Bluetooth_wnt5_x86-32_910.torrent”},
{:url=>“http://driverpacks.net/driverpacks/windows/xp/x86/chipset/11.08/download/torrent”,
:sha256=>“fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432”,
:content_filename=>“DP_Chipset_wnt5_x86-32_1108.7z”,
:torrent_filename=>“DP_Chipset_wnt5_x86-32_1108.torrent”}]

I updated the recipe to utilize the new array:

Now onto the meat of the matter:

I have debug logs of the relevant parts my chef run:

However when I do my chef-client run, the first torrent works fine:

DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent is about
to be hashed!
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
DEBUG: Setting file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
to the state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
DEBUG: Setting file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
to the state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent is about
to be hashed!
INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
in swarm with name of ‘DP_Bluetooth_wnt5_x86-32_910.7z’ and status of
’SEED’
DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]…100%
complete

CORE PROBLEM

We should be done with Bluetooth right? No every torrent after that

reports a torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19 and
doesn’t get loaded into transmission.

Begin processing DP_Chipset of the next torrent

DEBUG: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
on breeze.local
INFO: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
action create (unattended::default line 149)
DEBUG: remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checking for changes
DEBUG: remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checksum matches target checksum
(fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432) -
not updating
DEBUG: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
on breeze.local
INFO: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
action create (unattended::default line 156)
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent is about to
be hashed!
DEBUG: transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
DEBUG: Setting file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
to the state of the prior
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)

Note that we should be about to hash this local torrent torrent file:

DEBUG: /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent is about to
be hashed!

However it matches the DP_Bluetooth swarm!!!

INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
in swarm with name of ‘DP_Bluetooth_wnt5_x86-32_910.7z’ and status of
’SEED’

And it thinks we are done without even loading our torrent file into

transmission!!!

DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]…100%
complete

Still unsure why we have so many of these file processes

DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)

http://tickets.opscode.com/browse/COOK-729

https://github.com/opscode/cookbooks/blob/master/transmission/providers/torrent_file.rb#L117
is @@torrent_hash a global variable that never gets reset? YES!

Thanks to fujin for the help on Chef Infra (archive). Nice to know there are other
New Zealanders doing great things with chef.

Cheers,
-chris

On Tue, Aug 30, 2011 at 8:22 AM, Chris McClimans chef@hippiehacker.org wrote:

The short of it

I'm forced to opscode transmission cookbook on local files as the
cookbook requires urls that end it .torrent. (Not that big of a deal,
but I'm unsure of a clean solution)
Every transmission_torrent_file after the first one, reports the
torrent hash of the first, keeping it from being loaded into
transmission.
I'm unsure how to debug or proceed.

Possibly useful background

The opscode transmission cookbook will only treat torrents as remote
files if the start with 'http' and end with '.torrent'.

The urls I have for the torrents I want to use don't follow that logic:

However the driverpack urls do have the filename in the
Content-Disposition header.

To help decide the local target filename I decided parse the body/blob
of the torrent file to give us the name of the file that will result
from running the torrent:

  • resp.body.bdecode["info"]["name"]

So I wrote a script to generate the the default attributes:

Which results in a somewhat readable dictionary.

That looks something like this:
default[:unattended][:driverpack][:torrents] = [
{:url=>"http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent",
:sha256=>"1bc4d487fae0c0b963e8f5a98778fe5ebd07ce403d0b6bc48f748a8363e0caaf",
:content_filename=>"DP_Bluetooth_wnt5_x86-32_910.7z",
:torrent_filename=>"DP_Bluetooth_wnt5_x86-32_910.torrent"},
{:url=>"http://driverpacks.net/driverpacks/windows/xp/x86/chipset/11.08/download/torrent",
:sha256=>"fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432",
:content_filename=>"DP_Chipset_wnt5_x86-32_1108.7z",
:torrent_filename=>"DP_Chipset_wnt5_x86-32_1108.torrent"}]

I updated the recipe to utilize the new array:

Now onto the meat of the matter:

I have debug logs of the relevant parts my chef run:

However when I do my chef-client run, the first torrent works fine:

DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent is about
to be hashed!
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
DEBUG: Setting file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
to the state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
DEBUG: Setting file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
to the state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent is about
to be hashed!
INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
in swarm with name of 'DP_Bluetooth_wnt5_x86-32_910.7z' and status of
'SEED'
DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]...100%
complete

CORE PROBLEM

We should be done with Bluetooth right? No every torrent after that

reports a torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19 and
doesn't get loaded into transmission.

Begin processing DP_Chipset of the next torrent

DEBUG: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
on breeze.local
INFO: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
action create (unattended::default line 149)
DEBUG: remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checking for changes
DEBUG: remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checksum matches target checksum
(fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432) -
not updating
DEBUG: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
on breeze.local
INFO: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
action create (unattended::default line 156)
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent is about to
be hashed!
DEBUG: transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
DEBUG: Setting file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
to the state of the prior
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)

Note that we should be about to hash this local torrent torrent file:

DEBUG: /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent is about to
be hashed!

However it matches the DP_Bluetooth swarm!!!!!

INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
in swarm with name of 'DP_Bluetooth_wnt5_x86-32_910.7z' and status of
'SEED'

And it thinks we are done without even loading our torrent file into

transmission!!!!

DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]...100%
complete

Still unsure why we have so many of these file processes

DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)

Chris,
Great detective work hunting down that bug! Will try to get that fixed and pushed this week.

Seth

--
Opscode, Inc.
Seth Chisamore, Software Design Engineer
IRC, Skype, Twitter, Github: schisamo

On Aug 29, 2011, at 8:33 PM, Chris McClimans wrote:

http://tickets.opscode.com/browse/COOK-729

https://github.com/opscode/cookbooks/blob/master/transmission/providers/torrent_file.rb#L117
is @@torrent_hash a global variable that never gets reset? YES!

Thanks to fujin for the help on Chef Infra (archive). Nice to know there are other
New Zealanders doing great things with chef.

Cheers,
-chris

On Tue, Aug 30, 2011 at 8:22 AM, Chris McClimans chef@hippiehacker.org wrote:

The short of it

I'm forced to opscode transmission cookbook on local files as the
cookbook requires urls that end it .torrent. (Not that big of a deal,
but I'm unsure of a clean solution)
Every transmission_torrent_file after the first one, reports the
torrent hash of the first, keeping it from being loaded into
transmission.
I'm unsure how to debug or proceed.

Possibly useful background

The opscode transmission cookbook will only treat torrents as remote
files if the start with 'http' and end with '.torrent'.

The urls I have for the torrents I want to use don't follow that logic:

However the driverpack urls do have the filename in the
Content-Disposition header.

To help decide the local target filename I decided parse the body/blob
of the torrent file to give us the name of the file that will result
from running the torrent:

  • resp.body.bdecode["info"]["name"]

So I wrote a script to generate the the default attributes:

Which results in a somewhat readable dictionary.

That looks something like this:
default[:unattended][:driverpack][:torrents] = [
{:url=>"http://driverpacks.net/driverpacks/windows/xp/x86/bluetooth/9.10/download/torrent",
:sha256=>"1bc4d487fae0c0b963e8f5a98778fe5ebd07ce403d0b6bc48f748a8363e0caaf",
:content_filename=>"DP_Bluetooth_wnt5_x86-32_910.7z",
:torrent_filename=>"DP_Bluetooth_wnt5_x86-32_910.torrent"},
{:url=>"http://driverpacks.net/driverpacks/windows/xp/x86/chipset/11.08/download/torrent",
:sha256=>"fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432",
:content_filename=>"DP_Chipset_wnt5_x86-32_1108.7z",
:torrent_filename=>"DP_Chipset_wnt5_x86-32_1108.torrent"}]

I updated the recipe to utilize the new array:

Now onto the meat of the matter:

I have debug logs of the relevant parts my chef run:

However when I do my chef-client run, the first torrent works fine:

DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent is about
to be hashed!
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
DEBUG: Setting file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
to the state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Bluetooth_wnt5_x86-32_910.torrent
at /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent
DEBUG: Setting file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
to the state of the prior
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent]
INFO: Processing
file[/var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Bluetooth_wnt5_x86-32_910.torrent is about
to be hashed!
INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]
in swarm with name of 'DP_Bluetooth_wnt5_x86-32_910.7z' and status of
'SEED'
DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Bluetooth_wnt5_x86-32_910.7z]...100%
complete

CORE PROBLEM

We should be done with Bluetooth right? No every torrent after that

reports a torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19 and
doesn't get loaded into transmission.

Begin processing DP_Chipset of the next torrent

DEBUG: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
on breeze.local
INFO: Processing
remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
action create (unattended::default line 149)
DEBUG: remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checking for changes
DEBUG: remote_file[/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent]
checksum matches target checksum
(fcbcd23b21b29b36db2e5e7899b40757a3b40a006e3f837c6e7678a6477dc432) -
not updating
DEBUG: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
on breeze.local
INFO: Processing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
action create (unattended::default line 156)
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent is about to
be hashed!
DEBUG: transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
torrent hash = 4551e4bcfcd85ec04e0c28d5a151a0c1829fec19
DEBUG: Caching a copy of torrent file
/var/cache/chef/unattended/torrents/DP_Chipset_wnt5_x86-32_1108.torrent
at /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent
DEBUG: Setting file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
to the state of the prior
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent]
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)

Note that we should be about to hash this local torrent torrent file:

DEBUG: /var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent is about to
be hashed!

However it matches the DP_Bluetooth swarm!!!!!

INFO: Found existing
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]
in swarm with name of 'DP_Bluetooth_wnt5_x86-32_910.7z' and status of
'SEED'

And it thinks we are done without even loading our torrent file into

transmission!!!!

DEBUG: Downloading
transmission_torrent_file[/var/cache/chef/unattended/drivers/DP_Chipset_wnt5_x86-32_1108.7z]...100%
complete

Still unsure why we have so many of these file processes

DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)
DEBUG: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] on
breeze.local
INFO: Processing
file[/var/cache/chef/DP_Chipset_wnt5_x86-32_1108.torrent] action
create (/var/cache/chef/cookbooks/transmission/providers/torrent_file.rb
line 114)