-
Notifications
You must be signed in to change notification settings - Fork 47
Shortcomings with current answers/params structure towards implementing nested Nulecule application #187
Description
Problem statement
The way it is now, Nulecule apps are not that reusable. It's easier for us
to add dependencies internally, rather than, add external dependency. This
can be seen in most of our examples in [[1]]. There are a few shortcomings
in having dependency on external Nulecule applications.
Namespace conflict
When we consume external Nulecule applications in our Nulecule application,
we have no control over the component names chosen in the external
applications. For example, if our app contains two external Nulecule
applications: A, B, and both A and B contains a component named
db, then params for both these different components with same name
db would get merged into the same section [db] in answers.conf.
As a consumer, of a Nulecule application, why should I bother with the
internal components of the consumed Nulecule application?
Redundant params in ANSWERS
Let's take the example of a our nulecule wordpress[[2]] application. The sample
answers file generated during installing this app looks like:
[wordpress]
db_user = None
image = wordpress
db_pass = None
db_name = None
db_host = mariadb:3306
port = 8080
[mariadb-atomicapp]
db_pass = None
db_name = None
root_pass = MySQLPass
db_user = None
[general]
namespace = default
provider = kubernetes
We see that params like db_user, db_pass, db_name, etc. gets
duplicated in multiple sections. Currently, there's no model in place params
inheritance, which seems like a sensible thing to do.
Brainstorming
The way we currently load a Nulecule application is by doing a DFS
(Depth First Search) traversal of the Nulecule application tree, similar to
nested function calls. Each node, or component, in our Nulecule application
tree, is like a node in a tree data structure. Each node (except for root)
has a parent and may have some children.
However, we do not apply the same concept when dealing with params for our
Nulecule app. The current parameter model is a flat one, rather than
a hierarchical one, devoid of any notion of inheritance.
Proposed solution
So, why don't we translate nested nulecule applications to something like
nested function calls. The root/master nulecule application defines
params: mandatory and optional (with defaults), that it needs to run or
be consumed by another nulecule application. These params are defined at the
root level of the Nulecule SPEC data, rather than at the component level.
Now, we use these defined params, as required, at the component level, to
supply the components with necessary data they need to know.
An example will make it easier to understand the solution we are proposing.
We refactor the wordpress and mariadb nulecule application as an example
to demo our solution[[3]].
[1] https://github.com/projectatomic/nulecule-library
[2] https://github.com/projectatomic/nulecule-library/tree/master/wordpress-centos7-atomicapp
[3] projectatomic/nulecule-library@master...rtnpro:refactor_answers