[hostcfgd] If feature state entry not in the cache, add a default state (#5777)

Our use case is to register new features in runtime. The previous change which introduced the cache broke this capability and caused hostcfgd crash.

Signed-off-by: Stepan Blyshchak <stepanb@nvidia.com>
This commit is contained in:
Stepan Blyshchak 2020-11-06 20:24:31 +02:00 committed by GitHub
parent ad555d9ffd
commit 9bc693ce6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,6 +368,8 @@ class HostConfigDaemon:
syslog.syslog(syslog.LOG_WARNING, "Enable state of feature '{}' is None".format(feature_name))
return
self.cached_feature_states.setdefault(feature_name, 'disabled')
# Enable/disable the container service if the feature state was changed from its previous state.
if self.cached_feature_states[feature_name] != state:
self.cached_feature_states[feature_name] = state