Skip to content

Datasource binging in VCAP_SERVICES result in multiple DataSourcesΒ #103

Open
@dietzsch

Description

@dietzsch

So far we are using the Spring Cloud Connector with a datasource in VCAP_SERVICES like this:

  "oracle-mysql": [
    {
      "label": "oracle-mysql",
      "provider": null,
      "plan": "production",
      "name": "vmaasBrokerMySql",
      "tags": [
        "database",
        "mysql"
      ],
      "instance_name": "vmaasBrokerMySql",
      "binding_name": null,
      "credentials": {
        "hostname": "xx.xx.xx.xx",
        "password": "password",
        "readonly": false,
        "port": 38010,
        "dbschema-name": "db_name",
        "uri": "mysql://username:[email protected]:38010/db_name?connectTimeout=20000&useSSL=true&verifyServerCertificate=false",
        "username": "username"
      },
      "syslog_drain_url": null,
      "volume_mounts": []
    }
  ]

With Spring Cloud Connector this has worked the way that one DataSource was returned by the CloudConfig. When we try to switch to java-cfenv this doesn't work any more as the datasource binding end up with two datasources, one based on the label and one based on the name. At the end we receive an exception as below:

2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.IllegalArgumentException: No unique database service found. Found database service names [vmaasBrokerMySql, vmaasBrokerMySql]
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.throwExceptionIfMultipleMatches(CfJdbcUrlCreator.java:97)
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.findJdbcService(CfJdbcUrlCreator.java:87)
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcEnv.findJdbcService(CfJdbcEnv.java:46)

From my perspective either the first datasource created should be returned (then it would need a order which defines the preference) or the decision is not made based on name/labels, but the URI itself, as this would clearly distinguish between Oracle and MySQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions