[hypervisor] prevent unsetting unconfigured values
Unsetting unconfigured values result in a snap error and will delay the hypervisor configuration. When an unset value is detected, only set it when the new value is not null. Closes-Bug: #2065864 Change-Id: Id07f70276dab87326d2f2f024a938cc4b35b8cbd
This commit is contained in:
@@ -361,7 +361,10 @@ class HypervisorOperatorCharm(sunbeam_charm.OSBaseOperatorCharm):
|
||||
# Trying to retrieve an unset parameter results in a snapError
|
||||
# so assume the snap.SnapError means there is missing config
|
||||
# that needs setting.
|
||||
new_settings[k] = snap_data[k]
|
||||
# Setting a value to None will unset the value from the snap,
|
||||
# which will fail if the value was never set.
|
||||
if snap_data[k] is not None:
|
||||
new_settings[k] = snap_data[k]
|
||||
if new_settings:
|
||||
logger.debug(f"Applying new snap settings {new_settings}")
|
||||
hypervisor.set(new_settings, typed=True)
|
||||
|
Reference in New Issue
Block a user