From 696b93f421a9b1af3dbf68e8c29718927541759e Mon Sep 17 00:00:00 2001 From: Ruben Bosch <8641284+Rubueno@users.noreply.github.com> Date: Fri, 12 Aug 2022 13:44:04 +0200 Subject: [PATCH 1/2] kvm: update host memory stats (#6622) Fixes #6621 Each time getMemStat() is called, a static value is returned. This value should instead be refreshed to return the actual memory used. Co-authored-by: Ruben Bosch --- .../cloud/hypervisor/kvm/resource/LibvirtComputingResource.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index a3a5290671a..181b0516647 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -536,6 +536,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } public MemStat getMemStat() { + _memStat.refresh(); return _memStat; } From 9410a70454eaabd625ebfd6c1287adacc5949d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Beims=20Br=C3=A4scher?= Date: Fri, 12 Aug 2022 15:12:50 -0300 Subject: [PATCH 2/2] schema: increase size of column 'value' at table 'account_details' (#6080) This PR increases the column value at table account_details from 255 chars to 4096, matching with the value allowed in the API command for updating the configuration of accounts. When the value length is bigger than 255, the following log is presented right after the updateConfiguration API call: 2022-03-09 17:50:24,627 ERROR [c.c.a.ApiServer] (qtp30578394-234766:ctx-cad18b45 ctx-32e954dd) (logid:0948e203) unhandled exception executing api command: [Ljava.lang.String;@117c6ba7 com.cloud.utils.exception.CloudRuntimeException: DB Exception on: com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO account_details (account_details.account_id, account_details.name, account_details.value) VALUES (123, _binary'api.allowed.source.cidr.list', _binary'') at com.cloud.utils.db.GenericDaoBase.persist(GenericDaoBase.java:1450) at jdk.internal.reflect.GeneratedMethodAccessor168.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) .... .... .... Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'value' at row 1 at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092) ... 83 more Co-authored-by: Bart Meyers --- .../cloudstack/api/command/admin/config/UpdateCfgCmd.java | 2 +- .../schema/src/main/java/com/cloud/user/AccountDetailVO.java | 2 +- .../src/main/resources/META-INF/db/schema-41700to41710.sql | 3 +++ 3 files changed, 5 insertions(+), 2 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 acc0d79baae..0770f3c5a54 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 @@ -50,7 +50,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 = 4095) + @Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, description = "the value of the configuration", length = 4096) private String value; @Parameter(name = ApiConstants.ZONE_ID, diff --git a/engine/schema/src/main/java/com/cloud/user/AccountDetailVO.java b/engine/schema/src/main/java/com/cloud/user/AccountDetailVO.java index f4b356730ec..71ad765e618 100644 --- a/engine/schema/src/main/java/com/cloud/user/AccountDetailVO.java +++ b/engine/schema/src/main/java/com/cloud/user/AccountDetailVO.java @@ -42,7 +42,7 @@ public class AccountDetailVO implements InternalIdentity { private String name; @Encrypt - @Column(name = "value") + @Column(name = "value", length=4096) private String value; protected AccountDetailVO() { diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql b/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql index abbc99a53bc..7b8ed8f6848 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql @@ -126,3 +126,6 @@ CREATE VIEW `cloud`.`domain_router_view` AS `cloud`.`async_job` ON async_job.instance_id = vm_instance.id and async_job.instance_type = 'DomainRouter' and async_job.job_status = 0; + +-- PR #6080 Change column `value` size from 255 to 4096 characters, matching the API "updateConfiguration" "value" size +ALTER TABLE `cloud`.`account_details` MODIFY `value` VARCHAR(4096) NOT NULL; \ No newline at end of file