Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-5459] Recompute configmap instead of updating
The configtx validation code works by transforming the ConfigGroup tree structure into a map, where each config element has a fully qualified key like: [Groups] /Channel/Application or [Policy] /Channel/Application/Readers This flattened structure makes it easier to check which elements have been modified, as the maps may simply be iterated over, rather than walking the config tree. After applying a config update, the current config map is copied, and the elements which were updated are overlayed onto the old config. This map is then converted back into a tree structure and serialized to be the new config tree. The current code adopts the updated config map as the current config map. However, this produces the bug described in 5459. Because the updated config map is the overlay of the new config onto the old config, the updated config may contain orphaned nodes which appear in the map, but which do not appear in the config tree. Consequently, when a subsequent update arrives, it is validated not only against the current config, but also against the orphaned nodes which are still in the updated config map. This CR changes the logic to discard the updated config map (which may contain this orphaned nodes) and instead has the config map recomputed every time a new config is adopted. This is more obviously deterministic and mimics the way a new ordering node would initialize the config after being restarted. Note: There is no accompanying test case with this. I had originally written a test case which demonstrated that nodes were orphaned in the updated config. However, this is expected and not a useful test case. Similarly, forcing the update config map to have updated nodes, then testing that that map is not adopted does not provide a valuable test case. So, instead of a test, this CR opts for some code comments and this lengthly commit explaining the change. Change-Id: Idc847cd5e237531e4a8b978f3465e30a909eb94f Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information