ddev / ddev-platformsh

Add integration with Platform.sh hosting service
Apache License 2.0
9 stars 10 forks source link

Improper mapping of relationships - blog.blackfire.io database for example #38

Closed rfay closed 1 year ago

rfay commented 1 year ago

Testing out blog.blackfire.io I see that config.platformsh.yaml ends up with

database:
  type: mysql
  version: 10.2

which is obviously impossible, so the mapping here isn't being done right. .platform.app.yaml has

relationships:
    database: "mysqldb:mysql"
    cache: "memcached:memcached"

and services.yaml has

mysqldb:
    type: mysql:10.2
    disk: 2048

That should work. In relationships lines, the left part of the pair (mysqldb) in this case is free form and should be joined to the item of the same name in services.yaml

rfay commented 1 year ago

@lolautruche so in

relationships:
    database: "mysqldb:mysql"
    cache: "memcached:memcached"

the right-hand side of mysqldb:mysql or memcached:memcached is meaningless right? So all we care about, for example, with the database line here in .platform.app.yaml is the join value (mysqldb, which joins to the services .yaml stanza) and the right-hand side mysql is meaningless?

rfay commented 1 year ago

Oh,

# The left-hand side is the name of the relationship as it will be exposed
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.

But I guess I don't know what <endpoint name> means, can you enlighten me?

rfay commented 1 year ago

Oh, the problem in this issue is not this, I don't think.

It's that I didn't remember that mysql:10.2 actually means mariadb:10.2.

lolautruche commented 1 year ago

@rfay The doc states the following:

The endpoint_name is the exposed functionality of the service to use. For most services, the endpoint is the same as the service type. For some services (such as MariaDB and Solr), you can define additional explicit endpoints for multiple databases and cores in the service’s configuration.

So it's only relevant to a few services like MariaDB, which can define several endpoints (multiple databases).

rfay commented 1 year ago

Ah, so "endpoint" means "name of database" then? So we probably need to not use the endpoint name often given here (in this example "mysql") and instead use (by default) the name of ddev's default database, "db", when creating PLATFORM_RELATIONSHIPS? Or of course, add logic which will create databases of the endpoint/database name provided. That's probably the most robust thing in the end. Perhaps a post-start hook could create the databases.

lolautruche commented 1 year ago

It actually means more "name of the server".

rfay commented 1 year ago

If it means "name of the server" then where would the name of the database be? Or is server name == db name in Platformsh-land?

lolautruche commented 1 year ago

You would define this in the services.yaml (see the configuration for MariaDB/MySQL), on at the relationship level. By default, the DB name is main and referred as path in the $PLATFORM_RELATIONSHIPS JSON.