Problem with empty string parameter not behaving as expected on puppet4.

Bug #1680081 reported by Sofer Athlan-Guyot
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
puppet-vswitch
Fix Released
Medium
Unassigned

Bug Description

Hi,

puppet4 changed the semantic of the empty string.

With puppet3 empty sting meant false, with puppet4 it means true[1]

So now the semantic of this test[2] are false. If you look at [3] then puppet4 will happily creates the parameter:

    "--socket-mem ''"

while puppet3 won't as empty string is false.

Same on [4].

There are some places where this has been taken care of [5] for instance.

The !empty should be added everywhere to make sure we have the same behavior for empty string in puppet3 and in puppet4.

As it happen only when user explicitly passes empty string as parameter, I'm setting this as medium priority, as this behavior is not the "normal" one.

[1] https://docs.puppet.com/puppet/4.9/lang_updating_manifests.html#empty-strings-in-boolean-context-are-true

[2] https://github.com/openstack/puppet-vswitch/blob/master/spec/classes/vswitch_dpdk_spec.rb#L72-L78

[3] https://github.com/openstack/puppet-vswitch/blob/master/manifests/dpdk.pp#L63-L65
[4] https://github.com/openstack/puppet-vswitch/blob/master/manifests/dpdk.pp#L69
[5] https://github.com/openstack/puppet-vswitch/blob/master/manifests/dpdk.pp#L87

Revision history for this message
Takashi Kajinami (kajinamit) wrote :

I assume this was fixed by https://review.opendev.org/c/openstack/puppet-vswitch/+/432165 .
Please feel free to reopen this in case you still hit the same problem with a recent version.

Changed in puppet-vswitch:
status: Confirmed → Fix Released
Revision history for this message
Takashi Kajinami (kajinamit) wrote :

[vagrant@localhost ~]$ rpm -q puppet
puppet-7.16.0-1.el9s.noarch
[vagrant@localhost ~]$ rpm -q puppet-vswitch
puppet-vswitch-16.3.1-0.20220620192418.c3babed.el9.noarch
[vagrant@localhost ~]$ cat test.pp
vs_config { 'other_config:foo':
  ensure => present,
  value => '',
  wait => true
}
[vagrant@localhost ~]$ sudo puppet apply test.pp --modulepath /usr/share/openstack-puppet/modules/
Notice: Compiled catalog for localhost.localdomain in environment production in 0.02 seconds
Notice: /Stage[main]/Main/Vs_config[other_config:foo]/ensure: created
Notice: Applied catalog in 0.06 seconds
[vagrant@localhost ~]$ sudo ovs-vsctl get Open_vSwitch . other_config
{}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.