Project

General

Profile

Feature #20766

Change configuration handling and configuration files format

Added by Marco Mambelli over 1 year ago. Updated 19 days ago.

Status:
New
Priority:
Normal
Category:
Configuration Management
Target version:
Start date:
09/06/2018
Due date:
% Done:

0%

Estimated time:
Stakeholders:
Duration:

Description

Factory and Frontend configuration files are in XML
Furthermore they are being modified sometimes during the reconfig/upgrade commands

The new configuration files
- should be easy to write/read
- should allow comments
- should allow inclusion of multiple files
- should never be modified by reload(reconfig) or upgrade or restart

There should be a tool for checking/completing the configuration (different form the reloading). This could modify the file in place or write a different version.

Variables lists like condor_vars.lst should always be used to check correct type/options of the attributes and to set default values (see [#20749])

Some considerations based on current configuration handling in GWMS:
- should be in a different format from XML, easier to write and check (maybe Python, or JSON derivative like YAML)
https://www.zionandzion.com/json-vs-xml-vs-toml-vs-cson-vs-yaml/
- Upgrade could become an option of restart (or always be done at restart)
- Reloading should always happen on restart. And remain an option during run-time

Generic considerations:
- operators should evaluate the formats (e.g. presenting mock-ups in different formats) and pick one
- better if it allows defaults specification (e.g. for all attributes the dafault is... following attributes lists will include only elements that change)
- better if it allows type annotation and verification (e.g. enumerates)

History

#1 Updated by Marco Mambelli over 1 year ago

Added consideration:
- the configuration should allow the execution of code to generate some content (dynamic content/plugins)
- the configuration framework should be the same for Factory and Frontend, keeping as much as possible common (parsing, conversion, default managements, plugins, framework) and clearly isolate parts that are different (specific constraint and content)

Formats to consider:
Python, YAML, HJSON, JSON5?

#2 Updated by Marco Mambelli 5 months ago

  • Assignee set to Fernando Lisboa

#4 Updated by Marco Mambelli 4 months ago

Another format that could be considered is FHiCL. It has some interesting extensions in variables handling and allows imports:
- developed and used only at Fermilab (limited use, limited language support, anyway C++ and Python are supported)
+ implicit references: all elements can be referenced using dot notation and seq index) (note the sequential evaluation of references, different from HTCondor)
- everything can be a variable (this can be confusing in long files)
+ binding protection (ignore reassignment or throw error, a way to have constants),
+ prolog sections where default values could be specified
+ native import support (in YAML is possible w/ extensions not in the spec https://stackoverflow.com/questions/528281/how-can-i-include-a-yaml-file-inside-another https://davidchall.github.io/yaml-includes.html)
- single-line comments
- unclear multi-line string support
- only basic (json) data types (no sets, ordered dicts, ...)
- no type annotation

https://cdcvs.fnal.gov/redmine/attachments/download/29136/quick_start_v3.pdf
https://cdcvs.fnal.gov/redmine/attachments/download/6639/grammar.pdf
https://cdcvs.fnal.gov/redmine/projects/fhicl

This should be compared to YAML

#5 Updated by Marco Mambelli 4 months ago

Fernando did a Python-YAML comparison with a mocked Factory config and a parser. The results are in github:
https://github.com/fernandolis10/Factory-Configs

Check the testing branch:
https://github.com/fernandolis10/Factory-Configs/blob/testing/config.py

#6 Updated by Marco Mambelli 4 months ago

  • Description updated (diff)

#7 Updated by Marco Mambelli 3 months ago

Adding some new information:

Would be nice to have something similar for YAML

Ansible has some extensions to YAML:
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html

"{{ variable }}" for variables

YAML spec special chars:
https://yaml.org/spec/1.2/spec.html#id2765878

c-indicator:
- ? :  list item, key, value
, [] {}  for flow notation (c-flow-indicator)
& * !  anchor, alias, tag
# comment
| > flow and folded block
' "  single and double quoted strings
% directive line
` @ reserved for future use
cr lf are the only line-break characters
sp tab are the only white-space characters

PyYAML allows you to attach custom constructors (such as !include) to the YAML loader
https://stackoverflow.com/questions/528281/how-can-i-include-a-yaml-file-inside-another

import yaml
import os

class Loader(yaml.SafeLoader):

    def __init__(self, stream):

        self._root = os.path.split(stream.name)[0]

        super(Loader, self).__init__(stream)

    def include(self, node):

        filename = os.path.join(self._root, self.construct_scalar(node))

        with open(filename, 'r') as f:
            return yaml.load(f, Loader)

Loader.add_constructor('!include', Loader.include)

Here a gist with a better python3 implementation and usage example:
https://gist.github.com/joshbode/569627ced3076931b02f

Symphony is a YAML library for PHP that has different extensions:
https://symfony.com/doc/current/components/yaml.html



Also available in: Atom PDF