scr icon indicating copy to clipboard operation
scr copied to clipboard

config: multiple entries for given top key/val pair are merged rather than replaced

Open adammoody opened this issue 4 years ago • 1 comments

The following sequence:

SCR_Config("STORE=/dev/shm GROUP=NODE COUNT=1")
SCR_Config("STORE=/dev/shm GROUP=WORLD COUNT=2")

leads to the following:

STORE
  /dev/shm
    GROUP
      NODE
      WORLD
    COUNT
      1
      2

We should change this to have the second statement replace the first.

We may have a similar problem with config files. Looking at the scr_config.c code that processes config files, we use kvtree_se_kv to set values, which will add entries rather than replace existing values: https://github.com/LLNL/scr/blob/c53e3f7bdce2cf19aa73d87f9b2c7d651ee133a9/src/scr_config.c#L238

I suspect we'd get a kvtree like the one above from a config file having two entries like:

>>: cat .scrconf
STORE=/dev/shm GROUP=NODE COUNT=1
STORE=/dev/shm GROUP=WORLD COUNT=2

adammoody avatar Apr 29 '21 18:04 adammoody

It seems that this behaviour (adding) was originally intentional, namely to support uses like:

SCR_Config("STORE=/dev/shm GROUP=NODE");
SCR_Config("STORE=/dev/shm COUNT=1");

Changing behaviour to that STORE takes a structure of options (ie all sub-options need to be set at once) would be straightfoward to implement (much easier than than the current method of merging actually) in scr.c and branch https://github.com/rhaas80/scr/tree/rhaas/multi_entries commit https://github.com/rhaas80/scr/commit/328239f8011cdf55d4076ed08d278680e1954a0a contains such a change (for SCR_Config).

rhaas80 avatar May 19 '21 16:05 rhaas80