canonical / mongodb-operator

Charmed solution for MongoDB
Apache License 2.0
11 stars 14 forks source link

Juju 2.9 not supported #372

Closed cbartz closed 5 months ago

cbartz commented 5 months ago

Steps to reproduce

Use juju 2.9.46

  1. juju deploy mongodb --channel=6/beta (or 6/edge)
  2. juju status

Expected behavior

The app goes in active status. Non-support for juju 2.9 is nowhere mentioned, so I expect the charm to support it.

Actual behavior

The app goes into error state with the message hook failed: "install" . The reason seems to be that juju 2.9 does not support secrets (see log output below).

╰─$ juju status                                                                                                                                                                                                                                                              130 ↵
Model  Controller  Cloud/Region         Version  SLA          Timestamp
mongo  lxd         localhost/localhost  2.9.46   unsupported  08:58:17+01:00

App      Version  Status  Scale  Charm    Channel  Rev  Exposed  Message
mongodb           error       1  mongodb  6/beta   149  no       hook failed: "install"

Unit        Workload  Agent  Machine  Public address  Ports  Message
mongodb/0*  error     idle   0        10.51.120.118          hook failed: "install"

Machine  State    Address        Inst id        Series  AZ  Message
0        started  10.51.120.118  juju-f31241-0  jammy       Running

Versions

Operating system: Ubuntu 22.04.4 LTS

Juju CLI: 2.9.46-ubuntu-amd64

Juju agent: 2.9.46

Charm revision: 149 and 154

LXD: 5.0.3

Log output

Juju debug log:

unit-mongodb-0: 08:54:40 ERROR unit.mongodb/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-mongodb-0/charm/./src/charm.py", line 1431, in <module>
    main(MongodbOperatorCharm)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/main.py", line 441, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/main.py", line 149, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/framework.py", line 344, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/framework.py", line 833, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/framework.py", line 922, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/./src/charm.py", line 327, in _on_install
    config=self.mongodb_config,
  File "/var/lib/juju/agents/unit-mongodb-0/charm/./src/charm.py", line 217, in mongodb_config
    return self._get_mongodb_config_for_user(OperatorUser, set(self._unit_ips))
  File "/var/lib/juju/agents/unit-mongodb-0/charm/./src/charm.py", line 778, in _get_mongodb_config_for_user
    external_ca, _ = self.tls.get_tls_files(UNIT_SCOPE)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/lib/charms/mongodb/v0/mongodb_tls.py", line 271, in get_tls_files
    if not self.is_tls_enabled(scope):
  File "/var/lib/juju/agents/unit-mongodb-0/charm/lib/charms/mongodb/v0/mongodb_tls.py", line 73, in is_tls_enabled
    return self.charm.get_secret(scope, Config.TLS.SECRET_CERT_LABEL) is not None
  File "/var/lib/juju/agents/unit-mongodb-0/charm/./src/charm.py", line 1139, in get_secret
    secret = self.secrets.get(label)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/lib/charms/mongodb/v0/mongodb_secrets.py", line 136, in get
    if secret.meta:
  File "/var/lib/juju/agents/unit-mongodb-0/charm/lib/charms/mongodb/v0/mongodb_secrets.py", line 84, in meta
    self._secret_meta = self.charm.model.get_secret(label=self.label)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/model.py", line 269, in get_secret
    content = self._backend.secret_get(id=id, label=label)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/model.py", line 3049, in secret_get
    result = self._run('secret-get', *args, return_output=True, use_json=True)
  File "/var/lib/juju/agents/unit-mongodb-0/charm/venv/ops/model.py", line 2686, in _run
    raise RuntimeError(f'command not found: {args[0]}')
RuntimeError: command not found: secret-get
unit-mongodb-0: 08:54:41 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1
unit-mongodb-0: 08:54:41 INFO juju.worker.uniter awaiting error resolution for "install" hook

Additional context

github-actions[bot] commented 5 months ago

https://warthogs.atlassian.net/browse/DPE-3801

MiaAltieri commented 5 months ago

Hi @cbartz Thanks for your issue. Only 5/edge supports Juju 2.9 and we plan to drop support to 5/edge very soon.

Please use Juju 3 :)

I will create a JIRA ticket to update the docs to mention that we only support 3+ on Charmed MongoDB6. Thank you very much for helping us improve our documentation :)

cbartz commented 5 months ago

@MiaAltieri Thank you for this information. Are cross-model relations with a mongodb_client consumer from a juju 2.9 model supported?

I see secret-related information in the databag

╰─$ juju show-unit data-integrator/0  
data-integrator/0:
  opened-ports: []
  charm: ch:amd64/jammy/data-integrator-21
  leader: true
  life: alive
  relation-info:
  - relation-id: 21
    endpoint: data-integrator-peers
    related-endpoint: data-integrator-peers
    application-data:
      mongodb: ACTIVE
    local-unit:
      in-scope: true
      data:
        egress-subnets: 10.152.183.23/32
        ingress-address: 10.152.183.23
        private-address: 10.152.183.23
  - relation-id: 22
    endpoint: mongodb
    cross-model: true
    related-endpoint: database
    application-data:
      data: '{"database": "test-database", "external-node-connectivity": "true", "requested-secrets":
        "[\"username\", \"password\", \"tls\", \"tls-ca\", \"uris\"]"}'
      database: test-database
      endpoints: 10.33.194.75
      replset: mongodb
      secret-user: secret://b0a940a2-3e33-4f38-81fd-73d93ab544ac/cnompr2knc4j9aa9vb80
    related-units:
      mongodb/0:
        in-scope: true
        data:
          egress-subnets: 10.33.194.75/32
          ingress-address: 10.33.194.75
          private-address: 10.33.194.75
  provider-id: data-integrator-0
  address: 10.1.225.164
MiaAltieri commented 5 months ago

on. Are cross-model relations with a mongodb_client consumer from a juju 2.9 model supported?

I believe no - since in older implementations of Charmed MongoDB on Juju 2.9 (i.e. the 5/edge charm) - we shared client relation data on the mongodb_client interface directly in the relation_databag (i.e. URI, passwords, etc) - But in now, Juju 3 we use Juju Secrets, meaning that sensitive information in the mongodb_client interface is now shared in secrets (i.e. the secret-user field you have shared above) To view the contents of that secret you can do juju show-secret --reveal secret://b0a940a2-3e33-4f38-81fd-73d93ab544ac/cnompr2knc4j9aa9vb80

It might be possible that Juju has ways of reading secrets in Juju 2.9, but I am not sure if that functionality exists or not. If you would like I can ask a Juju Secrets expert from our team. :)

cbartz commented 5 months ago

I did a quick test creating a cmr with juju 2.9, it seems to work (relation databag looks different)

╰─$ juju_29 show-unit data-integrator/0                                                                                                                                                                                                                                      130 ↵
data-integrator/0:
  opened-ports: []
  charm: ch:amd64/jammy/data-integrator-21
  leader: true
  life: alive
  relation-info:
  - relation-id: 0
    endpoint: data-integrator-peers
    related-endpoint: data-integrator-peers
    application-data:
      mongodb: ACTIVE
    local-unit:
      in-scope: true
      data:
        egress-subnets: 10.152.183.160/32
        ingress-address: 10.152.183.160
        private-address: 10.152.183.160
  - relation-id: 1
    endpoint: mongodb
    cross-model: true
    related-endpoint: database
    application-data:
      data: '{"database": "test-database", "external-node-connectivity": "true"}'
      database: test-database
      endpoints: 10.33.194.75
      password: Wvwg8kqQqHRnsfY83h6QC5gZAl5Hy1sd
      replset: mongodb
      uris: mongodb://relation-3:Wvwg8kqQqHRnsfY83h6QC5gZAl5Hy1sd@10.33.194.75/test-database?replicaSet=mongodb&authSource=admin
      username: relation-3
    related-units:
      mongodb/0:
        in-scope: true
        data:
          egress-subnets: 10.33.194.75/32
          ingress-address: 10.33.194.75
          private-address: 10.33.194.75
  provider-id: data-integrator-0
  address: 10.1.225.166
cbartz commented 2 months ago

@MiaAltieri It seems the docs are still not updated, have you created the JIRA ticket?

MiaAltieri commented 2 months ago

@cbartz - My apologies. I have now added something in the overview page to reflect that the charm operates on Juju 3. The tutorial also instructs the reader to deploy the charm on Juju 3. Is this what you would expect to see?

I can ask our docs team if it is needed on every single documentation page.

cbartz commented 2 months ago

@cbartz - My apologies. I have now added something in the overview page to reflect that the charm operates on Juju 3. The tutorial also instructs the reader to deploy the charm on Juju 3. Is this what you would expect to see?

I can ask our docs team if it is needed on every single documentation page.

@MiaAltieri I would expect something like this, but mentioning that juju 2.9 is not supported.

As for the tutorial, I found https://github.com/canonical/mongodb-operator/blob/6/edge/docs/tutorial/t-setup-environment.md#install-and-prepare-juju which shows juju 2.9 as status output.

MiaAltieri commented 2 months ago

Hi @cbartz - thanks for this.

AFAICT we do specify the minimum requirements and state juju v3.0 or higher - is what your see here sufficient? If not, please let me know and I will correct it immediately

As for the tutorial - please view charmhub/discourse - By default Canonical uses Discourse / Charmhub as their default place for storing/viewing documentation. What we have here is part of a github workflow that is currently a WIP.

But this is a good reminder. I should remove what docs we have in the repo until this workflow is corrected. I will add you to that PR

cbartz commented 2 months ago

@MiaAltieri Hi, thank you. The documentation on charmhub.io/mongodb has a problem in my browser (cannot open certain sections), so I missed it.

MiaAltieri commented 2 months ago

Hi @cbartz - yes unfortunately there is something wrong with Charmhub, from what I can tell from our internal message board it seems that the webteam is working to address it