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

Insync? not invoked for Puppet::Property::Boolean #9542

Open
h-haaks opened this issue Jan 28, 2025 · 2 comments
Open

Insync? not invoked for Puppet::Property::Boolean #9542

h-haaks opened this issue Jan 28, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@h-haaks
Copy link

h-haaks commented Jan 28, 2025

Describe the Bug

I have a custom type with a boolean property defined as

newproperty(:myprop, parent: Puppet::Property::Boolean) do
end

On puppet run when 'is' value is true and 'should' value is false, the insync? is never invoked and puppet does not change the value of the property!

I think the problem is here https://github.com/puppetlabs/puppet/blob/main/lib/puppet/property.rb#L274
When @should is false at this point safe_insync? never invoke insync?

Expected Behavior

I would expect puppet to change the value from true to false

@h-haaks h-haaks added the bug Something isn't working label Jan 28, 2025
@h-haaks
Copy link
Author

h-haaks commented Jan 28, 2025

I'm not sure, but would this fix be enough?
return true if @should.nil?

@joshcooper
Copy link
Contributor

This is https://perforce.atlassian.net/browse/PUP-2368 for properties and https://perforce.atlassian.net/browse/PUP-8442 for parameters. We tried to fix parameters before and caused a regression in the vcs module which caused repos to be forceable deleted, so the fix needs to be opt-in.

There are likely several places where puppet conflates false and nil such as the transaction, resource_harness and events/reports.

The workaround is to use symbols :true :false as described in https://dev.to/betadots/the-ruby-side-of-puppet-part-3-custom-types-and-providers-4hma

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