From f8463436880bdf5d4ccb1f59d703ec2f19a29809 Mon Sep 17 00:00:00 2001 From: SadiJr <17a0db2854@firemailbox.club> Date: Fri, 20 Aug 2021 09:57:06 -0300 Subject: [PATCH 1/2] Externalize config to increment or not VM metrics in memory --- .../main/java/com/cloud/server/StatsCollector.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java index fd59fb86c762..36c0372325dd 100644 --- a/server/src/main/java/com/cloud/server/StatsCollector.java +++ b/server/src/main/java/com/cloud/server/StatsCollector.java @@ -51,6 +51,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.log4j.Logger; import org.influxdb.BatchOptions; import org.influxdb.InfluxDB; @@ -221,6 +222,9 @@ public String toString() { private static final ConfigKey statsOutputUri = new ConfigKey("Advanced", String.class, "stats.output.uri", "", "URI to send StatsCollector statistics to. The collector is defined on the URI scheme. Example: graphite://graphite-hostaddress:port or influxdb://influxdb-hostaddress/dbname. Note that the port is optional, if not added the default port for the respective collector (graphite or influxdb) will be used. Additionally, the database name '/dbname' is also optional; default db name is 'cloudstack'. You must create and configure the database if using influxdb.", true); + private static final ConfigKey VM_STATS_INCREMENT_METRICS_IN_MEMORY = new ConfigKey("Advanced", Boolean.class, "vm.stats.increment.metrics.in.memory", "true", + "When set to 'true', VM metrics(NetworkReadKBs, NetworkWriteKBs, DiskWriteKBs, DiskReadKBs, DiskReadIOs and DiskWriteIOs) that are collected from the hypervisor are summed and stored in memory. " + + "On the other hand, when set to 'false', the VM metrics API will just display the latest metrics collected.", true); private static StatsCollector s_instance = null; @@ -1460,11 +1464,12 @@ private void prepareVmMetricsForGraphite(Map metrics, VmStatsEnt private void storeVirtualMachineStatsInMemory(VmStatsEntry statsForCurrentIteration) { VmStatsEntry statsInMemory = (VmStatsEntry)_VmStats.get(statsForCurrentIteration.getVmId()); - if (statsInMemory == null) { - //no stats exist for this vm, directly persist + boolean vmStatsIncrementMetrics = BooleanUtils.toBoolean(VM_STATS_INCREMENT_METRICS_IN_MEMORY.value()); + if (statsInMemory == null || !vmStatsIncrementMetrics) { _VmStats.put(statsForCurrentIteration.getVmId(), statsForCurrentIteration); } else { - //update each field + s_logger.debug(String.format("Increment saved values of NetworkReadKBs, NetworkWriteKBs, DiskWriteKBs, DiskReadKBs, DiskReadIOs, DiskWriteIOs, with current metrics for VM with ID [%s]. " + + "To change this process, check value of 'vm.stats.increment.metrics.in.memory' configuration.", statsForCurrentIteration.getVmId())); statsInMemory.setCPUUtilization(statsForCurrentIteration.getCPUUtilization()); statsInMemory.setNumCPUs(statsForCurrentIteration.getNumCPUs()); statsInMemory.setNetworkReadKBs(statsInMemory.getNetworkReadKBs() + statsForCurrentIteration.getNetworkReadKBs()); @@ -1625,7 +1630,7 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {vmDiskStatsInterval, vmDiskStatsIntervalMin, vmNetworkStatsInterval, vmNetworkStatsIntervalMin, StatsTimeout, statsOutputUri}; + return new ConfigKey[] {vmDiskStatsInterval, vmDiskStatsIntervalMin, vmNetworkStatsInterval, vmNetworkStatsIntervalMin, StatsTimeout, statsOutputUri, VM_STATS_INCREMENT_METRICS_IN_MEMORY}; } public double getImageStoreCapacityThreshold() { From fdde5c56ffceed8c9597ab3136476cd048b008d3 Mon Sep 17 00:00:00 2001 From: "lucas.martins.scclouds" Date: Tue, 9 Jan 2024 14:43:02 -0300 Subject: [PATCH 2/2] Change Cryptsetup validation --- .../java/org/apache/cloudstack/utils/cryptsetup/CryptSetup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/cryptsetup/CryptSetup.java b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/cryptsetup/CryptSetup.java index 82c4ebe6d8fb..bcdb9acb7b65 100644 --- a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/cryptsetup/CryptSetup.java +++ b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/cryptsetup/CryptSetup.java @@ -108,7 +108,7 @@ public void luksFormat(byte[] passphrase, LuksType luksType, String diskPath) th public boolean isSupported() { final Script script = new Script(commandPath); - script.add("--usage"); + script.add("--version"); final String result = script.execute(); return result == null; }