config-get returns scientific notation for large ints

Bug #1302118 reported by Matt Bruzek
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
High
Wayne Witzel III
1.25
Fix Released
High
Ian Booth

Bug Description

I was writing a new charm and I found an interesting problem.

When I put a large int value in config.yaml (30000000) and read this value in config-changed with config-get it returned the scientific notation of that number 3e+07.

This result was unexpected and very hard to deal with the number in a bash script. I was trying to do some math with "bc" which does not recognize this format of scientific notation.

I have included a skeleton charm that shows this. Deploy the charm and watch the unit logs it will echo the value from the config-changed hook.

Please let me know if you need any more information.

Tags: config oil
Revision history for this message
Matt Bruzek (mbruzek) wrote :
Revision history for this message
Curtis Hovey (sinzui) wrote :

This might be an issue with goyaml.

Changed in juju-core:
status: New → Triaged
importance: Undecided → High
tags: added: config
Revision history for this message
Dave Cheney (dave-cheney) wrote : Re: [Bug 1302118] Re: config-get returns scientific notation for large ints

Hmm, interesting.

unit-test-0: 2014-04-04 03:05:33 DEBUG juju.worker.logger logger.go:45
reconfiguring logging from "<root>=DEBUG" to
"<root>=WARNING;unit=DEBUG"
unit-test-0: 2014-04-04 03:05:34 INFO config-changed 3e+07

Yet when I add a test case to the output_test.go tests in cmd/ it passes ... hmm

On Fri, Apr 4, 2014 at 6:03 AM, Curtis Hovey <email address hidden> wrote:
> This might be an issue with goyaml.
>
> ** Changed in: juju-core
> Status: New => Triaged
>
> ** Changed in: juju-core
> Importance: Undecided => High
>
> ** Tags added: config
>
> --
> You received this bug notification because you are subscribed to juju-
> core.
> Matching subscriptions: MOAR JUJU SPAM!
> https://bugs.launchpad.net/bugs/1302118
>
> Title:
> config-get returns scientific notation for large ints
>
> Status in juju-core:
> Triaged
>
> Bug description:
> I was writing a new charm and I found an interesting problem.
>
> When I put a large int value in config.yaml (30000000) and read this
> value in config-changed with config-get it returned the scientific
> notation of that number 3e+07.
>
> This result was unexpected and very hard to deal with the number in a
> bash script. I was trying to do some math with "bc" which does not
> recognize this format of scientific notation.
>
> I have included a skeleton charm that shows this. Deploy the charm
> and watch the unit logs it will echo the value from the config-changed
> hook.
>
> Please let me know if you need any more information.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju-core/+bug/1302118/+subscriptions

Revision history for this message
Dave Cheney (dave-cheney) wrote :

Hmm, even more interesting

lucky(~/src/launchpad.net/juju-core) % juju run --unit test/0
'config-get --format=yaml -a'
int-option: 3e+07
lucky(~/src/launchpad.net/juju-core) % juju run --unit test/0
'config-get --format=smart -a'
int-option: 3e+07
lucky(~/src/launchpad.net/juju-core) % juju run --unit test/0
'config-get --format=json -a'
{"int-option":3e+07}

On Fri, Apr 4, 2014 at 2:06 PM, David Cheney <email address hidden> wrote:
> Hmm, interesting.
>
> unit-test-0: 2014-04-04 03:05:33 DEBUG juju.worker.logger logger.go:45
> reconfiguring logging from "<root>=DEBUG" to
> "<root>=WARNING;unit=DEBUG"
> unit-test-0: 2014-04-04 03:05:34 INFO config-changed 3e+07
>
> Yet when I add a test case to the output_test.go tests in cmd/ it passes ... hmm
>
> On Fri, Apr 4, 2014 at 6:03 AM, Curtis Hovey <email address hidden> wrote:
>> This might be an issue with goyaml.
>>
>> ** Changed in: juju-core
>> Status: New => Triaged
>>
>> ** Changed in: juju-core
>> Importance: Undecided => High
>>
>> ** Tags added: config
>>
>> --
>> You received this bug notification because you are subscribed to juju-
>> core.
>> Matching subscriptions: MOAR JUJU SPAM!
>> https://bugs.launchpad.net/bugs/1302118
>>
>> Title:
>> config-get returns scientific notation for large ints
>>
>> Status in juju-core:
>> Triaged
>>
>> Bug description:
>> I was writing a new charm and I found an interesting problem.
>>
>> When I put a large int value in config.yaml (30000000) and read this
>> value in config-changed with config-get it returned the scientific
>> notation of that number 3e+07.
>>
>> This result was unexpected and very hard to deal with the number in a
>> bash script. I was trying to do some math with "bc" which does not
>> recognize this format of scientific notation.
>>
>> I have included a skeleton charm that shows this. Deploy the charm
>> and watch the unit logs it will echo the value from the config-changed
>> hook.
>>
>> Please let me know if you need any more information.
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/juju-core/+bug/1302118/+subscriptions

Curtis Hovey (sinzui)
Changed in juju-core:
importance: High → Medium
Revision history for this message
Curtis Hovey (sinzui) wrote :

Actions also experience this problem. This looks like an under lying library that doesn't like number above 1,000,000.

Curtis Hovey (sinzui)
tags: added: oil
Revision history for this message
Nate Finch (natefinch) wrote :

note, a quick test with goyaml shows it does the right thing. Must be somewhere else turning it into a float.

Revision history for this message
Dave Cheney (dave-cheney) wrote :

The default output format for config-get is json, that number is being
eaten by JSON's terrible handling of integers.

On Fri, Jun 12, 2015 at 6:59 AM, Nate Finch <email address hidden> wrote:
> note, a quick test with goyaml shows it does the right thing. Must be
> somewhere else turning it into a float.
>
> --
> You received this bug notification because you are subscribed to juju-
> core.
> Matching subscriptions: MOAR JUJU SPAM!
> https://bugs.launchpad.net/bugs/1302118
>
> Title:
> config-get returns scientific notation for large ints
>
> Status in goyaml:
> New
> Status in juju-core:
> Triaged
>
> Bug description:
> I was writing a new charm and I found an interesting problem.
>
> When I put a large int value in config.yaml (30000000) and read this
> value in config-changed with config-get it returned the scientific
> notation of that number 3e+07.
>
> This result was unexpected and very hard to deal with the number in a
> bash script. I was trying to do some math with "bc" which does not
> recognize this format of scientific notation.
>
> I have included a skeleton charm that shows this. Deploy the charm
> and watch the unit logs it will echo the value from the config-changed
> hook.
>
> Please let me know if you need any more information.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/goyaml/+bug/1302118/+subscriptions

Revision history for this message
Adam Israel (aisrael) wrote :

This also affects values passed in the CLI, i.e.:

$ juju action do mysql-benchmark/0 oltp table-size=1000000 num-threads=5

Changed in juju-core:
importance: Medium → High
Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

Not sure if this is the "right" fix, but have a patch for juju/cmd that I believe resolves this issue.

    https://github.com/wwitzel3/cmd/commit/50da537d06272412b73abc6f169daa61a4e40c7f

Adam, if you want to build a juju from source using this juju/cmd package and try your tests, that would be greatly appreciated.

Changed in juju-core:
assignee: nobody → Wayne Witzel III (wwitzel3)
status: Triaged → In Progress
Curtis Hovey (sinzui)
Changed in juju-core:
milestone: none → 1.26-alpha1
Ian Booth (wallyworld)
Changed in juju-core:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
Changed in juju-core:
status: Fix Committed → Fix Released
no longer affects: goyaml
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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