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

Handling of integer values causes puppet to always apply properties #71

Open
sbraz opened this issue Feb 7, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@sbraz
Copy link
Contributor

sbraz commented Feb 7, 2024

Describe the Bug

Hi,
Because of the way ZFS properties can be passed and are returned by the zfs get commands, Puppet applies properties even though they already have the correct values, e.g.

quota changed '4.88T' to '5000G' (corrective)`
reservation changed '6T' to '6597069766656' (corrective)

Expected Behavior

When the values match, the module should detect it and not attempt to set them again.

Steps to Reproduce

  1. Set a quota of 5000G
  2. Set a reservation of 6597069766656

Environment

  • Version 8.4.0
  • Platform Debian 12

Additional Context

I thought of the following patch:

diff --git a/lib/puppet/provider/zfs/zfs.rb b/lib/puppet/provider/zfs/zfs.rb
index 976d9bf..b97ec0c 100644
--- a/lib/puppet/provider/zfs/zfs.rb
+++ b/lib/puppet/provider/zfs/zfs.rb
@@ -82,7 +82,7 @@ Puppet::Type.type(:zfs).provide(:zfs) do
    :secondarycache, :setuid, :sharenfs, :sharesmb,
    :snapdir, :sync, :version, :volsize, :vscan, :xattr].each do |field|
     define_method(field) do
-      zfs(:get, '-H', '-o', 'value', field, @resource[:name]).strip
+      zfs(:get, '-p', '-H', '-o', 'value', field, @resource[:name]).strip
     end
 
     define_method(field.to_s + '=') do |should|

It would prevent issues when the Puppet configuration uses exact values:
But it doesn't help when we pass Puppet human-readable values, e.g.

quota changed '5368709120000' to '5000G' (corrective)

Maybe the solution would be to:

  • apply the above patch
  • convert human-readable values to exact values before applying them
@sbraz sbraz added the bug Something isn't working label Feb 7, 2024
@joshcooper
Copy link
Contributor

The munge method needs to implemented for properties whose values can take multiple forms. That way the desired and current values are canonicalized before being compared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants