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

Azure Applications: datasource config fails silently #154

Comments

@edburns
Copy link
Collaborator

edburns commented Aug 13, 2020

Testing of the database integration reveals that if the datasource config fails, the template still succeeds. This is not correct. If the datasource config fails, the template should fail.

I think the problem may lie in this method in the datasource config script:

function createJDBCSource_model()
{
echo "Creating JDBC data source with name $jdbcDataSourceName"
cat <<EOF >create_datasource.py
connect('$wlsUserName','$wlsPassword','t3://$wlsAdminURL')
edit("$hostName")
startEdit()
cd('/')
try:
  cmo.createJDBCSystemResource('$jdbcDataSourceName')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName')
  cmo.setName('$jdbcDataSourceName')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName/JDBCDataSourceParams/$jdbcDataSourceName')
  set('JNDINames',jarray.array([String('$jdbcDataSourceName')], String))
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName')
  cmo.setDatasourceType('GENERIC')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName/JDBCDriverParams/$jdbcDataSourceName')
  cmo.setUrl('$dsConnectionURL')
  cmo.setDriverName('org.postgresql.Driver')
  cmo.setPassword('$dsPassword')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName/JDBCConnectionPoolParams/$jdbcDataSourceName')
  cmo.setTestTableName('SQL ISVALID\r\n\r\n\r\n\r\n')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName/JDBCDriverParams/$jdbcDataSourceName/Properties/$jdbcDataSourceName')
  cmo.createProperty('user')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName/JDBCDriverParams/$jdbcDataSourceName/Properties/$jdbcDataSourceName/Properties/user')
  cmo.setValue('$dsUser')
  cd('/JDBCSystemResources/$jdbcDataSourceName/JDBCResource/$jdbcDataSourceName/JDBCDataSourceParams/$jdbcDataSourceName')
  cmo.setGlobalTransactionsProtocol('EmulateTwoPhaseCommit')
  cd('/JDBCSystemResources/$jdbcDataSourceName')
  set('Targets',jarray.array([ObjectName('com.bea:Name=$wlsClusterName,Type=Cluster')], ObjectName))
  save()
  resolve()
  activate()
except Exception, e:
  print "Already datasource with name $jdbcDataSourceName exists"
destroyEditSession("$hostName",force = true)
disconnect()
EOF
}
@galiacheng
Copy link
Collaborator

galiacheng commented Oct 21, 2020

We should remove the data source name for failure deployment, to avoid error:

weblogic.descriptor.BeanAlreadyExistsException: Bean already exists: "weblogic.j2ee.descriptor.wl.JDBCPropertyBeanImpl@2899c76a([jdbc/testsqldb1]/JDBCDriverParams/Properties/Properties[user])"

Besides, the error also happens in case:
Reproduce steps:

  • Create database with name "jdbc/javaee1022" successfully with template.
  • Remove the database manually successfully from Admin Console -> Services -> Data Sources
  • Remove vm extension by running az cli command
  • Re-deploy DB template with the same name via az cli command
# az cli command to remove the vm extension
az vm extension delete -g ${your-resource-group} --vm-name adminVM --name newuserscript
# az cli command to set up oracle db
az group deployment create --verbose --resource-group ${your-resource-group} --parameters @oracleparameters.json --template-uri https://raw.githubusercontent.com/wls-eng/arm-oraclelinux-wls-admin/2020-09-10-01-Q3/src/main/arm/nestedtemplates/dbTemplate.json

The data source name was not listed in Admin Console and /u01/domains/domain_name/config/jdbc. But stopped later deployment running with the same data source name.

@sanjaymantoor
Copy link
Collaborator

sanjaymantoor commented Oct 21, 2020

You can try code like below . If datasource config fails then rollback the changes and raise exception.
except Exception, e:
e.printStackTrace()
dumpStack()
undo('true',defaultAnswer='y')
cancelEdit('y')
destroyEditSession("$hostName",force = true)
raise("$jdbcDataSourceName configuration failed")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants