Re: [Puppet Users] Re: notify resource different between 3 and 4?

2016-09-23 Thread Henrik Lindberg

On 20/09/16 15:54, R.I.Pienaar wrote:



- Original Message -

From: "jcbollinger" <john.bollin...@stjude.org>
To: "puppet-users" <puppet-users@googlegroups.com>
Sent: Tuesday, 20 September, 2016 15:37:21
Subject: Re: [Puppet Users] Re: notify resource different between 3 and 4?



On Monday, September 19, 2016 at 10:03:14 AM UTC-5, R.I. Pienaar wrote:




On 19 Sep 2016, at 15:31, jcbollinger <john.bo...@stjude.org >
wrote:
I see a difference between 3.8 and 4.6 with respect to the result of
interpolating an array into a string.  In Puppet 3 (and earlier) you get a
concatenation of the stringifications of all the elements, whereas in
Puppet 4, you get a more formatted representation.  I would have expected
such a change to be applied during a major version update -- so between 3.x
and 4.0 -- but a quick browse of the release notes does not appear to
mention it.

This is not a puppet behaviour change. Newer Ruby does nicer looking to_s
on arrays that's why






It was a deliberate change in how interpolation is done. Earlier it was 
unspecified and inconsistent. The change was introduced very early in 
the life cycle of "future parser", and I believe it was documented then.
When 4.0 was released, many of the language changes were not release 
noted. In some cases because it was impossible to define how it used to 
work :-). For this particular change, there should probably have been a 
note.



I'm prepared to believe that there's no Puppet code change, which would
explain why it's not documented in any release notes, but there's certainly
an observable behavior difference between the two example runs.  If that is
not to be accounted a Puppet behavior change then I suppose it must also be
observable with (only) Puppet 3.8 running on different Ruby versions.
That's a nice gotcha if you happen to rely on interpolating arrays (not
that I would recommend doing so in any case).


The recommendation is to be explicit about how arrays and hashes should 
be formatted if they are wanted in String form (Using either String.new 
with a suitable format, or using the join function).



yeah, and so you would I think, certainly recall people on IRC running into 
that.



On the other hand, I observe that the current (4.6) Puppet docs document
the array interpolation format
<https://docs.puppet.com/puppet/4.6/reference/lang_data_string.html#conversion-of-interpolated-values>,
independent of underlying Ruby.  That may now be a distinction without much
practical difference, but it's the right thing to do: details of the
infrastructure -- and especially changes to them -- ought not to leak out
into Puppet's user-facing behavior.  This sort of thing will become more
important as Puppet continues its movement away from Ruby as the main
implementation language.


yup, this becomes a specified and supported way to do this and you can probably
expect these to be properly treated in future.


Yes, now that it is specified it is part of the API.


There is additionally massive amount of string formatting stuff now in the 
language
https://github.com/puppetlabs/puppet-specifications/blob/master/language/types_values_variables.md

Though their usability leaves a lot to be desired, I suppose they are meant to 
be
used as plumbing for higher order solutions like wrapper functions or something,
I can't imagine anyone using them as is.

Yes, the more advanced formatting stuff is intended to be the basic 
building blocks for functions. The current support should be compared to 
Ruby's Kernel#format. The surface level functionality is easy to use 
though - for example things like String('%d', 42)





In any case, inasmuch as the OP was asking about behavioral differences, it
is highly relevant that the one observable difference of any significance
arises not because of a difference in the version of Puppet, but because of
a difference in the version of the Ruby underneath.


Yeah, expect less of that as work moves toward C based compilers etc, this
will make pinning every thing down to specified behaviour, good times.


Having the Puppet Language specification is key here.

- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ns3jbl%24pd2%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: notify resource different between 3 and 4?

2016-09-20 Thread R.I.Pienaar


- Original Message -
> From: "jcbollinger" <john.bollin...@stjude.org>
> To: "puppet-users" <puppet-users@googlegroups.com>
> Sent: Tuesday, 20 September, 2016 15:37:21
> Subject: Re: [Puppet Users] Re: notify resource different between 3 and 4?

> On Monday, September 19, 2016 at 10:03:14 AM UTC-5, R.I. Pienaar wrote:
>>
>>
>>
>> On 19 Sep 2016, at 15:31, jcbollinger <john.bo...@stjude.org >
>> wrote:
>> I see a difference between 3.8 and 4.6 with respect to the result of
>> interpolating an array into a string.  In Puppet 3 (and earlier) you get a
>> concatenation of the stringifications of all the elements, whereas in
>> Puppet 4, you get a more formatted representation.  I would have expected
>> such a change to be applied during a major version update -- so between 3.x
>> and 4.0 -- but a quick browse of the release notes does not appear to
>> mention it.
>>
>> This is not a puppet behaviour change. Newer Ruby does nicer looking to_s
>> on arrays that's why
>>
>>
> 
> I'm prepared to believe that there's no Puppet code change, which would
> explain why it's not documented in any release notes, but there's certainly
> an observable behavior difference between the two example runs.  If that is
> not to be accounted a Puppet behavior change then I suppose it must also be
> observable with (only) Puppet 3.8 running on different Ruby versions.
> That's a nice gotcha if you happen to rely on interpolating arrays (not
> that I would recommend doing so in any case).

yeah, and so you would I think, certainly recall people on IRC running into 
that.

> 
> On the other hand, I observe that the current (4.6) Puppet docs document
> the array interpolation format
> <https://docs.puppet.com/puppet/4.6/reference/lang_data_string.html#conversion-of-interpolated-values>,
> independent of underlying Ruby.  That may now be a distinction without much
> practical difference, but it's the right thing to do: details of the
> infrastructure -- and especially changes to them -- ought not to leak out
> into Puppet's user-facing behavior.  This sort of thing will become more
> important as Puppet continues its movement away from Ruby as the main
> implementation language.

yup, this becomes a specified and supported way to do this and you can probably
expect these to be properly treated in future.

There is additionally massive amount of string formatting stuff now in the 
language
https://github.com/puppetlabs/puppet-specifications/blob/master/language/types_values_variables.md

Though their usability leaves a lot to be desired, I suppose they are meant to 
be
used as plumbing for higher order solutions like wrapper functions or something,
I can't imagine anyone using them as is.


> In any case, inasmuch as the OP was asking about behavioral differences, it
> is highly relevant that the one observable difference of any significance
> arises not because of a difference in the version of Puppet, but because of
> a difference in the version of the Ruby underneath.

Yeah, expect less of that as work moves toward C based compilers etc, this
will make pinning every thing down to specified behaviour, good times.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/1120926933.445844.1474379654522.JavaMail.zimbra%40devco.net.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: notify resource different between 3 and 4?

2016-09-20 Thread jcbollinger


On Monday, September 19, 2016 at 10:03:14 AM UTC-5, R.I. Pienaar wrote:
>
>
>
> On 19 Sep 2016, at 15:31, jcbollinger  
> wrote:
> I see a difference between 3.8 and 4.6 with respect to the result of 
> interpolating an array into a string.  In Puppet 3 (and earlier) you get a 
> concatenation of the stringifications of all the elements, whereas in 
> Puppet 4, you get a more formatted representation.  I would have expected 
> such a change to be applied during a major version update -- so between 3.x 
> and 4.0 -- but a quick browse of the release notes does not appear to 
> mention it.
>
> This is not a puppet behaviour change. Newer Ruby does nicer looking to_s 
> on arrays that's why
>
>

I'm prepared to believe that there's no Puppet code change, which would 
explain why it's not documented in any release notes, but there's certainly 
an observable behavior difference between the two example runs.  If that is 
not to be accounted a Puppet behavior change then I suppose it must also be 
observable with (only) Puppet 3.8 running on different Ruby versions.  
That's a nice gotcha if you happen to rely on interpolating arrays (not 
that I would recommend doing so in any case).

On the other hand, I observe that the current (4.6) Puppet docs document 
the array interpolation format 
,
 
independent of underlying Ruby.  That may now be a distinction without much 
practical difference, but it's the right thing to do: details of the 
infrastructure -- and especially changes to them -- ought not to leak out 
into Puppet's user-facing behavior.  This sort of thing will become more 
important as Puppet continues its movement away from Ruby as the main 
implementation language.

In any case, inasmuch as the OP was asking about behavioral differences, it 
is highly relevant that the one observable difference of any significance 
arises not because of a difference in the version of Puppet, but because of 
a difference in the version of the Ruby underneath.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ed271976-8776-4dc1-bb71-166fd5db8e82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: notify resource different between 3 and 4?

2016-09-19 Thread R.I.Pienaar


> On 19 Sep 2016, at 15:31, jcbollinger  wrote:
> 
> 
> 
>> On Friday, September 16, 2016 at 12:11:26 PM UTC-5, Christopher Wood wrote:
>> While trying to figure out the reduce function with notice/notify I happened 
>> across this thing. It looks like an unquoted array in the notify resource's 
>> message only appears as its first array item. Not sure if it's a bug. 
>> 
>> I couldn't find any documentation to say if this was intended and I couldn't 
>> really tell what the type was doing with the self.should bit. I am not 
>> actually a programmer. 
>> 
>> $ cat /tmp/xx.pp 
>> $array = ["one", "two", "three"] 
>> 
>> notify { 'notify one': 
>>   message => "${array}", 
>> } 
>> 
>> notify { 'notify two': 
>>   message => $array, 
>> } 
>> 
>> With puppet 3 I see this: 
>> 
>> $ puppet --version 
>> 3.8.7 
>> $ puppet apply /tmp/xx.pp 
>> Fact file /etc/facter/facts.d/monit_fail_count was parsed but returned an 
>> empty data set 
>> Fact file /etc/facter/facts.d/monit_fail_count was parsed but returned an 
>> empty data set 
>> Notice: Compiled catalog for mail82c40.carrierzone.com in environment 
>> production in 0.03 seconds 
>> Notice: one 
>> Notice: /Stage[main]/Main/Notify[notify two]/message: defined 'message' as 
>> 'one' 
>> Notice: onetwothree 
>> Notice: /Stage[main]/Main/Notify[notify one]/message: defined 'message' as 
>> 'onetwothree' 
>> Notice: Finished catalog run in 0.05 seconds 
>> 
>> With puppet 4 I see this: 
>> 
>> $ puppet --version 
>> 4.6.2 
>> $ puppet apply /tmp/xx.pp 
>> Notice: Compiled catalog for cwl.hostopia.com in environment production in 
>> 0.09 seconds 
>> Notice: [one, two, three] 
>> Notice: /Stage[main]/Main/Notify[notify one]/message: defined 'message' as 
>> '[one, two, three]' 
>> Notice: one 
>> Notice: /Stage[main]/Main/Notify[notify two]/message: defined 'message' as 
>> 'one' 
>> Notice: Applied catalog in 0.11 seconds 
> 
> 
> I see a difference between 3.8 and 4.6 with respect to the result of 
> interpolating an array into a string.  In Puppet 3 (and earlier) you get a 
> concatenation of the stringifications of all the elements, whereas in Puppet 
> 4, you get a more formatted representation.  I would have expected such a 
> change to be applied during a major version update -- so between 3.x and 4.0 
> -- but a quick browse of the release notes does not appear to mention it.

This is not a puppet behaviour change. Newer Ruby does nicer looking to_s on 
arrays that's why


> 
> You called out the unquoted array being bound to the 'message' parameter of 
> the second Notify, but that seems to have exactly the same behavior in the 
> two Puppet outputs you present.  In both cases, the message is taken as the 
> first element of the array.  As R.I. observed, you should not bind an array 
> to a parameter that expects a string.  Given that you did so, I think Puppet 
> handled the situation in a reasonable way.  I'm uncertain whether that 
> behavior is documented.
> 
> 
> John
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/eadea0df-b342-47b9-a3e3-daa981d128b7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/E14BBDEE-2291-45BD-96BB-0D3D06AD3E21%40devco.net.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: notify resource different between 3 and 4?

2016-09-19 Thread jcbollinger


On Friday, September 16, 2016 at 12:11:26 PM UTC-5, Christopher Wood wrote:
>
> While trying to figure out the reduce function with notice/notify I 
> happened across this thing. It looks like an unquoted array in the notify 
> resource's message only appears as its first array item. Not sure if it's a 
> bug. 
>
> I couldn't find any documentation to say if this was intended and I 
> couldn't really tell what the type was doing with the self.should bit. I am 
> not actually a programmer. 
>
> $ cat /tmp/xx.pp 
> $array = ["one", "two", "three"] 
>
> notify { 'notify one': 
>   message => "${array}", 
> } 
>
> notify { 'notify two': 
>   message => $array, 
> } 
>
> With puppet 3 I see this: 
>
> $ puppet --version 
> 3.8.7 
> $ puppet apply /tmp/xx.pp 
> Fact file /etc/facter/facts.d/monit_fail_count was parsed but returned an 
> empty data set 
> Fact file /etc/facter/facts.d/monit_fail_count was parsed but returned an 
> empty data set 
> Notice: Compiled catalog for mail82c40.carrierzone.com in environment 
> production in 0.03 seconds 
> Notice: one 
> Notice: /Stage[main]/Main/Notify[notify two]/message: defined 'message' as 
> 'one' 
> Notice: onetwothree 
> Notice: /Stage[main]/Main/Notify[notify one]/message: defined 'message' as 
> 'onetwothree' 
> Notice: Finished catalog run in 0.05 seconds 
>
> With puppet 4 I see this: 
>
> $ puppet --version 
> 4.6.2 
> $ puppet apply /tmp/xx.pp 
> Notice: Compiled catalog for cwl.hostopia.com in environment production 
> in 0.09 seconds 
> Notice: [one, two, three] 
> Notice: /Stage[main]/Main/Notify[notify one]/message: defined 'message' as 
> '[one, two, three]' 
> Notice: one 
> Notice: /Stage[main]/Main/Notify[notify two]/message: defined 'message' as 
> 'one' 
> Notice: Applied catalog in 0.11 seconds 
>


I see a difference between 3.8 and 4.6 with respect to the result of 
interpolating an array into a string.  In Puppet 3 (and earlier) you get a 
concatenation of the stringifications of all the elements, whereas in 
Puppet 4, you get a more formatted representation.  I would have expected 
such a change to be applied during a major version update -- so between 3.x 
and 4.0 -- but a quick browse of the release notes does not appear to 
mention it.

You called out the unquoted array being bound to the 'message' parameter of 
the second Notify, but that seems to have exactly the same behavior in the 
two Puppet outputs you present.  In both cases, the message is taken as the 
first element of the array.  As R.I. observed, you should not bind an array 
to a parameter that expects a string.  Given that you did so, I think 
Puppet handled the situation in a reasonable way.  I'm uncertain whether 
that behavior is documented.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/eadea0df-b342-47b9-a3e3-daa981d128b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.