From 20a22a0f51cdcf3028e70fd5a46b0610f5042ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20De=20Marco=20Gon=C3=A7alves?= Date: Tue, 29 Apr 2025 14:56:23 -0300 Subject: [PATCH 1/6] make value parameter of the updateConfiguration API required --- .../cloudstack/api/command/admin/config/UpdateCfgCmd.java | 2 +- .../com/cloud/configuration/ConfigurationManagerImpl.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) 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; From 058320eec122f850f731544e500e4e5191da3f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20De=20Marco=20Gon=C3=A7alves?= Date: Wed, 30 Apr 2025 11:44:31 -0300 Subject: [PATCH 2/6] clean up config values --- ui/src/views/setting/ConfigurationValue.vue | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/src/views/setting/ConfigurationValue.vue b/ui/src/views/setting/ConfigurationValue.vue index b4a44fdcd20f..9d5f5fa765b2 100644 --- a/ui/src/views/setting/ConfigurationValue.vue +++ b/ui/src/views/setting/ConfigurationValue.vue @@ -275,6 +275,15 @@ 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'].includes(configrecord.type) && Object.keys(newValue).length === 0) || + (configrecord.type === 'String' && newValue.length === 0) + ) { + newValue = ' ' + } + const params = { [this.scopeKey]: this.$route.params?.id, name: configrecord.name, @@ -362,6 +371,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(',') From 06bf866fa9e32ace95eac3334822dd76bde8858d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20De=20Marco=20Gon=C3=A7alves?= Date: Wed, 30 Apr 2025 13:42:56 -0300 Subject: [PATCH 3/6] remove unecessary validation --- ui/src/views/setting/ConfigurationValue.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/src/views/setting/ConfigurationValue.vue b/ui/src/views/setting/ConfigurationValue.vue index 9d5f5fa765b2..19e50320a2ee 100644 --- a/ui/src/views/setting/ConfigurationValue.vue +++ b/ui/src/views/setting/ConfigurationValue.vue @@ -278,8 +278,7 @@ export default { // The updateConfiguration API expects a blank string to clean up the configuration value if ( - (['CSV', 'Order', 'WhitespaceSeparatedListWithOptions'].includes(configrecord.type) && Object.keys(newValue).length === 0) || - (configrecord.type === 'String' && newValue.length === 0) + (['CSV', 'Order', 'WhitespaceSeparatedListWithOptions', 'String'].includes(configrecord.type) && newValue.length === 0) ) { newValue = ' ' } From ac886474739136a96e15f1a98dd3026a96a707e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20De=20Marco=20Gon=C3=A7alves?= Date: Fri, 6 Jun 2025 14:26:50 -0300 Subject: [PATCH 4/6] fix test_vm_strict_host_tags.py integration tests --- test/integration/smoke/test_vm_strict_host_tags.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 From f90cbbbc6fb79b4cee61dc25b189e8c8621aa932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20De=20Marco=20Gon=C3=A7alves?= Date: Fri, 6 Jun 2025 14:28:50 -0300 Subject: [PATCH 5/6] fix test_global_settings.py integration tests --- test/integration/smoke/test_global_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): From f08f0d263ee64fc2a5eada3a1364542eb31f485a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20De=20Marco=20Gon=C3=A7alves?= Date: Fri, 6 Jun 2025 14:30:41 -0300 Subject: [PATCH 6/6] fix test_deploy_vm_extra_config_data.py integration tests --- test/integration/smoke/test_deploy_vm_extra_config_data.py | 3 +++ 1 file changed, 3 insertions(+) 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()