Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

cfgen PR

Valery V. Vorotyntsev edited this page Aug 19, 2019 · 10 revisions

cfgen Progress Report

📽️ [watch the screencast]

Configuration generation script — cfgen — generates various configuration files required to start Mero cluster.

Input — cluster description file

Cluster administrator shall provide a cluster description file, specifying which hosts the cluster is made of, how many Mero services and clients to run, where to run confd services, which drives to use for Mero I/O.

Sample (single-node):

hosts:
  - name: localhost
    disks: { path_glob: "/dev/loop[0-9]*" }
    m0_servers:
      - runs_confd: true
        io_disks: { path_regex: . }
    c0_clients: 2
    m0t1fs_clients: 0
pools:
  - name: the pool
    # allowed_failures: { site: 0, rack: 0, encl: 0, ctrl: 0, disk: 0 }
    data_units: 1
    parity_units: 0
    disks: all

Output files

cfgen script reads cluster description file from stdin, ssh-es to the hosts mentioned there, collects their “facts” (e.g., number of CPUs, RAM size), and uses that information to generate configuration files: bootstrap-env, consul-config.json, conful-kv.json, confd.xc.

See 3/CFGEN#output-files.

Bootstrap procedure

See 6/BOOT.

Run cfgen

cfgen

$ cd cfgen/
$ ./cfgen -h
usage: cfgen [-o <output-dir>] [--mock]

Generate configuration data for Mero cluster.

optional arguments:
  -h, --help     show this help message and exit
  --help-schema  show cluster description file schema
  -o output-dir  output directory (defaults to '.')
  --mock         Generate pseudo-random "facts". The hosts specified in the
                 cluster description file will not be visited and don't even
                 have to exist.
  -V, --version  show program's version number and exit

The program reads cluster description in YAML format from the standard input;
'--help-schema' option shows the schema.
$
$
$ mkdir /tmp/cfgen.out
$ ./cfgen -o /tmp/cfgen.out <_misc/singlenode.yaml
$ ls /tmp/cfgen.out/
bootstrap-env  confd.dhall
$
$
$ cat /tmp/cfgen.out/bootstrap-env
consul_server_nodes=cmu
consul_client_nodes=
$
$
$ head /tmp/cfgen.out/confd.dhall
let Endpoint/tcp = ./dhall/Endpoint/tcp
let Obj          = ./dhall/Conf/Obj/Obj
let ObjT         = ./dhall/Conf/ObjT/ObjT
let Oid          = ./dhall/Conf/Oid/Oid
let SvcT         = ./dhall/Conf/SvcT/SvcT
let confgen      = ./dhall/Conf/confgen
let zoid         = ./dhall/Conf/Oid/zoid

let objs =
  [ Obj.Node { id = zoid ObjT.Node 3, nr_cpu = 3, memsize_MB = 2845, processes = [ zoid ObjT.Process 6, zoid ObjT.Process 9, zoid ObjT.Process 19, zoid ObjT.Process 22 ] }
$
$
$ dhall text </tmp/cfgen.out/confd.dhall | head -5
(node-3 memsize=2845 nr_cpu=3 last_state=0 flags=0 processes=[process-6, process-9, process-19, process-22])
(process-6 cores=[1, 1, 1] mem_limit_as=134217728 mem_limit_rss=2913280 mem_limit_stack=2913280 mem_limit_memlock=2913280 endpoint="10.0.2.15@tcp:12345:1975:1" services=[service-7, service-8, service-10, service-11, service-12, service-13, service-14, service-15, service-16, service-17, service-18, service-20, service-21, service-23, service-24])
(service-7 type=@M0_CST_HA endpoints=["10.0.2.15@tcp:12345:1975:1"] params=[] sdevs=[])
(service-8 type=@M0_CST_RMS endpoints=["10.0.2.15@tcp:12345:1975:1"] params=[] sdevs=[])
(process-9 cores=[1, 1, 1] mem_limit_as=134217728 mem_limit_rss=2913280 mem_limit_stack=2913280 mem_limit_memlock=2913280 endpoint="10.0.2.15@tcp:12345:1975:2" services=[service-7, service-8, service-10, service-11, service-12, service-13, service-14, service-15, service-16, service-17, service-18, service-20, service-21, service-23, service-24])
$
$
$ dhall text </tmp/cfgen.out/confd.dhall | ~/m/utils/m0confgen | head -5
[20:
 {0x6e| ((^n|1:3), 0xb1d, 3, 0, 0, [4: ^r|1:6, ^r|1:9, ^r|1:19, ^r|1:22])},
 {0x72| ((^r|1:6), [3: 1, 1, 1], 0x8000000, 0x2c7400, 0x2c7400, 0x2c7400, "10.0.2.15@tcp:12345:1975:1", [15: ^s|1:7, ^s|1:8, ^s|1:10, ^s|1:11, ^s|1:12, ^s|1:13, ^s|1:14, ^s|1:15, ^s|1:16, ^s|1:17, ^s|1:18, ^s|1:20, ^s|1:21, ^s|1:23, ^s|1:24])},
 {0x73| ((^s|1:7), @M0_CST_HA, [1: "10.0.2.15@tcp:12345:1975:1"], [0], [0])},
 {0x73| ((^s|1:8), @M0_CST_RMS, [1: "10.0.2.15@tcp:12345:1975:1"], [0], [0])},

Code

python-logo

$ wc cfgen/cfgen 
     642    2093   21760 cfgen/cfgen
$ cloc cfgen/cfgen
       1 text file.
       1 unique file.                              
       0 files ignored.

github.com/AlDanial/cloc v 1.82  T=0.01 s (66.9 files/s, 42940.3 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Python                           1            131             80            431
-------------------------------------------------------------------------------

dhall-logo

$ find cfgen/dhall -type f | wc -l
      22
$ find cfgen/dhall -type f | xargs cat | wc
     695    2348   14421

Team

  • @prasanna.kulkarni
  • @vvv