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

The exception handling in _update_config is wrong. #179

Open
dstathis opened this issue Sep 9, 2024 · 0 comments
Open

The exception handling in _update_config is wrong. #179

dstathis opened this issue Sep 9, 2024 · 0 comments

Comments

@dstathis
Copy link
Contributor

dstathis commented Sep 9, 2024

Bug Description

The following code has issues.

        try:
            self.write_file(CONFIG_PATH, yaml.dump(config))
            # FIXME: change this to self._reload_config when #19 is fixed
            # Restart the service to pick up the new config
            self.restart()
        except GrafanaAgentReloadError as e:
            logger.error(str(e))
            self.status.update_config = BlockedStatus(str(e))
        except APIError as e:
            logger.warning(str(e))
            self.status.update_config = WaitingStatus(str(e))

Firstly, the code in question can not raise GrafanaAgentReloadError but instead would raise GrafanaAgentServiceError. So this should be switched until canonical/grafana-agent-k8s-operator#19 is fixed (but in this repo).

Secondly, if we get the above mentioned exception, there is no known user intervention that could fix it, so it should be an error and not a BlockedStatus.

Thirdly, APIError can never be raised by this code. It is left over from the k8s charm.

To Reproduce

Environment

Relevant log output

-

Additional context

No response

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

No branches or pull requests

1 participant