Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
FACT 3.1.4
-
None
-
Windows 8, 64bit, with AIO puppet agent 1.3.5
-
2
-
Client 2016-04-20, Client 2016-05-04
-
Bug Fix
-
This fix corrects a bug in facter preventing it from properly serializing integers exceeding the 32bit boundary.
Description
I'm writing a custom fact that uses sys/filesystem to serialize the mount table:
require 'sys/filesystem' |
include Sys
|
|
Facter.add("mounts") do |
setcode do |
begin |
hash = {}
|
Filesystem.mounts do |mount| |
mount_hash = {};
|
mount_hash['name'] = mount.name; |
mount_hash['type'] = mount.mount_type; |
mount_hash['options'] = mount.options; |
stat = Filesystem.stat(mount.mount_point);
|
mount_hash['block_size'] = stat.block_size; |
mount_hash['blocks_available'] = stat.blocks_available; |
mount_hash['blocks_free'] = stat.blocks_free; |
mount_hash['blocks_used'] = mount_hash['blocks_available'] - mount_hash['blocks_free']; |
|
mount_hash['bytes_available'] = mount_hash['blocks_available'] * mount_hash['block_size']; |
mount_hash['bytes_free'] = (mount_hash['blocks_free'] * mount_hash['block_size']).to_s; |
mount_hash['bytes_used'] = (mount_hash['blocks_used'] * mount_hash['block_size']).to_s; |
mount_hash['percent_used'] = mount_hash['blocks_used'].to_f / mount_hash['blocks_available']; |
mount_hash['percent_free'] = mount_hash['blocks_free'].to_f / mount_hash['blocks_available']; |
hash[mount.mount_point] = mount_hash;
|
end |
hash
|
rescue |
nil |
end |
end |
end |
On windows systems, however, the bytes_* variables are larger then a 32bit integer, and the fact returns invalid data:
{
|
C:\ => {
|
name => "\Device\HarddiskVolume4",
|
type => "NTFS",
|
options => "casepres,casesens,compression,namedstreams,pacls,encryption,obj
|
ds,rpoints,sparse,unicode",
|
block_size => 4096,
|
blocks_available => 62379263,
|
blocks_free => 29046694,
|
blocks_used => 33332569,
|
bytes_available => ,
|
bytes_free => "118975258624",
|
bytes_used => "136530202624",
|
percent_used => 0.534353,
|
percent_free => 0.465647
|
}
|
}
|
As you can see, bytes_available returns nothing, while bytes_free (which has been to_s''d) returns the proper values. The integers are BigNums as they should be, and using puts ruby returns the correct numbers in all cases.
I couldn't reproduce this on rhel7 so I'm assuming it's a bug in the windows facter agent