Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deploying the nextcloud charm and relating to PostgreSQL charm #61

Open
marceloneppel opened this issue Jun 2, 2023 · 8 comments

Comments

@marceloneppel
Copy link

I was trying to deploy the nextcloud charm using those instructions, but couldn’t manage to make it work.

I changed the deploy commands a little bit (due to the changes in the PG charm channels and that the nextcloud charm is available only on the edge channel):

juju add-model my-nextcloud
juju model-config default-series=focal
juju deploy postgresql --channel latest/stable
juju deploy nextcloud --channel latest/edge
juju relate nextcloud:db postgresql:db

The error that I received was the following:

unit-nextcloud-0: 13:05:24 ERROR unit.nextcloud/0.juju-log Uncaught exception while in charm         code:
Traceback (most recent call last):
  File "./src/charm.py", line 596, in <module>
    main(NextcloudCharm)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/main.py", line 434, in main
    framework.reemit()
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/framework.py", line 840, in reemit
    self._reemit()
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/framework.py", line 919, in _reemit
    custom_handler(event)
  File "./src/charm.py", line 291, in _on_start
    self._on_update_status(event)
  File "./src/charm.py", line 455, in _on_update_status
    self._checkLogConfigDiff()
  File "./src/charm.py", line 589, in _checkLogConfigDiff
    if cluster_rel.data[self.app]['nextcloud_config'] == str(nextcloud_config):
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/model.py", line 1493, in __getitem__
    return super().__getitem__(key)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/model.py", line 695, in __getitem__
    return self._data[key]
KeyError: 'nextcloud_config'
unit-nextcloud-0: 13:05:24 ERROR juju.worker.uniter.operation hook "update-status" (via hook     dispatching script: dispatch) failed: exit status 1

Juju version: 2.9.42

@erik78se
Copy link
Owner

erik78se commented Jun 4, 2023

Thanx for reporting this. I'm working on getting the charm fixed up for the new postgresql charm.

Meanwhile - a workaround if to add the missing key with a None value.

@marceloneppel
Copy link
Author

Thanx for reporting this. I'm working on getting the charm fixed up for the new postgresql charm.

Meanwhile - a workaround if to add the missing key with a None value.

Thanks Erik! I'm gonna use you suggestion to patch the missing key.

@erik78se
Copy link
Owner

erik78se commented Jun 4, 2023

This is the code you can use:

    def _checkLogConfigDiff(self):
        """
        Compares nextcloud config.php with cluster/peer with application databag.
        Logs this information only.
        """
        cluster_rel = self.model.relations['cluster'][0]
        try:
            if 'nextcloud_config' in cluster_rel.data[self.app]:
                with open(NEXTCLOUD_CONFIG_PHP) as f:
                    nextcloud_config = f.read()
                    if cluster_rel.data[self.app]['nextcloud_config'] == str(nextcloud_config):
                        logger.info("No manual/local changes to nextcloud config.php detected.")
                    else:
                        logger.warning("Manual/local changes to config.php detected, will be overwritten by config updates.")
            else:
                logger.info("nextcloud_config key not found in cluster_rel.data.")
        except KeyError:
            logger.error("Error accessing cluster_rel.data dictionary.")

@marceloneppel
Copy link
Author

This is the code you can use:

    def _checkLogConfigDiff(self):
        """
        Compares nextcloud config.php with cluster/peer with application databag.
        Logs this information only.
        """
        cluster_rel = self.model.relations['cluster'][0]
        try:
            if 'nextcloud_config' in cluster_rel.data[self.app]:
                with open(NEXTCLOUD_CONFIG_PHP) as f:
                    nextcloud_config = f.read()
                    if cluster_rel.data[self.app]['nextcloud_config'] == str(nextcloud_config):
                        logger.info("No manual/local changes to nextcloud config.php detected.")
                    else:
                        logger.warning("Manual/local changes to config.php detected, will be overwritten by config updates.")
            else:
                logger.info("nextcloud_config key not found in cluster_rel.data.")
        except KeyError:
            logger.error("Error accessing cluster_rel.data dictionary.")

Cool! Thanks again, @erik78se! I tested that patch and now I could relate the nextcloud charm to the PostgreSQL charm.

@marceloneppel
Copy link
Author

Just to update the issue, if it's a not know error, the new revision of the charm fails with the following error:

unit-nextcloud-0: 18:04:57 ERROR unit.nextcloud/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/./src/charm.py", line 635, in <module>
    main(NextcloudCharm)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/main.py", line 441, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/main.py", line 149, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/framework.py", line 354, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/framework.py", line 830, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/venv/ops/framework.py", line 919, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/./src/charm.py", line 144, in _on_config_changed
    self.updateClusterRelationData()
  File "/var/lib/juju/agents/unit-nextcloud-0/charm/./src/charm.py", line 126, in updateClusterRelationData
    with open(NEXTCLOUD_CONFIG_PHP) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/var/www/nextcloud/config/config.php'

I also tried to deploy it without relating to PostgreSQL and got the same error.

@erik78se
Copy link
Owner

I'll see if I can reproduce this.

Also, I'm in the process of revamping the repos and its now also made public.

https://github.com/nextcloud-charmers/operator-nextcloud

This repo will be deprecated eventually as to move into the new one.

@erik78se
Copy link
Owner

Would you mind show how you did deploy it?

@marceloneppel
Copy link
Author

Would you mind show how you did deploy it?

juju bootstrap localhost lxd
juju add-model my-nextcloud
juju model-config default-series=jammy
juju deploy nextcloud --channel edge

Juju client and agent: 2.9.43
LXD: 5.14-7072c7b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants