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

hook failed: "storage-attached": ModuleNotFoundError: No module named 'psycopg2._psycopg #91

Closed gustavosr98 closed 1 year ago

gustavosr98 commented 1 year ago

Bug Description

I am not able to deploy charm on top of local LXD

To Reproduce

$ juju controllers
lxd*                            pg           admin  superuser  localhost/localhost                  3      4  none  2.9.34  
$ juju deploy postgresql pg-c --channel edge -n 3

Environment

Cloud: LXD Juju: 2.9.34 (Client and Controller) Postgresql charm: latest/edge (rev 281)

$ juju status
Model  Controller  Cloud/Region         Version  SLA          Timestamp
pg     lxd         localhost/localhost  2.9.34   unsupported  11:26:40-05:00

App   Version  Status  Scale  Charm       Channel  Rev  Exposed  Message
pg-c           error       3  postgresql  edge     281  no       hook failed: "storage-attached"

Unit     Workload  Agent  Machine  Public address  Ports  Message
pg-c/0   error     idle   0        10.46.90.87            hook failed: "storage-attached"
pg-c/1*  error     idle   1        10.46.90.199           hook failed: "storage-attached"
pg-c/2   error     idle   2        10.46.90.233           hook failed: "storage-attached"

Machine  State    Address       Inst id        Series  AZ  Message
0        started  10.46.90.87   juju-dcc2a8-0  focal       Running
1        started  10.46.90.199  juju-dcc2a8-1  focal       Running
2        started  10.46.90.233  juju-dcc2a8-2  focal       Running

Revelant log output


2023-03-28 16:23:51 ERROR juju.worker.uniter.operation runhook.go:140 hook "pgdata-storage-attached" (via hook dispatching script: dispatch) failed: exit status 1
2023-03-28 16:23:51 INFO juju.worker.uniter resolver.go:145 awaiting error resolution for "storage-attached" hook
2023-03-28 16:28:01 INFO juju.worker.uniter resolver.go:145 awaiting error resolution for "storage-attached" hook
2023-03-28 16:28:51 INFO juju.worker.uniter resolver.go:145 awaiting error resolution for "storage-attached" hook
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60 Traceback (most recent call last):
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60   File "./src/charm.py", line 13, in <module>
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60     from charms.postgresql_k8s.v0.postgresql import (
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60   File "/var/lib/juju/agents/unit-pg-c-0/charm/lib/charms/postgresql_k8s/v0/postgresql.py", line 24, in <module>
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60     import psycopg2
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60   File "/var/lib/juju/agents/unit-pg-c-0/charm/venv/psycopg2/__init__.py", line 51, in <module>
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60     from psycopg2._psycopg import (                     # noqa
2023-03-28 16:28:51 WARNING unit.pg-c/0.pgdata-storage-attached logger.go:60 ModuleNotFoundError: No module named 'psycopg2._psycopg'
2023-03-28 16:28:52 ERROR juju.worker.uniter.operation runhook.go:140 hook "pgdata-storage-attached" (via hook dispatching script: dispatch) failed: exit status 1
2023-03-28 16:28:52 INFO juju.worker.uniter resolver.go:145 awaiting error resolution for "storage-attached" hook
2023-03-28 16:33:44 INFO juju.worker.uniter resolver.go:145 awaiting error resolution for "storage-attached" hook
dragomirp commented 1 year ago

Hi, can you retry with setting the series of the charm to jammy? That should solve at least the psycopg2 exception.

gustavosr98 commented 1 year ago

Thanks @dragomirp that seems to have solved that issue.

I am seeing now something else probably not related. Third unit seem to be stuck awaiting for something to happen.

$ juju status                   
Model  Controller  Cloud/Region         Version  SLA          Timestamp
pg     lxd         localhost/localhost  2.9.42   unsupported  14:45:11-05:00

App   Version  Status  Scale  Charm       Channel  Rev  Exposed  Message
pg-j           active      3  postgresql  edge     281  no       

Unit     Workload  Agent  Machine  Public address  Ports  Message
pg-j/0*  active    idle   0        10.46.90.43            Primary
pg-j/1   active    idle   1        10.46.90.120           
pg-j/2   waiting   idle   2        10.46.90.44            awaiting for member to start

Machine  State    Address       Inst id        Series  AZ  Message
0        started  10.46.90.43   juju-dfa824-0  jammy       Running
1        started  10.46.90.120  juju-dfa824-1  jammy       Running
2        started  10.46.90.44   juju-dfa824-2  jammy       Running
$ juju show-status-log pg-j/2
Time                        Type       Status     Message
28 Mar 2023 14:16:15-05:00  juju-unit  executing  running restart-relation-changed hook for pg-j/1
28 Mar 2023 14:16:15-05:00  workload   waiting    awaiting passwords generation
28 Mar 2023 14:16:16-05:00  juju-unit  idle       
28 Mar 2023 14:16:24-05:00  juju-unit  executing  running database-peers-relation-changed hook
28 Mar 2023 14:16:25-05:00  juju-unit  executing  running database-peers-relation-changed hook for pg-j/0
28 Mar 2023 14:16:25-05:00  workload   waiting    awaiting for cluster to start
28 Mar 2023 14:16:26-05:00  juju-unit  idle       
28 Mar 2023 14:16:30-05:00  juju-unit  executing  running database-peers-relation-changed hook
28 Mar 2023 14:18:39-05:00  juju-unit  executing  running database-peers-relation-changed hook for pg-j/0
28 Mar 2023 14:18:41-05:00  juju-unit  executing  running database-peers-relation-changed hook for pg-j/1
28 Mar 2023 14:18:43-05:00  juju-unit  idle       
28 Mar 2023 14:29:18-05:00  juju-unit  executing  running action get-password
28 Mar 2023 14:29:20-05:00  juju-unit  idle       
28 Mar 2023 14:38:07-05:00  juju-unit  executing  running action juju-run
28 Mar 2023 14:38:07-05:00  juju-unit  idle       
28 Mar 2023 14:38:13-05:00  juju-unit  executing  running action juju-run
28 Mar 2023 14:38:13-05:00  juju-unit  idle       
28 Mar 2023 14:38:22-05:00  juju-unit  executing  running action juju-run
28 Mar 2023 14:38:22-05:00  juju-unit  idle       
28 Mar 2023 14:42:07-05:00  workload   waiting    awaiting for member to start

Would you like me to open a different issue for this?