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

Rework handling of the pebble_ready event #146

Merged
merged 20 commits into from
Nov 29, 2023
Merged

Conversation

nrobinaubertin
Copy link
Collaborator

@nrobinaubertin nrobinaubertin commented Nov 22, 2023

Overview

We discovered that in cases where the workload container gets restarted on its own, only a pebble_ready event would be thrown by juju and the container would not be correctly re-planned.
This PR handles pebble_ready event correctly and adds a named function for each event we listen to. This is a step towards "managing charm complexity", allows us to have more fine grained logging and handling of events.
During the creation of the PR, it was noted that the redis_relation_changed handler didn't try to setup discourse as needed, so it was added.

Checklist

@nrobinaubertin nrobinaubertin marked this pull request as ready for review November 23, 2023 23:16
@nrobinaubertin nrobinaubertin requested a review from a team as a code owner November 23, 2023 23:16
@amandahla
Copy link
Contributor

Out of curiosity: From the doc Lifecycle events, while deploying the charm, this happens: install -> config-changed -> start -> -pebble-ready

Would this make the set up discourse run twice?

@nrobinaubertin
Copy link
Collaborator Author

Out of curiosity: From the doc Lifecycle events, while deploying the charm, this happens: install -> config-changed -> start -> -pebble-ready

Would this make the set up discourse run twice?

Yes, indeed. This is probably why it is subject to timeouts here. I need to fix this

@nrobinaubertin nrobinaubertin marked this pull request as draft November 24, 2023 21:57
@nrobinaubertin nrobinaubertin marked this pull request as ready for review November 27, 2023 16:00
Copy link
Contributor

@jdkandersson jdkandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a step towards moving discourse to be compliant with the architecture guidance

src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
tests/unit/test_charm.py Show resolved Hide resolved
tests/unit/test_charm.py Show resolved Hide resolved
merkata
merkata previously approved these changes Nov 28, 2023
Copy link
Contributor

@merkata merkata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the comments are worth having a look at.

@amandahla
Copy link
Contributor

While reading this I was thinking: "why not handle only pebble ready event?"

@nrobinaubertin
Copy link
Collaborator Author

While reading this I was thinking: "why not handle only pebble ready event?"

The pebble ready event can occur when the relations don't exist or are not ready. So if we don't defer, it doesn't allow us to be sure that the charm will go through the setup

yanksyoon
yanksyoon previously approved these changes Nov 29, 2023
Copy link
Contributor

@yanksyoon yanksyoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor comments and questions. Thank you!

src/charm.py Show resolved Hide resolved
src/charm.py Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
jdkandersson
jdkandersson previously approved these changes Nov 29, 2023
src/charm.py Outdated Show resolved Hide resolved
Copy link
Contributor

Test coverage for 4ebe987

Name              Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------
src/charm.py        324     32     84     12    89%   137, 163, 173, 181-182, 338->343, 526-528, 533-534, 545-547, 552-553, 565-567, 572-573, 585-587, 612-614, 654->exit, 664->exit, 694-700, 726->exit, 740-741, 751->exit, 765
src/database.py      30      1      8      1    95%   56
-------------------------------------------------------------
TOTAL               354     33     92     13    90%

Static code analysis report

Run started:2023-11-29 15:16:08.049764

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 1903
  Total lines skipped (#nosec): 1
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@nrobinaubertin nrobinaubertin merged commit 549168b into main Nov 29, 2023
28 checks passed
@nrobinaubertin nrobinaubertin deleted the untangle-charm branch November 29, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants