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

Datasource always change state, if there is a number in it. #97

Closed
lasse-kristensen opened this issue Dec 18, 2015 · 10 comments · Fixed by #109
Closed

Datasource always change state, if there is a number in it. #97

lasse-kristensen opened this issue Dec 18, 2015 · 10 comments · Fixed by #109
Labels

Comments

@lasse-kristensen
Copy link

I've made a wildfly datasource, where some config keys have number in.
'min-pool-size' => 1,
'max-pool-size' => 10,
It configure it right, but every puppet run it tells me that state changed.
/state: state changed '{"max-pool-size"=>10, "min-pool-size"=>1}' to '{"min-pool-size"=>"1", "max-pool-size"=>"10"}'

@lasse-kristensen lasse-kristensen changed the title Datasource always state change, if there is a number in it. Datasource always change state, if there is a number in it. Dec 18, 2015
@BobVincentatNCRdotcom
Copy link
Contributor

Try alphabetizing your keys.

@lasse-kristensen
Copy link
Author

It makes no difference.
My ruby skills is very limited,but in wildfly/lib/puppet/type/wildfly_resource.rb there is a to_s method which would "" quote numbers.
Could this be why the state changes?

@lasse-kristensen
Copy link
Author

Here is some debug info:
Debug: /Stage[main]/Profile::Wildfly/Wildfly::Datasources::Datasource[dupDS]/Wildfly::Util::Resource[/subsystem=datasources/data-source=dupDS]/Wildfly_resource[/subsystem=datasources/data-source=dupDS]/state: Should: {"connection-url"=>"jdbc:oracle:thin:@ks-oracle02:1521:PREPR", "min-pool-size"=>"1", "driver-name"=>"oracle", "password"=>"pwd", "max-pool-size"=>"10", "jndi-name"=>"java:/jdbc/dupDS", "user-name"=>"DUP"} Is: {"connection-url"=>"jdbc:oracle:thin:@ks-oracle02:1521:PREPR", "driver-name"=>"oracle", "jndi-name"=>"java:/jdbc/dupDS", "max-pool-size"=>10, "min-pool-size"=>1, "password"=>"pwd", "user-name"=>"DUP"}

I have currently "fixed" this by adding this, to the "insync?" method.

       is.each do |k,v|
        if ( v.is_a? Integer )
          is[k]=v.to_s
        end
      end

@cfrantsen
Copy link
Contributor

I have encountered the same problem, INT/LONG values in "should" are quoted but the "is" values are not, resulting in insync always returning false.

This is not a datasource only problem, it happens on any resource where you try to and enforce state that includes INT/LONG values using the wildfly_resource type.

@jairojunior
Copy link
Collaborator

I'll investigate this tonight. Could you (@icetrain @lasse-kristensen) provide more information about your environment? (Ruby version, Puppet version, module version and etc)

@lasse-kristensen
Copy link
Author

Hey
ruby --version: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
puppet --version: 3.8.4
The module version is: 0.4.0
Running on: CentOS Linux release 7.1.1503 (Core)

@cfrantsen
Copy link
Contributor

ruby --version: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
puppet --version: 3.7.5
The module version is: 0.5.1
Running on: Red Hat Enterprise Linux Server release 7.1 (Maipo)
WildFly: 9.0.1

@jairojunior
Copy link
Collaborator

Fact: Puppet custom types checks current state (Is) against desirable state (Should).

Wildfly HTTP API returns a JSON representation of a resource (Is) and if one its properties is a number, a number is returned.

User provides a Hash representation (Should) of a resource in any form, but generally a string representation.

If the user provided a string representation of a number property, this issue will happen.

e.g.

wildfly::datasources::datasource { 'DemoDS':
  config         => {
    'driver-name' => 'postgresql',
    'connection-url' => 'jdbc:postgresql://localhost/postgres',
    'jndi-name' => 'java:jboss/datasources/DemoDS',
    'user-name' => 'postgres',
    'password' => 'postgres',
    'min-pool-size' => "10",
    'max-pool-size' => "30",
  }
}

instead of:

wildfly::datasources::datasource { 'DemoDS':
  config         => {
    'driver-name' => 'postgresql',
    'connection-url' => 'jdbc:postgresql://localhost/postgres',
    'jndi-name' => 'java:jboss/datasources/DemoDS',
    'user-name' => 'postgres',
    'password' => 'postgres',
    'min-pool-size' => 10,
    'max-pool-size' => 30,
  }
}

I changed custom type to ignore types (convert everything to strings), but if you change number properties to number literals you'll might get the same outcome.

mpeter added a commit to mpeter/biemond-wildfly that referenced this issue Jan 10, 2016
* upstream:
  Support any service name in RHEL7 based distros.
  Fix issue voxpupuli#102. Manage interfaces using augeas for versions < 8.2.1.
  Fix issue voxpupuli#97. Convert everything to string before state verification.
  Fix issue voxpupuli#101. Add wildfly.service file in RHEL7 base OSs.
@bjwschaap
Copy link
Contributor

Please re-open this issue. This 'fix' breaks recursive resources!!!
I will provide an alternative pull-request, that combines this issue with #108

jairojunior added a commit that referenced this issue Jan 11, 2016
martinbalint added a commit to martinbalint/biemond-wildfly that referenced this issue Feb 15, 2016
@jairojunior
Copy link
Collaborator

It's back, at least for booleans: state changed '{"value"=>"false"}' to '{"value"=>false}'

@jairojunior jairojunior reopened this Apr 27, 2016
jairojunior added a commit that referenced this issue May 16, 2016
Another fix for #97, stringify true/false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants