diff --git a/datastore/longhorn.go b/datastore/longhorn.go index 34b84dc893..93563f4983 100644 --- a/datastore/longhorn.go +++ b/datastore/longhorn.go @@ -100,7 +100,7 @@ func (s *DataStore) filterCustomizedDefaultSettings(customizedDefaultSettings ma availableCustomizedDefaultSettings := make(map[string]string) for name, value := range customizedDefaultSettings { - if !s.isSettingValueChanged(types.SettingName(name), value) { + if !s.isEitherValueChanged(types.SettingName(name), value) { continue } @@ -114,8 +114,9 @@ func (s *DataStore) filterCustomizedDefaultSettings(customizedDefaultSettings ma return availableCustomizedDefaultSettings } -// isSettingValueChanged check if the customized default setting and value was changed -func (s *DataStore) isSettingValueChanged(name types.SettingName, value string) bool { +// isEitherValueChanged checks whether the proposed value differs from either the setting definition's +// default value or the current setting's value. +func (s *DataStore) isEitherValueChanged(name types.SettingName, value string) bool { setting, err := s.GetSettingExactRO(name) if err != nil { if !ErrorIsNotFound(err) { @@ -124,10 +125,15 @@ func (s *DataStore) isSettingValueChanged(name types.SettingName, value string) } return true } - if setting.Value == value { - return false + + // Also check the setting definition. + definition, ok := types.GetSettingDefinition(name) + if !ok { + logrus.Errorf("customized default setting %v is not defined", name) + return true } - return true + + return (setting.Value != value || definition.Default != value) } func (s *DataStore) syncSettingsWithDefaultImages(defaultImages map[types.SettingName]string) error {