Bug 854773 - [as7] Unable to enable datasource on creation
[as7] Unable to enable datasource on creation
Status: CLOSED CURRENTRELEASE
Product: JBoss Operations Network
Classification: JBoss
Component: Plugin -- JBoss EAP 6 (Show other bugs)
JON 3.1.0
All All
medium Severity high
: ER07
: JON 3.2.0
Assigned To: Thomas Segismont
Mike Foley
:
Depends On: 854774
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-05 19:38 EDT by Larry O'Leary
Modified: 2014-10-23 09:41 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 854774 (view as bug list)
Environment:
Last Closed: 2014-01-02 15:35:31 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Larry O'Leary 2012-09-05 19:38:01 EDT
Description of problem:
Newly created datasources do not honor the "Enabled" configuration option when it is set to "Yes". The result is that a user can create a new datasource but the datasource is not enabled in the EAP server.

Version-Release number of selected component (if applicable):
3.1.0

How reproducible:
Always

Steps to Reproduce:
1.  Import standalone EAP 6 server into JON inventory
2.  Navigate to the *datasources* node of the newly imported EAP 6 standalone server (i.e. *JBossAS7 Standalone Servers / EAP (127.0.0.1:9990) / datasources*)
3.  Select its *Inventory > Child Resources* tab
4.  Click *Create Child -> DataSource (Standalone)*
5.  Enter a name (i.e. TestDS) and click *Next*
6.  Set the following properties and click *Finish*

        *Connection Url*:   `jdbc:h2:mem:test;DB_CLOSE_DELAY=-1`
        *Driver Name*:      `h2`
        *Jndi Name*:        `java:jboss/datasources/TestDS`
        *User Name*:        `sa`
        *Password*:         `sa`
        *Enabled*:          *Yes*

7.  Click *Refresh* and wait for TestDS to appear in datasources *Inventory > Child Resources* tab
8.  Select newly created *TestDS* resource
9.  Select its *Configuration > Current* tab
  
Actual results:
Enabled configuration property is set to `false`

Expected results:
Enabled configuration property should be `true`

Additional info:
To enable the datasource, the user must use the EAP 6 Management Console as this configuration option is read-only in JON 3.1.0 due to Bug 847119.
Comment 1 mark yarborough 2012-11-06 15:05:07 EST
Per 3.1.2 triage with loleary, mfoley, ccrouch, asantos: Okay to move to JON 3.2.
Comment 2 Charles Crouch 2013-05-28 11:56:56 EDT
Note: Bug 847119 is now fixed.

So the main issue is that the Enabled property doesn't appear to be getting through to the EAP instance itself. Is this just at creation time or also post creation while using the configuration screen?
Comment 4 Thomas Segismont 2013-05-30 08:38:53 EDT
I've tested different configurations with AS7.1.1, EAP6.0, EAP6.1

'enabled' is an attribute which came with EAP 6.0 (AS7.1.1 does not have it). And it's read-only.

The only way to enable a datasource from JON is to use the 'enable' operation. This is available in AS7.1.1, EAP 6.0 and EAP 6.1.

If you set the 'enabled' attribute when creating a datasource (default is unset), the attribute will be sent to AS7/EAP but it won't be taken into account. AS7.1.1 and EAP6.0 will create the datasource in disabled state. EAP6.1 will create the datasource in enabled state.

I see two paths for improvement:
* update the GUI which at the moment lets you edit a read-only configuration field (what's a read-only configuration field?) ; downside is some plugins may rely on this somewhat buggy behavior
* update the org.rhq.modules.plugins.jbossas7.DatasourceComponent#createResource to make it send the 'enable' operation if needed (because when you create a Datasource you want it enabled I guess)

Feedback appreciated
Comment 5 Larry O'Leary 2013-05-30 10:42:11 EDT
(In reply to Thomas Segismont from comment #4)
> I've tested different configurations with AS7.1.1, EAP6.0, EAP6.1
> 
> 'enabled' is an attribute which came with EAP 6.0 (AS7.1.1 does not have
> it). And it's read-only.

This isn't completely clear to me. If it is not there in AS7.1.1 does that mean it should be removed from the resource configuration page? How are you to tell if it is enabled or disabled?

> The only way to enable a datasource from JON is to use the 'enable'
> operation. This is available in AS7.1.1, EAP 6.0 and EAP 6.1.
>
> If you set the 'enabled' attribute when creating a datasource (default is
> unset), the attribute will be sent to AS7/EAP but it won't be taken into
> account. AS7.1.1 and EAP6.0 will create the datasource in disabled state.
> EAP6.1 will create the datasource in enabled state.

Is this what EAP is doing when I create a datasource in EAP? For example, in the following I can see that enabled is a property of a newly created datasource:

/subsystem=datasources/xa-data-source="java:jboss/datasources/MySqlXADS":add(jndi-name="java:jboss/datasources/MySqlXADS",pool-name="MySQLXA_Pool",enabled=true,xa-data-source-properties = {"ServerName"=>"localhost","DatabaseName"=>"devtest","User"=>"test"},driver-name="mysql")

Is this not the case?
 
> I see two paths for improvement:
> * update the GUI which at the moment lets you edit a read-only configuration
> field (what's a read-only configuration field?) ; downside is some plugins
> may rely on this somewhat buggy behavior

If we are going to leave this configuration property on the configuration page it should be configurable. There should be no such thing as "read-only" configuration. Such information should be exposed as a trait in my opinion. It makes no sense to have non-configuration on a configuration page. 

That being said, it is possible to expose this as a read/write configuration. We would need to handle this value explicitly in the plug-in itself. If the value changes, the underlying operation is invoked and the result of that operation should determine the new value of the configuration property.

> * update the
> org.rhq.modules.plugins.jbossas7.DatasourceComponent#createResource to make
> it send the 'enable' operation if needed (because when you create a
> Datasource you want it enabled I guess)

At minimum, if we can't get EAP to accept the value of enabled, we need to explicitly invoke the operation based on the value the user specified.

In the end, this second path is a requirement if we can't get the enabled property to be honored with the datasource definition being sent to the EAP server. The fact that we are exposing non-configuration as configuration -- the first path -- is just an error in implementation and needs to also be addressed but is not the root of this BZ. It was only highlighted as that was the next logical place a user would go to when they realized their enabled datasource didn't get enabled. i.e.

  #. Create datasource and set it to enabled
  #. Realize datasource isn't available to my application
  #. Review datasource configuration in JBoss ON UI and notice enabled is set to false
  #. Attempt to update enabled to true but I can't because it is read-only
  #. This thing is completely broken!
Comment 6 Thomas Segismont 2013-05-31 10:44:53 EDT
(In reply to Larry O'Leary from comment #5)
> (In reply to Thomas Segismont from comment #4)
> > I've tested different configurations with AS7.1.1, EAP6.0, EAP6.1
> > 
> > 'enabled' is an attribute which came with EAP 6.0 (AS7.1.1 does not have
> > it). And it's read-only.
> 
> This isn't completely clear to me. If it is not there in AS7.1.1 does that
> mean it should be removed from the resource configuration page? How are you
> to tell if it is enabled or disabled?
> 

No it shouldn't be removed. It's the only way we have to know if a datasource is enabled in EAP6.0 and EAP6.1

Unfortunately with AS7.1.1 we have no way to show in RHQ if a datasource is enabled.

> > The only way to enable a datasource from JON is to use the 'enable'
> > operation. This is available in AS7.1.1, EAP 6.0 and EAP 6.1.
> >
> > If you set the 'enabled' attribute when creating a datasource (default is
> > unset), the attribute will be sent to AS7/EAP but it won't be taken into
> > account. AS7.1.1 and EAP6.0 will create the datasource in disabled state.
> > EAP6.1 will create the datasource in enabled state.
> 
> Is this what EAP is doing when I create a datasource in EAP? For example, in
> the following I can see that enabled is a property of a newly created
> datasource:
> 
> /subsystem=datasources/xa-data-source="java:jboss/datasources/MySqlXADS":
> add(jndi-name="java:jboss/datasources/MySqlXADS",pool-name="MySQLXA_Pool",
> enabled=true,xa-data-source-properties =
> {"ServerName"=>"localhost","DatabaseName"=>"devtest","User"=>"test"},driver-
> name="mysql")
> 
> Is this not the case?
>  

Yes that's also the behavior of the admin console. There is no 'enabled' attribute in their form. In EAP6.0, datasource are created disabled by default, in EAP6.1 enabled by default.

> > I see two paths for improvement:
> > * update the GUI which at the moment lets you edit a read-only configuration
> > field (what's a read-only configuration field?) ; downside is some plugins
> > may rely on this somewhat buggy behavior
> 
> If we are going to leave this configuration property on the configuration
> page it should be configurable. There should be no such thing as "read-only"
> configuration. Such information should be exposed as a trait in my opinion.
> It makes no sense to have non-configuration on a configuration page. 
> 
> That being said, it is possible to expose this as a read/write
> configuration. We would need to handle this value explicitly in the plug-in
> itself. If the value changes, the underlying operation is invoked and the
> result of that operation should determine the new value of the configuration
> property.
> 
> > * update the
> > org.rhq.modules.plugins.jbossas7.DatasourceComponent#createResource to make
> > it send the 'enable' operation if needed (because when you create a
> > Datasource you want it enabled I guess)
> 
> At minimum, if we can't get EAP to accept the value of enabled, we need to
> explicitly invoke the operation based on the value the user specified.
> 
> In the end, this second path is a requirement if we can't get the enabled
> property to be honored with the datasource definition being sent to the EAP
> server. The fact that we are exposing non-configuration as configuration --
> the first path -- is just an error in implementation and needs to also be
> addressed but is not the root of this BZ. It was only highlighted as that
> was the next logical place a user would go to when they realized their
> enabled datasource didn't get enabled. i.e.
> 
>   #. Create datasource and set it to enabled
>   #. Realize datasource isn't available to my application
>   #. Review datasource configuration in JBoss ON UI and notice enabled is
> set to false
>   #. Attempt to update enabled to true but I can't because it is read-only
>   #. This thing is completely broken!

I will update the plugin to make the property read/write. And the resource creation will take the value of the property into account. I will work with EAP 6.0 and 6.1. Not with AS7.1.1
Comment 7 Larry O'Leary 2013-05-31 13:28:52 EDT
(In reply to Thomas Segismont from comment #6)
> > This isn't completely clear to me. If it is not there in AS7.1.1 does that
> > mean it should be removed from the resource configuration page? How are you
> > to tell if it is enabled or disabled?
> > 
> 
> No it shouldn't be removed. It's the only way we have to know if a
> datasource is enabled in EAP6.0 and EAP6.1
> 
> Unfortunately with AS7.1.1 we have no way to show in RHQ if a datasource is
> enabled.

It was not clear to the lineage of EAP 6.x to AS 7. If EAP 6+ exposes the enabled attribute then it doesn't matter. However, the only stuff that should ever be on the configuration tab is stuff that can be configured from that page. So, if it is to remain there, it really needs to be read/write and if setting a new value doesn't actually change this in EAP then we need to invoke the enable datasource operation under the covers in JBoss ON when the user changes this value. 

> > Is this what EAP is doing when I create a datasource in EAP? For example, in
> > the following I can see that enabled is a property of a newly created
> > datasource:
> > 
> > /subsystem=datasources/xa-data-source="java:jboss/datasources/MySqlXADS":
> > add(jndi-name="java:jboss/datasources/MySqlXADS",pool-name="MySQLXA_Pool",
> > enabled=true,xa-data-source-properties =
> > {"ServerName"=>"localhost","DatabaseName"=>"devtest","User"=>"test"},driver-
> > name="mysql")
> > 
> > Is this not the case?
> >  
> 
> Yes that's also the behavior of the admin console. There is no 'enabled'
> attribute in their form. In EAP6.0, datasource are created disabled by
> default, in EAP6.1 enabled by default.

So the root of my question was if it honors the enabled attribute as part of the 'add' operation. If it does then I would expect that to me setting "enabled" to true or false would take care of its default state without needing to invoke the operation separately.

 
> I will update the plugin to make the property read/write. And the resource
> creation will take the value of the property into account. I will work with
> EAP 6.0 and 6.1. Not with AS7.1.1

This may actually answer all my questions above. Basically, once you are done:

 * I will be able to update the enabled value from the resource configuration page and it will actually enable/disable the datasource resource as expected.
 * I will be able to use the enable operation to enable or disable the datasource and the value in the configuration page will reflect the new state.
 * When creating a new datasource, I can set enabled to true or false and have it correctly reflected upon deployment to the profile.

If I am missing something here please let me know. I understand that this may not be the case for AS 7.1.1 but I am assuming that is an old version and I am only looking at this from an EAP 6.x perspective.
Comment 8 Thomas Segismont 2013-06-03 04:32:28 EDT
I was wrong about as7.1.1 and datasources enabled attribute. It does expose the attribute, but not after creation. When the datasource is first enabled the attribute is set.
Comment 9 Thomas Segismont 2013-06-04 10:23:40 EDT
commit 861dc16aae70c3dbbeed47342ad425b063d4e977
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Tue Jun 4 16:19:09 2013 +0200

    Bug 854773 - [as7] Unable to enable datasource on creation
    
    Plugin descriptor:
    * 'enabled' property is now read-write (in RHQ, not in the server management model)
    * fixed resource types where 'background-validation-minutes' attribute was still present instead of 'background-validation-millis'
    
    DatasourceComponent:
    * modified #createResource and #updateResourceConfiguration: now they read the 'enabled attribute at the end of the process and execute the 'enable' or 'disabled' operation as needed
    * modified #loadResourceConfiguration because AS7 does not give a value to the 'enable' attribute when the datasource was just created
    * work around for 'allow-multiple-users' attribute which is only present on EAP servers
Comment 10 Thomas Segismont 2013-06-04 12:03:35 EDT
The issues are fixed in the RHQ plugin code. But EAP6.1 has a bug with the 'disable' operation on Datasource and XADatasource in both standalone and domain mode:
https://bugzilla.redhat.com/show_bug.cgi?id=970679

A new BZ to track the EAP6.1 issue has been created:
https://bugzilla.redhat.com/show_bug.cgi?id=970699
Comment 11 Larry O'Leary 2013-09-06 10:32:09 EDT
As this is MODIFIED or ON_QA, setting milestone to ER1.
Comment 12 Libor Zoubek 2013-11-06 12:18:10 EST
Reassigning to Thomas:

Main goal of this BZ was verified. I was able to create datasource either enabled or disabled (by selecting it when created).

But once I tried Disable enabled datasource via it's configuration, it failed with: 
"You must disable the datasource before editing its configuration"

at the same time .. enabling/disabling datasource is still available via datasource operations. I'd vote for removing it, having it as configuration makes more sense, especially when diabling/enabling requires server reload, and that's being announced only on Configuration page.
Comment 13 Larry O'Leary 2013-11-06 12:25:09 EST
(In reply to Libor Zoubek from comment #12)
> at the same time .. enabling/disabling datasource is still available via
> datasource operations. I'd vote for removing it, having it as configuration
> makes more sense, especially when diabling/enabling requires server reload,
> and that's being announced only on Configuration page.

I agree. However, note that disabling/enabling the datasource should not require a server reload. That would be a bug in itself.
Comment 14 Thomas Segismont 2013-11-07 08:50:48 EST
This is a regression caused by the fix for BZ999976
Comment 17 Thomas Segismont 2013-11-07 11:51:03 EST
Fixed in master

commit 2abf17c8d2d4796c05f78b5e479ed9f1bb5bf0bc
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Thu Nov 7 17:49:17 2013 +0100

When the datasource is enabled, allow modification if the configuration supplied by the user sets the 'enabled' attribute to false.
    
Changed the way community servers are managed as AS7 has no 'enabled' attribute in its management model.
Comment 18 Thomas Segismont 2013-11-07 11:53:22 EST
Cherry-picked to release/jon3.2.x

commit 5fe5765b9dcd48d5d9e18282546dd3f058ca2fe3
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Thu Nov 7 17:49:17 2013 +0100
Comment 19 Simeon Pinder 2013-11-19 10:47:42 EST
Moving to ON_QA as available for testing with new brew build.
Comment 20 Simeon Pinder 2013-11-22 00:13:16 EST
Mass moving all of these from ER6 to target milestone ER07 since the ER6 build was bad and QE was halted for the same reason.
Comment 21 Filip Brychta 2013-12-02 12:15:06 EST
Verified on
Version :	
3.2.0.ER7
Build Number :	
e8e6401:ff0061d

I verified following things on EAP6.0 and EAP6.1:
 * I will be able to update the enabled value from the resource configuration page and it will actually enable/disable the datasource resource as expected.
 * I will be able to use the enable operation to enable or disable the datasource and the value in the configuration page will reflect the new state.
 * When creating a new datasource, I can set enabled to true or false and have it correctly reflected upon deployment to the profile.
 
I filed a bz 1036787 to track the requirement to call a reload operation when disabling/enabling datasource. 

Asking Larry what to do with Libor's suggestion from comment 12

Note You need to log in before you can comment on or make changes to this bug.