Skip to content

Commit 0dd48f1

Browse files
authored
Merge branch '4.20' into fix-vmware-ip-loss
2 parents 2726aca + a21f912 commit 0dd48f1

103 files changed

Lines changed: 2111 additions & 1166 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ jobs:
236236
237237
- name: Install Python dependencies
238238
run: |
239-
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycrypto mock flask netaddr pylint pycodestyle six astroid pynose
239+
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycryptodome mock flask netaddr pylint pycodestyle six astroid pynose
240240
241241
- name: Install jacoco dependencies
242242
run: |

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,13 @@ public interface VmDetailConstants {
101101
String VMWARE_HOST_NAME = String.format("%s-host", VMWARE_TO_KVM_PREFIX);
102102
String VMWARE_DISK = String.format("%s-disk", VMWARE_TO_KVM_PREFIX);
103103
String VMWARE_MAC_ADDRESSES = String.format("%s-mac-addresses", VMWARE_TO_KVM_PREFIX);
104+
105+
// TPM
106+
String VIRTUAL_TPM_ENABLED = "virtual.tpm.enabled";
107+
String VIRTUAL_TPM_MODEL = "virtual.tpm.model";
108+
String VIRTUAL_TPM_VERSION = "virtual.tpm.version";
109+
110+
// CPU mode and model, ADMIN only
111+
String GUEST_CPU_MODE = "guest.cpu.mode";
112+
String GUEST_CPU_MODEL = "guest.cpu.model";
104113
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,11 @@ public class ApiConstants {
477477
public static final String STATE = "state";
478478
public static final String STATS = "stats";
479479
public static final String STATUS = "status";
480+
public static final String STORAGE_TYPE = "storagetype";
481+
public static final String STORAGE_POLICY = "storagepolicy";
482+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
480483
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
481484
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
482-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
483-
public static final String STORAGE_POLICY = "storagepolicy";
484-
public static final String STORAGE_POOL = "storagepool";
485-
public static final String STORAGE_TYPE = "storagetype";
486485
public static final String SUBNET = "subnet";
487486
public static final String OWNER = "owner";
488487
public static final String SWAP_OWNER = "swapowner";

api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
152152
@Deprecated
153153
@SerializedName("memoryallocated")
154154
@Param(description = "the amount of the host's memory currently allocated")
155-
private Long memoryAllocated;
155+
private long memoryAllocated;
156156

157157
@SerializedName("memoryallocatedpercentage")
158158
@Param(description = "the amount of the host's memory currently allocated in percentage")
@@ -407,7 +407,7 @@ public void setMemWithOverprovisioning(String memWithOverprovisioning){
407407
this.memWithOverprovisioning=memWithOverprovisioning;
408408
}
409409

410-
public void setMemoryAllocated(Long memoryAllocated) {
410+
public void setMemoryAllocated(long memoryAllocated) {
411411
this.memoryAllocated = memoryAllocated;
412412
}
413413

@@ -687,8 +687,8 @@ public Long getMemoryTotal() {
687687
return memoryTotal;
688688
}
689689

690-
public Long getMemoryAllocated() {
691-
return memoryAllocated == null ? 0 : memoryAllocated;
690+
public long getMemoryAllocated() {
691+
return memoryAllocated;
692692
}
693693

694694
public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) {

api/src/main/java/org/apache/cloudstack/query/QueryService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package org.apache.cloudstack.query;
1818

19+
import java.util.Arrays;
1920
import java.util.List;
2021

2122
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -97,13 +98,16 @@
9798
import org.apache.cloudstack.framework.config.ConfigKey;
9899

99100
import com.cloud.exception.PermissionDeniedException;
101+
import com.cloud.vm.VmDetailConstants;
100102

101103
/**
102104
* Service used for list api query.
103105
*
104106
*/
105107
public interface QueryService {
106108

109+
List<String> RootAdminOnlyVmSettings = Arrays.asList(VmDetailConstants.GUEST_CPU_MODE, VmDetailConstants.GUEST_CPU_MODEL);
110+
107111
// Config keys
108112
ConfigKey<Boolean> AllowUserViewDestroyedVM = new ConfigKey<>("Advanced", Boolean.class, "allow.user.view.destroyed.vm", "false",
109113
"Determines whether users can view their destroyed or expunging vm ", true, ConfigKey.Scope.Account);

engine/components-api/src/main/java/com/cloud/agent/AgentManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* AgentManager manages hosts. It directly coordinates between the DAOs and the connections it manages.
3838
*/
3939
public interface AgentManager {
40-
static final ConfigKey<Integer> Wait = new ConfigKey<Integer>("Advanced", Integer.class, "wait", "1800", "Time in seconds to wait for control commands to return",
40+
ConfigKey<Integer> Wait = new ConfigKey<Integer>("Advanced", Integer.class, "wait", "1800", "Time in seconds to wait for control commands to return",
4141
true);
4242
ConfigKey<Boolean> EnableKVMAutoEnableDisable = new ConfigKey<>(Boolean.class,
4343
"enable.kvm.host.auto.enable.disable",
@@ -54,7 +54,7 @@ public interface AgentManager {
5454
"This timeout overrides the wait global config. This holds a comma separated key value pairs containing timeout (in seconds) for specific commands. " +
5555
"For example: DhcpEntryCommand=600, SavePasswordCommand=300, VmDataCommand=300", false);
5656

57-
public enum TapAgentsAction {
57+
enum TapAgentsAction {
5858
Add, Del, Contains,
5959
}
6060

engine/components-api/src/main/java/com/cloud/event/UsageEventUtils.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@
2525
import javax.annotation.PostConstruct;
2626
import javax.inject.Inject;
2727

28+
import com.cloud.network.Network;
29+
import org.apache.commons.collections.MapUtils;
30+
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
31+
2832
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
2933
import org.apache.cloudstack.framework.events.Event;
3034
import org.apache.cloudstack.framework.events.EventBus;
3135
import org.apache.cloudstack.framework.events.EventDistributor;
32-
import org.apache.commons.collections.MapUtils;
3336
import org.apache.logging.log4j.LogManager;
3437
import org.apache.logging.log4j.Logger;
35-
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
3638

3739
import com.cloud.dc.DataCenterVO;
3840
import com.cloud.dc.dao.DataCenterDao;
@@ -243,4 +245,22 @@ private static void publishUsageEvent(String usageEventType, Long accountId, Lon
243245

244246
static final String Name = "management-server";
245247

248+
public static void publishNetworkCreation(Network network) {
249+
publishUsageEvent(EventTypes.EVENT_NETWORK_CREATE, network.getAccountId(), network.getDataCenterId(),
250+
network.getId(), network.getName(), network.getNetworkOfferingId(), null, null, null, network.getState().name(),
251+
network.getUuid());
252+
}
253+
254+
public static void publishNetworkUpdate(Network network) {
255+
publishUsageEvent(EventTypes.EVENT_NETWORK_UPDATE, network.getAccountId(), network.getDataCenterId(),
256+
network.getId(), network.getName(), network.getNetworkOfferingId(), null, network.getState().name(),
257+
Network.class.getName(), network.getUuid(), true);
258+
}
259+
260+
public static void publishNetworkDeletion(Network network) {
261+
publishUsageEvent(EventTypes.EVENT_NETWORK_DELETE, network.getAccountId(), network.getDataCenterId(),
262+
network.getId(), network.getName(), network.getNetworkOfferingId(), null, null, null,
263+
Network.class.getName(), network.getUuid());
264+
}
265+
246266
}

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
5252
import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
5353
import org.apache.cloudstack.utils.identity.ManagementServerNode;
54-
import org.apache.commons.collections.MapUtils;
5554
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
55+
import org.apache.commons.collections.MapUtils;
5656
import org.apache.commons.lang3.BooleanUtils;
5757
import org.apache.commons.lang3.StringUtils;
5858
import org.apache.logging.log4j.ThreadContext;
@@ -210,6 +210,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
210210
"Number of maximum concurrent new connections server allows for remote agents. " +
211211
"If set to zero (default value) then no limit will be enforced on concurrent new connections",
212212
false);
213+
protected final ConfigKey<Integer> RemoteAgentNewConnectionsMonitorInterval = new ConfigKey<>("Advanced", Integer.class, "agent.connections.monitor.interval", "1800",
214+
"Time in seconds to monitor the new agent connections and cleanup the expired connections.", false);
213215
protected final ConfigKey<Integer> AlertWait = new ConfigKey<Integer>("Advanced", Integer.class, "alert.wait", "1800",
214216
"Seconds to wait before alerting on a disconnected agent", true);
215217
protected final ConfigKey<Integer> DirectAgentLoadSize = new ConfigKey<Integer>("Advanced", Integer.class, "direct.agent.load.size", "16",
@@ -221,6 +223,11 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
221223
protected final ConfigKey<Boolean> CheckTxnBeforeSending = new ConfigKey<Boolean>("Developer", Boolean.class, "check.txn.before.sending.agent.commands", "false",
222224
"This parameter allows developers to enable a check to see if a transaction wraps commands that are sent to the resource. This is not to be enabled on production systems.", true);
223225

226+
public static final List<Host.Type> HOST_DOWN_ALERT_UNSUPPORTED_HOST_TYPES = Arrays.asList(
227+
Host.Type.SecondaryStorage,
228+
Host.Type.ConsoleProxy
229+
);
230+
224231
@Override
225232
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
226233

@@ -726,9 +733,9 @@ public boolean start() {
726733

727734
_monitorExecutor.scheduleWithFixedDelay(new MonitorTask(), mgmtServiceConf.getPingInterval(), mgmtServiceConf.getPingInterval(), TimeUnit.SECONDS);
728735

729-
final int cleanupTime = Wait.value();
730-
newAgentConnectionsMonitor.scheduleAtFixedRate(new AgentNewConnectionsMonitorTask(), cleanupTime,
731-
cleanupTime, TimeUnit.MINUTES);
736+
final int agentConnectionsMonitorTimeInSecs = RemoteAgentNewConnectionsMonitorInterval.value();
737+
newAgentConnectionsMonitor.scheduleAtFixedRate(new AgentNewConnectionsMonitorTask(), agentConnectionsMonitorTimeInSecs,
738+
agentConnectionsMonitorTimeInSecs, TimeUnit.SECONDS);
732739

733740
return true;
734741
}
@@ -984,9 +991,11 @@ protected boolean handleDisconnectWithInvestigation(final AgentAttache attache,
984991
if (determinedState == Status.Down) {
985992
final String message = String.format("Host %s is down. Starting HA on the VMs", host);
986993
logger.error(message);
987-
if (host.getType() != Host.Type.SecondaryStorage && host.getType() != Host.Type.ConsoleProxy) {
988-
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(),
989-
host.getPodId(), String.format("Host down, %s", host), message);
994+
if (Status.Down.equals(host.getStatus())) {
995+
logger.debug(String.format("Skipping sending alert for %s as it already in %s state",
996+
host, host.getStatus()));
997+
} else if (!HOST_DOWN_ALERT_UNSUPPORTED_HOST_TYPES.contains(host.getType())) {
998+
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host down, " + host.getId(), message);
990999
}
9911000
event = Status.Event.HostDown;
9921001
} else if (determinedState == Status.Up) {
@@ -1857,27 +1866,21 @@ protected class AgentNewConnectionsMonitorTask extends ManagedContextRunnable {
18571866
@Override
18581867
protected void runInContext() {
18591868
logger.trace("Agent New Connections Monitor is started.");
1860-
final int cleanupTime = Wait.value();
1869+
final int cleanupTime = RemoteAgentNewConnectionsMonitorInterval.value();
18611870
Set<Map.Entry<String, Long>> entrySet = newAgentConnections.entrySet();
1862-
long cutOff = System.currentTimeMillis() - (cleanupTime * 60 * 1000L);
1863-
if (logger.isDebugEnabled()) {
1864-
List<String> expiredConnections = newAgentConnections.entrySet()
1865-
.stream()
1866-
.filter(e -> e.getValue() <= cutOff)
1867-
.map(Map.Entry::getKey)
1868-
.collect(Collectors.toList());
1869-
logger.debug(String.format("Currently %d active new connections, of which %d have expired - %s",
1870-
entrySet.size(),
1871-
expiredConnections.size(),
1872-
StringUtils.join(expiredConnections)));
1873-
}
1874-
for (Map.Entry<String, Long> entry : entrySet) {
1875-
if (entry.getValue() <= cutOff) {
1876-
if (logger.isTraceEnabled()) {
1877-
logger.trace(String.format("Cleaning up new agent connection for %s", entry.getKey()));
1878-
}
1879-
newAgentConnections.remove(entry.getKey());
1880-
}
1871+
long cutOff = System.currentTimeMillis() - (cleanupTime * 1000L);
1872+
List<String> expiredConnections = newAgentConnections.entrySet()
1873+
.stream()
1874+
.filter(e -> e.getValue() <= cutOff)
1875+
.map(Map.Entry::getKey)
1876+
.collect(Collectors.toList());
1877+
logger.debug("Currently {} active new connections, of which {} have expired - {}",
1878+
entrySet.size(),
1879+
expiredConnections.size(),
1880+
StringUtils.join(expiredConnections));
1881+
for (String connection : expiredConnections) {
1882+
logger.trace("Cleaning up new agent connection for {}", connection);
1883+
newAgentConnections.remove(connection);
18811884
}
18821885
}
18831886
}
@@ -1958,7 +1961,8 @@ public String getConfigComponentName() {
19581961
public ConfigKey<?>[] getConfigKeys() {
19591962
return new ConfigKey<?>[] { CheckTxnBeforeSending, Workers, Port, Wait, AlertWait, DirectAgentLoadSize,
19601963
DirectAgentPoolSize, DirectAgentThreadCap, EnableKVMAutoEnableDisable, ReadyCommandWait,
1961-
GranularWaitTimeForCommands, RemoteAgentSslHandshakeTimeout, RemoteAgentMaxConcurrentNewConnections };
1964+
GranularWaitTimeForCommands, RemoteAgentSslHandshakeTimeout, RemoteAgentMaxConcurrentNewConnections,
1965+
RemoteAgentNewConnectionsMonitorInterval };
19621966
}
19631967

19641968
protected class SetHostParamsListener implements Listener {

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
427427
static final ConfigKey<Long> VmOpCleanupInterval = new ConfigKey<Long>("Advanced", Long.class, "vm.op.cleanup.interval", "86400",
428428
"Interval to run the thread that cleans up the vm operations (in seconds)", false);
429429
static final ConfigKey<Long> VmOpCleanupWait = new ConfigKey<Long>("Advanced", Long.class, "vm.op.cleanup.wait", "3600",
430-
"Time (in seconds) to wait before cleanuping up any vm work items", true);
430+
"Time (in seconds) to wait before cleaning up any vm work items", true);
431431
static final ConfigKey<Long> VmOpCancelInterval = new ConfigKey<Long>("Advanced", Long.class, "vm.op.cancel.interval", "3600",
432432
"Time (in seconds) to wait before cancelling a operation", false);
433433
static final ConfigKey<Boolean> VmDestroyForcestop = new ConfigKey<Boolean>("Advanced", Boolean.class, "vm.destroy.forcestop", "false",

0 commit comments

Comments
 (0)