diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java index dbf478df7012..57d144fb5d8e 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java @@ -48,7 +48,7 @@ public class UpdateCfgCmd extends BaseCmd { @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the configuration") private String cfgName; - @Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, description = "the value of the configuration", length = 4096) + @Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, required = true, description = "the value of the configuration", length = 4096) private String value; @Parameter(name = ApiConstants.ZONE_ID, diff --git a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java index 908f3d7dad07..a538783cde42 100644 --- a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java @@ -994,10 +994,6 @@ public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidP throw new CloudRuntimeException("Only Root Admin is allowed to edit this configuration."); } - if (value == null) { - return _configDao.findByName(name); - } - ConfigKey.Scope scope = null; Long id = null; int paramCountCheck = 0; diff --git a/test/integration/smoke/test_deploy_vm_extra_config_data.py b/test/integration/smoke/test_deploy_vm_extra_config_data.py index 98e60f9d287c..cd67119a0ea5 100644 --- a/test/integration/smoke/test_deploy_vm_extra_config_data.py +++ b/test/integration/smoke/test_deploy_vm_extra_config_data.py @@ -125,6 +125,9 @@ def setUp(self): # Ste Global Config value def add_global_config(self, name, value): + if len(value) == 0: + value = ' ' + self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.dbclient = self.testClient.getDbConnection() diff --git a/test/integration/smoke/test_global_settings.py b/test/integration/smoke/test_global_settings.py index 53f55736d4f6..f866a1f44ddf 100644 --- a/test/integration/smoke/test_global_settings.py +++ b/test/integration/smoke/test_global_settings.py @@ -79,7 +79,7 @@ def tearDown(self): updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "commands.timeout" - updateConfigurationCmd.value = "" + updateConfigurationCmd.value = " " self.apiClient.updateConfiguration(updateConfigurationCmd) class TestListConfigurations(cloudstackTestCase): diff --git a/test/integration/smoke/test_vm_strict_host_tags.py b/test/integration/smoke/test_vm_strict_host_tags.py index 2377e9a76185..b03f6a9295bc 100644 --- a/test/integration/smoke/test_vm_strict_host_tags.py +++ b/test/integration/smoke/test_vm_strict_host_tags.py @@ -97,6 +97,9 @@ def expunge_vm(self, vm): @classmethod def updateConfiguration(self, name, value): + if len(value) == 0: + value = ' ' + cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.value = value @@ -265,6 +268,9 @@ def expunge_vm(self, vm): @classmethod def updateConfiguration(self, name, value): + if len(value) == 0: + value = ' ' + cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.value = value @@ -385,6 +391,9 @@ def expunge_vm(self, vm): @classmethod def updateConfiguration(self, name, value): + if len(value) == 0: + value = ' ' + cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.value = value @@ -509,6 +518,9 @@ def expunge_vm(self, vm): @classmethod def updateConfiguration(self, name, value): + if len(value) == 0: + value = ' ' + cmd = updateConfiguration.updateConfigurationCmd() cmd.name = name cmd.value = value diff --git a/ui/src/views/setting/ConfigurationValue.vue b/ui/src/views/setting/ConfigurationValue.vue index b4a44fdcd20f..19e50320a2ee 100644 --- a/ui/src/views/setting/ConfigurationValue.vue +++ b/ui/src/views/setting/ConfigurationValue.vue @@ -275,6 +275,14 @@ export default { if (configrecord.type === 'WhitespaceSeparatedListWithOptions') { newValue = newValue.join(' ') } + + // The updateConfiguration API expects a blank string to clean up the configuration value + if ( + (['CSV', 'Order', 'WhitespaceSeparatedListWithOptions', 'String'].includes(configrecord.type) && newValue.length === 0) + ) { + newValue = ' ' + } + const params = { [this.scopeKey]: this.$route.params?.id, name: configrecord.name, @@ -362,6 +370,17 @@ export default { } return 0 } + + if (configrecord.value?.trim().length === 0) { + if (['CSV', 'Order', 'WhitespaceSeparatedListWithOptions'].includes(configrecord.type)) { + return [] + } + + if (configrecord.type === 'String') { + return '' + } + } + if (['Order', 'CSV'].includes(configrecord.type)) { if (configrecord.value && configrecord.value.length > 0) { return String(configrecord.value).split(',')