delgod/mongodb-k8s-operator

Unable to create database

Closed this issue · 1 comments

Bug Description

I'm trying to figure out how to integrate a charm with mongodb-k8s, so I've modified an existing charm to do this, by following the documentation instructions on https://charmhub.io/data-platform-libs/libraries/database_requires. However, when I relate my charm to the mongodb-k8s charm, the database isn't created and so no DatabaseCreatedEvent is triggered and there's no connection information over the relation.

It's possible I'm doing something wrong in my charm implmentation. Any feedback on that appreciated.

To Reproduce

  1. git clone -b mongodb-relation https://github.com/mthaddon/gunicorn-k8s-operator
  2. cd gunicorn-k8s-operator
  3. charmcraft pack
  4. juju deploy gunicorn-k8s_ubuntu-20.04-amd64.charm --resource gunicorn-image='gunicorncharmers/gunicorn-app:edge'
  5. git clone https://github.com/delgod/mongodb-k8s-operator
  6. cd mongdb-k8s-operator
  7. charmcraft pack
  8. juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=mongo:4.4
  9. juju relate mongodb-k8s gunicorn-k8s
  10. Wait for relation to settle
  11. View juju debug-log as well as juju show-unit output, see that there's no database been created in mongodb microk8s kubectl exec -ti -n g-test -c mongod mongodb-k8s-0 -- /bin/bash; mongo; show dbs.

Environment

I'm using microk8s 1.25, juju 2.9.34

Relevant log output

Please see https://paste.ubuntu.com/p/hQYMvpnHV9/

Additional context

N/A

fixed in #32

NB: please use the following command to check if credentials work correctly

microk8s kubectl exec -n testing mongodb-k8s-0 -c mongod -it -- mongo "$(juju show-unit gunicorn-k8s/0 | grep uris | awk '{print$2}')" --eval 'db.inventory.insertOne({item: "canvas"}); db.adminCommand({listDatabases: 1})'

The reason behind: it is needed to push one document into the database before show dbs will show it.