-
Notifications
You must be signed in to change notification settings - Fork 7
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
[DPE-2977][DPE-2978][DPE-2979][DPE-3189] - refactor: restructure entire codebase into managers, events + core #103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass! Great job! I believe the code has really improved with respect to the structure and the organization. I really like it really a lot more!
In particular, the use of the State
really provides a great entry point to the snapshot of the data available to the charm. Moreover, we now very well separate between the data, the business logic and the charm logic.
I have a number of comments and suggestions that I don't think they would take too much time, but I believe they would provide sensible value.
The only major general comment I have is to really create a clean dependency tree among modules, e.g.:
- core can import from common
- managers can import from core (and eventually common)
- events can import from managers (and eventually common and core)
- charm-specific can import from events (and eventually common, core and managers)
With increasing specialization, going from very general (e.g. common that applies to ANY charm) to charm-specific modules.
Right now, this is somewhat broken by the literals
since literals is charm specific, but it is imported by multiple level in the hierarchy, and this creates a bit of circular, more complex dependency tree in the scope
34c28bb
to
e34d745
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'm rather happy with these modifications and I believe the code structuring of the charm has improved significantly.
I would still try to separate the constants of literals.py
in the different modules (such that we could eventually externalize/factor out some of these modules), but this can be done later when needed.
For a lower and deeper level review, I'll leave it up to @juditnovak and @zmraul
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent 1st Prototype!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 1st prototype!
However I foresee furher iterations to reach the "golden standard", for reasons such as :
- [DPE-2977][DPE-2978][DPE-2979][DPE-3189] - refactor: restructure entire codebase into managers, events + core #103 (comment)
- futher consensus is needed on the spec, that may have (foreseeably non-essential) impact implementation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments, as this is an initial pass after doing the changes to Kafka.
A big problem I have (even though I did it the same way) is that the naming convention of Unit --> ZKServer, App --> ZKCluster, Client --> ZKClient both provider + requirer data
feels extremely unintuitive to someone that is not familiarized with the charm. Whereas keeping names like peer_relation
or client_relation
are way more obvious from the get go if you know charming standards.
Goals
Make it easier and quicker to share code and features between VM + K8s ZooKeeper charms, with minimal 'little fixes' each time.
Break up code across multiple modules for more straightforward separation of concerns and readability.
Overview
core/
cluster.py
Unit
,App
+ client relation dataCharmBase
all_units_related
)models.py
StateBase
with an overriddenupdate()
method, acting as a relation-data objectUnit
-->ZKServer
App
-->ZKCluster
ZKClient
- contains both provider + requirer dataworkload.py
PATHS
global inliterals.py
, which will be different for both K8s + VM, but allows using the same interfacesrc/workload.py
for substrate specific logic, again, using the same common interface between K8s + VMevents/
CharmBase
as a constructor. Can be thought of as 'extensions' ofCharmBase
, similar to pattern already applied to the majority of charmsself.charm.state
andself.charm.manager
references to do things, keeping a singlestate
and a singlemanager
to avoid object proliferationmanagers/
events/
, it helps with separation of concernsstate
andworkload
as constructors, isolating them fromCharmBase
charm.py
managers
+events
+state
charm.py
and not inevents/
is because when surveying any charm for the first time, the first place you look is incharm.py
. Centralizes the most important logicliterals.py
SUBSTRATE=vm|k8s
allows for branching logic in a single file while building hostnames in a singlemanagers/config
fileworkload.py
core/workload
for substrate specific, mostly serving as a replacement for theZooKeeperSnap
class from before this PR