canonical / postgresql-operator

A Charmed Operator for running PostgreSQL on machines
https://charmhub.io/postgresql
Apache License 2.0
8 stars 19 forks source link

charm install fails if python3-jinja2 is not installed #519

Closed baycarbone closed 2 months ago

baycarbone commented 2 months ago

Steps to reproduce

  1. Deploy a fresh ubuntu desktop image
  2. add a manual cloud
  3. bootstrap juju provider on manual cloud
  4. create model
  5. deploy postgres charm from channel 14/stable

Expected behavior

Installation succeeds and status in juju is all green. If a dependency is missing I would expect the charm to install it.

Actual behavior

Installation fails and juju shows the postgres unit in error state. From the juju logs it seems the charms expects the jinja module to be available but on the desktop image the python3-jinja2 package is not installed by default. After installing the package manually, the installation proceeds successfuly.

Versions

Operating system: Ubuntu 22.04.4 LTS

Juju CLI: 3.4.4-genericlinux-amd64

Juju agent: 3.4.4

Model       Controller        Cloud/Region  Version  SLA          Timestamp
controller  anvil-controller  maas/default  3.4.4    unsupported  23:52:57+02:00

App          Version  Status  Scale  Charm            Channel        Rev  Exposed  Message
controller            active      1  juju-controller  3.4/stable     101  no
haproxy               active      1  haproxy          latest/stable   79  no       Unit is ready
maas-agent   35359    active      1  maas-agent       latest/edge      9  no
maas-region  35359    active      1  maas-region      latest/edge      9  no
postgresql   14.11    active      1  postgresql       14/stable      429  no

Unit            Workload  Agent  Machine  Public address  Ports                                                                               Message
controller/0*   active    idle   0        172.27.40.1
haproxy/0*      active    idle   0        172.27.40.1     80/tcp                                                                              Unit is ready
maas-agent/0*   active    idle   0        172.27.40.1
maas-region/0*  active    idle   0        172.27.40.1     53,3128,5239-5247,5250-5274,5280-5284,5443,8000/tcp 53,67,69,123,323,5241-5247/udp
postgresql/0*   active    idle   0        172.27.40.1     5432/tcp                                                                            Primary

Machine  State    Address      Inst id  Base          AZ  Message
0        started  172.27.40.1  manual:  ubuntu@22.04      Manually provisioned machine

Charm revision: 429

Log output

Juju debug log:

2024-07-02 21:41:31 INFO juju.worker.uniter uniter.go:363 unit "postgresql/0" started
2024-07-02 21:41:31 INFO juju.worker.uniter uniter.go:689 resuming charm install
2024-07-02 21:41:31 INFO juju.worker.uniter.charm bundles.go:82 downloading ch:amd64/jammy/postgresql-429 from API server
2024-07-02 21:41:48 INFO juju.worker.uniter uniter.go:389 hooks are retried true
2024-07-02 21:41:50 WARNING unit.postgresql/0.pgdata-storage-attached logger.go:60 Traceback (most recent call last):
2024-07-02 21:41:50 WARNING unit.postgresql/0.pgdata-storage-attached logger.go:60   File "/var/lib/juju/agents/unit-postgresql-0/charm/./src/charm.py", line 56, in <module>
2024-07-02 21:41:50 WARNING unit.postgresql/0.pgdata-storage-attached logger.go:60     from backups import PostgreSQLBackups
2024-07-02 21:41:50 WARNING unit.postgresql/0.pgdata-storage-attached logger.go:60   File "/var/lib/juju/agents/unit-postgresql-0/charm/src/backups.py", line 23, in <module>
2024-07-02 21:41:50 WARNING unit.postgresql/0.pgdata-storage-attached logger.go:60     from jinja2 import Template
2024-07-02 21:41:50 WARNING unit.postgresql/0.pgdata-storage-attached logger.go:60 ModuleNotFoundError: No module named 'jinja2'

Additional context

The same test on an AWS VMs succeeds using image: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-* as it comes with python3-jinja2 installed by default.

github-actions[bot] commented 2 months ago

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

dragomirp commented 2 months ago

Hi, @baycarbone, looks like the charm is depending on jinja being provided as a deep dependency. We should be able to add it as a direct dependency of the charm to solve this.

dragomirp commented 2 months ago

Latest 14/edge (revisions 435 & 436) should have their own jinja2 installed.