Hi, Erik, can you provide more details about your setup? I tried this locally in an LXD container and was able to connect both from within the container and from the host using:
The relation/integration that is used for the old versions of the charm is: postgresql:db <-> nextcloud:db on the interface: postgresql
In Nextcloud metadata.yaml
requires:
db:
interface: pgsql
The new charm needs to move to a new relation to work with postgresql:
database:
interface: postgresql_client
limit: 1
I have a tricky situation now, since I can’t seem to re-deploy the old charm (revision 246) charm, since its no longer available in the store. Since I would like to reproduce the deployment, to test my migration process. This means I would need access to the old version of the charm postgresql.
I was reading through this and noticed that the link “The location of a charm library inside a charm” is to an archived page and inaccessible on the production docs.
The link should now be pointing to a subsection inside of the general “Library” explanation, which is here: Library
Another thing I noticed was that the postgresql-k8s charm itself required --trust to be deployed. I found this out by looking at the charm documentation and saw that the machine charm can be run without --trust but the k8s charm requires some changes to service accounts (maybe? or at least something with privileges).
I think what I found was that it would deploy, but end up at a “blocked” state. It wasn’t until I dived into the logs that I saw it trying to do things with service accounts and then I found the postgresql-k8s charm page itself (Charmhub | Deploy Charmed PostgreSQL K8s using Charmhub - The Open Operator Collection) had a --trust in its tutorial.
key is never used in the loop of the above code. If there is no reason to evaluate the key attribute we may want to make the code easier to understand, e.g. like this:
def fetch_postgres_relation_data(self) -> dict:
relations = self.database.fetch_relation_data()
logger.debug("Got following database data: %s", relations)
for data in relations.values():
if not data:
continue
logger.info("New PSQL database endpoint is %s", data["endpoints"])
...
def fetch_postgres_relation_data(self) -> dict:
"""Fetch postgres relation data.
This function retrieves relation data from a postgres database using
the `fetch_relation_data` method of the `database` object. The retrieved data is
then logged for debugging purposes, and any non-empty data is processed to extract
endpoint information, username, and password. This processed data is then returned as
a dictionary. If no data is retrieved, the unit is set to waiting status and
the program exits with a zero status code."""
relations = self.database.fetch_relation_data()
logger.debug("Got following database data: %s", relations)
for data in relations.values():
if not data:
continue
logger.info("New PSQL database endpoint is %s", data["endpoints"])
host, port = val["endpoints"].split(":")
db_data = {
"db_host": host,
"db_port": port,
"db_username": val["username"],
"db_password": val["password"],
}
return db_data
self.unit.status = WaitingStatus("Waiting for database relation")
raise SystemExit(0)
should be
def fetch_postgres_relation_data(self) -> dict:
"""Fetch postgres relation data.
This function retrieves relation data from a postgres database using
the `fetch_relation_data` method of the `database` object. The retrieved data is
then logged for debugging purposes, and any non-empty data is processed to extract
endpoint information, username, and password. This processed data is then returned as
a dictionary. If no data is retrieved, the unit is set to waiting status and
the program exits with a zero status code."""
relations = self.database.fetch_relation_data()
logger.debug("Got following database data: %s", relations)
for data in relations.values():
if not data:
continue
logger.info("New PSQL database endpoint is %s", data["endpoints"])
host, port = data["endpoints"].split(":")
db_data = {
"db_host": host,
"db_port": port,
"db_username": data["username"],
"db_password": data["password"],
}
return db_data
self.unit.status = WaitingStatus("Waiting for database relation")
raise SystemExit(0)
(Variable name val is not defined and should be data)
I already changed that in the doc post. Should I do a PR for the Github repo or directly pushing it to the branch?