Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hostcfgd] Fix issue: FeatureHandler might override user configuration (
#58) **Why I did this?** hostcfgd is using a subscribe/listen way to handle configuration data. It handles feature configuration like this: 1. subscribe to CONFIG DB FEATURE table 2. read initial data from CONFIG DB FEATURE table and call FeatureHandler.sync_state_field to process the initial data 3. As FEATURE table "state" field might be a template, FeatureHandler is responsible for rendering it 4. FeatureHandler will "resync" the rendered "state" back to CONFIG DB However, if there is a user configuration occurs between step 2 and step 3, user configuration will be silently ignored and override. Here is an example: 1. subscribe to CONFIG DB FEATURE table 2. read initial FEATURE data, say sflow.state = disabled. FeatureHandler.sync_state_field get an input that "sflow.state = disabled" 3. user issued command "config feature state sflow enabled". Now sflow.state is enabled in FEATURE table. 4. FeatureHandler.sync_state_field continues running and resync "sflow.state = disabled" back to FEATURE table In this case, user configuration in step#3 will be override. The PR is a fix for this issue. **How I verified?** Added new unit test ``` ----------- coverage: platform linux, python 3.9.2-final-0 ----------- Name Stmts Miss Cover ---------------------------------------------------- host_modules/config_engine.py 35 1 97% host_modules/gcu.py 54 0 100% host_modules/host_service.py 19 3 84% host_modules/showtech.py 27 7 74% scripts/caclmgrd 608 211 65% scripts/determine-reboot-cause 144 13 91% scripts/hostcfgd 1236 261 79% scripts/procdockerstatsd 157 90 43% ---------------------------------------------------- TOTAL 2280 586 74% Coverage HTML written to dir htmlcov Coverage XML written to file coverage.xml ======================= 104 passed, 4 warnings in 6.44s ======================== ```
- Loading branch information