Configure FLUs and chains with "rc.d" style configuration #56

Merged
slfritchie merged 43 commits from slf/flu-config-rcd-style into master 2015-12-18 06:46:05 +00:00
slfritchie commented 2015-12-16 10:17:49 +00:00 (Migrated from github.com)

Taking inspiration from BSD init's "rc.d" style configuration, this PR moves FLU config (which FLUs to start at app start time), chain bootstrapping (the first config before Humming Consensus manages the chain), and chain reconfiguration (adding/removing chain members) into the new style.

Also added machi-admin interface (as a strawman/temporary proposal) to provide a declarative configuration method for adding FLUs, adding chains, and reconfiguring chains. For example:

% make
% make stage
% ./rel/machi/bin/machi start

% ./rel/machi/bin/machi-admin quick-admin-apply ./priv/quick-admin-examples/000 localhost
ok

% ./rel/machi/bin/machi-admin quick-admin-apply ./priv/quick-admin-examples/001 localhost
Result: ok

% ./rel/machi/bin/machi-admin quick-admin-apply ./priv/quick-admin-examples/002 localhost
Result: ok

% ./rel/machi/bin/machi attach
Remote Shell: Use "Ctrl-C a" to quit. q() or init:stop() will terminate the machi node.
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V6.4  (abort with ^G)
(machi@127.0.0.1)1> supervisor:which_children(machi_flu_sup).
[{f6,<0.334.0>,supervisor,[]},
 {f5,<0.309.0>,supervisor,[]},
 {f4,<0.285.0>,supervisor,[]},
 {f3,<0.183.0>,supervisor,[]},
 {f2,<0.161.0>,supervisor,[]},
 {f1,<0.138.0>,supervisor,[]}]
(machi@127.0.0.1)2>

To examine the two new chains, c1 and c2 that were created by those commands:

% ls -l rel/machi/etc/quick-admin-archive
total 24
-rw-rw-r--  1 fritchie  staff   25 Dec 16 19:02 000001
-rw-rw-r--  1 fritchie  staff  119 Dec 16 19:02 000002
-rw-rw-r--  1 fritchie  staff  119 Dec 16 19:02 000003

% grep chain, rel/machi/etc/quick-admin-archive/*
rel/machi/etc/quick-admin-archive/000002:{chain,c1,[f1,f2,f3],[]}.
rel/machi/etc/quick-admin-archive/000003:{chain,c2,[f4,f5,f6],[]}.

... and ...

(machi@127.0.0.1)3> machi_projection_store:read_latest_projection(f1_pstore, private).
{ok,#projection_v1{
        epoch_number = 1113,
        epoch_csum =
            <<72,224,87,205,221,235,84,78,94,99,3,144,245,144,39,194,
              119,159,223,74>>,
        author_server = f1,chain_name = c1,
        all_members = [f1,f2,f3],
        witnesses = [],
        creation_time = {1450,260189,548973},
        mode = ap_mode,
        upi = [f1,f2,f3],
        repairing = [],down = [],
        dbg = [d_foo1,{ps,[]},{nodes_up,[f1,f2,f3]}],
[....]
Taking inspiration from BSD init's "rc.d" style configuration, this PR moves FLU config (which FLUs to start at app start time), chain bootstrapping (the first config before Humming Consensus manages the chain), and chain reconfiguration (adding/removing chain members) into the new style. Also added `machi-admin` interface (as a strawman/temporary proposal) to provide a declarative configuration method for adding FLUs, adding chains, and reconfiguring chains. For example: ``` % make % make stage % ./rel/machi/bin/machi start % ./rel/machi/bin/machi-admin quick-admin-apply ./priv/quick-admin-examples/000 localhost ok % ./rel/machi/bin/machi-admin quick-admin-apply ./priv/quick-admin-examples/001 localhost Result: ok % ./rel/machi/bin/machi-admin quick-admin-apply ./priv/quick-admin-examples/002 localhost Result: ok % ./rel/machi/bin/machi attach Remote Shell: Use "Ctrl-C a" to quit. q() or init:stop() will terminate the machi node. Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] Eshell V6.4 (abort with ^G) (machi@127.0.0.1)1> supervisor:which_children(machi_flu_sup). [{f6,<0.334.0>,supervisor,[]}, {f5,<0.309.0>,supervisor,[]}, {f4,<0.285.0>,supervisor,[]}, {f3,<0.183.0>,supervisor,[]}, {f2,<0.161.0>,supervisor,[]}, {f1,<0.138.0>,supervisor,[]}] (machi@127.0.0.1)2> ``` To examine the two new chains, `c1` and `c2` that were created by those commands: ``` % ls -l rel/machi/etc/quick-admin-archive total 24 -rw-rw-r-- 1 fritchie staff 25 Dec 16 19:02 000001 -rw-rw-r-- 1 fritchie staff 119 Dec 16 19:02 000002 -rw-rw-r-- 1 fritchie staff 119 Dec 16 19:02 000003 % grep chain, rel/machi/etc/quick-admin-archive/* rel/machi/etc/quick-admin-archive/000002:{chain,c1,[f1,f2,f3],[]}. rel/machi/etc/quick-admin-archive/000003:{chain,c2,[f4,f5,f6],[]}. ``` ... and ... ``` (machi@127.0.0.1)3> machi_projection_store:read_latest_projection(f1_pstore, private). {ok,#projection_v1{ epoch_number = 1113, epoch_csum = <<72,224,87,205,221,235,84,78,94,99,3,144,245,144,39,194, 119,159,223,74>>, author_server = f1,chain_name = c1, all_members = [f1,f2,f3], witnesses = [], creation_time = {1450,260189,548973}, mode = ap_mode, upi = [f1,f2,f3], repairing = [],down = [], dbg = [d_foo1,{ps,[]},{nodes_up,[f1,f2,f3]}], [....] ```
slfritchie commented 2015-12-17 03:34:42 +00:00 (Migrated from github.com)

TODO items:

  • Write some additional docs for the config language, use, etc.
  • Fix dialyzer warnings that have crept into machi_chain_manager1.erl and machi_chain_repair.erl as well as this PR's new code.
TODO items: - Write some additional docs for the config language, use, etc. - Fix dialyzer warnings that have crept into machi_chain_manager1.erl and machi_chain_repair.erl as well as this PR's new code.
slfritchie commented 2015-12-17 03:48:40 +00:00 (Migrated from github.com)

Dialyzer has no complaints at master commit b8b3e872e4 for the chain mgr & repair modules, so I won't worry about complaints in those mods on this PR's branch.

Dialyzer has no complaints at `master` commit b8b3e872e45ffe36de13f44fa5143272ff7a3017 for the chain mgr & repair modules, so I won't worry about complaints in those mods on this PR's branch.
slfritchie commented 2015-12-17 12:36:48 +00:00 (Migrated from github.com)

Alright, first draft of docs added. Mark, any last review bits?

Alright, first draft of docs added. Mark, any last review bits?
jadeallenx commented 2015-12-18 04:13:57 +00:00 (Migrated from github.com)

👍

:+1:
slfritchie commented 2015-12-18 06:46:41 +00:00 (Migrated from github.com)

Many thanks, Mark. The merge was a hassle, but it's done, hooray.

Many thanks, Mark. The merge was a hassle, but it's done, hooray.
jadeallenx commented 2015-12-18 17:13:26 +00:00 (Migrated from github.com)

Whew! Glad to hear it. 🍰

Whew! Glad to hear it. :cake:
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/machi#56
No description provided.