Skip to content

Commit d7d9d13

Browse files
author
Daan Hoogland
committed
Merge branch '4.20'
2 parents c2259ce + 01d87b7 commit d7d9d13

File tree

14 files changed

+79
-27
lines changed

14 files changed

+79
-27
lines changed

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/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
import org.apache.cloudstack.management.ManagementServerHost;
5656
import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
5757
import org.apache.cloudstack.utils.identity.ManagementServerNode;
58-
import org.apache.commons.collections.MapUtils;
5958
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
59+
import org.apache.commons.collections.MapUtils;
6060
import org.apache.commons.lang3.BooleanUtils;
6161
import org.apache.commons.lang3.StringUtils;
6262
import org.apache.logging.log4j.ThreadContext;
@@ -223,6 +223,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
223223
"Number of maximum concurrent new connections server allows for remote (indirect) agents. " +
224224
"If set to zero (default value) then no limit will be enforced on concurrent new connections",
225225
false);
226+
protected final ConfigKey<Integer> RemoteAgentNewConnectionsMonitorInterval = new ConfigKey<>("Advanced", Integer.class, "agent.connections.monitor.interval", "1800",
227+
"Time in seconds to monitor the new agent connections and cleanup the expired connections.", false);
226228
protected final ConfigKey<Integer> AlertWait = new ConfigKey<>("Advanced", Integer.class, "alert.wait", "1800",
227229
"Seconds to wait before alerting on a disconnected agent", true);
228230
protected final ConfigKey<Integer> DirectAgentLoadSize = new ConfigKey<>("Advanced", Integer.class, "direct.agent.load.size", "16",
@@ -1945,7 +1947,7 @@ protected class AgentNewConnectionsMonitorTask extends ManagedContextRunnable {
19451947
@Override
19461948
protected void runInContext() {
19471949
logger.trace("Agent New Connections Monitor is started.");
1948-
final int cleanupTime = Wait.value();
1950+
final int cleanupTime = RemoteAgentNewConnectionsMonitorInterval.value();
19491951
Set<Map.Entry<String, Long>> entrySet = newAgentConnections.entrySet();
19501952
long cutOff = System.currentTimeMillis() - (cleanupTime * 1000L);
19511953
List<String> expiredConnections = newAgentConnections.entrySet()
@@ -2040,7 +2042,8 @@ public String getConfigComponentName() {
20402042
public ConfigKey<?>[] getConfigKeys() {
20412043
return new ConfigKey<?>[] { CheckTxnBeforeSending, Workers, Port, Wait, AlertWait, DirectAgentLoadSize,
20422044
DirectAgentPoolSize, DirectAgentThreadCap, EnableKVMAutoEnableDisable, ReadyCommandWait,
2043-
GranularWaitTimeForCommands, RemoteAgentSslHandshakeTimeout, RemoteAgentMaxConcurrentNewConnections };
2045+
GranularWaitTimeForCommands, RemoteAgentSslHandshakeTimeout, RemoteAgentMaxConcurrentNewConnections,
2046+
RemoteAgentNewConnectionsMonitorInterval };
20442047
}
20452048

20462049
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",

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static com.google.common.collect.Lists.newArrayList;
2424

2525
import java.io.File;
26+
import java.io.UnsupportedEncodingException;
2627
import java.net.URI;
2728
import java.util.ArrayList;
2829
import java.util.Arrays;
@@ -810,7 +811,7 @@ public Answer createVolume(final CreateObjectCommand cmd) {
810811
final SR poolSr = hypervisorResource.getStorageRepository(conn,
811812
CitrixHelper.getSRNameLabel(primaryStore.getUuid(), primaryStore.getPoolType(), primaryStore.getPath()));
812813
VDI.Record vdir = new VDI.Record();
813-
vdir.nameLabel = volume.getName();
814+
vdir.nameLabel = getEncodedVolumeName(volume.getName());
814815
vdir.SR = poolSr;
815816
vdir.type = Types.VdiType.USER;
816817

@@ -831,6 +832,26 @@ public Answer createVolume(final CreateObjectCommand cmd) {
831832
}
832833
}
833834

835+
private String getEncodedVolumeName(String volumeName) throws UnsupportedEncodingException {
836+
byte[] utf8Bytes = volumeName.getBytes("UTF-8");
837+
// Decode UTF-8 into a Java String (UTF-16)
838+
String decoded = new String(utf8Bytes, "UTF-8");
839+
// Print each code unit as a Unicode escape
840+
StringBuilder unicodeEscaped = new StringBuilder();
841+
for (int i = 0; i < decoded.length(); i++) {
842+
char ch = decoded.charAt(i);
843+
if (ch <= 127 && Character.isLetterOrDigit(ch)) {
844+
// Keep ASCII alphanumerics as-is
845+
unicodeEscaped.append(ch);
846+
} else {
847+
// Escape non-ASCII characters
848+
unicodeEscaped.append(String.format("\\u%04X", (int) ch));
849+
}
850+
}
851+
852+
return unicodeEscaped.toString();
853+
}
854+
834855
@Override
835856
public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd) {
836857
final Connection conn = hypervisorResource.getConnection();

plugins/storage/object/ceph/src/main/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public Bucket createBucket(Bucket bucket, boolean objectLock) {
9595
AmazonS3 s3client = getS3Client(storeId, accountId);
9696

9797
try {
98-
if (s3client.getBucketAcl(bucketName) != null) {
99-
throw new CloudRuntimeException("Bucket already exists with name " + bucketName);
98+
if (s3client.doesBucketExistV2(bucketName)) {
99+
throw new CloudRuntimeException("Bucket already exists with the name: " + bucketName);
100100
}
101101
} catch (AmazonS3Exception e) {
102102
if (e.getStatusCode() != 404) {
@@ -221,9 +221,11 @@ public boolean createUser(long accountId, long storeId) {
221221
if (user.isPresent()) {
222222
logger.info("User already exists in Ceph RGW: " + username);
223223
return true;
224+
} else {
225+
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
224226
}
225227
} catch (Exception e) {
226-
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
228+
logger.debug("Get user info failed for user {} with exception {}. Proceeding with user creation.", username, e.getMessage());
227229
}
228230

229231
try {
@@ -348,7 +350,7 @@ protected AmazonS3 getS3Client(String url, String accessKey, String secretKey) {
348350
new AWSStaticCredentialsProvider(
349351
new BasicAWSCredentials(accessKey, secretKey)))
350352
.withEndpointConfiguration(
351-
new AwsClientBuilder.EndpointConfiguration(url, "auto"))
353+
new AwsClientBuilder.EndpointConfiguration(url, null))
352354
.build();
353355

354356
if (client == null) {

plugins/storage/object/ceph/src/test/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testCreateBucket() throws Exception {
9696
when(bucketDao.findById(anyLong())).thenReturn(new BucketVO(bucket.getName()));
9797
Bucket bucketRet = cephObjectStoreDriverImpl.createBucket(bucket, false);
9898
assertEquals(bucketRet.getName(), bucket.getName());
99-
verify(rgwClient, times(1)).getBucketAcl(anyString());
99+
verify(rgwClient, times(1)).doesBucketExistV2(anyString());
100100
verify(rgwClient, times(1)).createBucket(anyString());
101101
}
102102

python/lib/cloudutils/networkConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def listNetworks():
4141
return devs
4242
@staticmethod
4343
def getDefaultNetwork():
44-
cmd = bash("route -n|awk \'/^0.0.0.0/ {print $2,$8}\'")
44+
cmd = bash("ip route show default | awk \'{print $3,$5}\'")
4545
if not cmd.isSuccess():
4646
logging.debug("Failed to get default route")
4747
raise CloudRuntimeException("Failed to get default route")

server/src/main/java/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ public boolean associatePublicIP(final Network network, final List<? extends Pub
229229
public boolean applyNetworkACLs(final Network network, final List<? extends NetworkACLItem> rules, final VirtualRouter router, final boolean isPrivateGateway)
230230
throws ResourceUnavailableException {
231231

232-
if (rules == null || rules.isEmpty()) {
233-
logger.debug("No network ACLs to be applied for network {}", network);
234-
return true;
235-
}
236-
237232
logger.debug("APPLYING NETWORK ACLs RULES");
238233

239234
final String typeString = "network acls";

server/src/test/java/org/apache/cloudstack/resource/ResourceCleanupServiceImplTest.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
package org.apache.cloudstack.resource;
1818

1919
import java.lang.reflect.Field;
20+
import java.time.Duration;
21+
import java.time.Instant;
22+
import java.time.ZoneId;
23+
import java.time.ZonedDateTime;
24+
import java.time.zone.ZoneRules;
2025
import java.util.ArrayList;
2126
import java.util.Calendar;
2227
import java.util.Date;
@@ -629,9 +634,23 @@ public void testCalculatePastDateFromConfig() {
629634
Date result = resourceCleanupService.calculatePastDateFromConfig(
630635
ResourceCleanupService.ExpungedResourcesPurgeKeepPastDays.key(),
631636
days);
632-
Date today = new Date();
633-
long diff = today.getTime() - result.getTime();
634-
Assert.assertEquals(days, TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS));
637+
Instant resultInstant = result.toInstant();
638+
ZoneId systemZone = ZoneId.systemDefault();
639+
ZoneRules rules = systemZone.getRules();
640+
ZonedDateTime resultDateTime = resultInstant.atZone(systemZone);
641+
boolean isDSTInResultDateTime = rules.isDaylightSavings(resultDateTime.toInstant());
642+
643+
ZonedDateTime todayDateTime = ZonedDateTime.now(systemZone);
644+
boolean isDSTInTodayDateTime = rules.isDaylightSavings(todayDateTime.toInstant());
645+
646+
Duration duration = Duration.between(resultDateTime, todayDateTime);
647+
long actualDays = TimeUnit.DAYS.convert(duration.toMillis(), TimeUnit.MILLISECONDS);
648+
649+
if (!isDSTInResultDateTime && isDSTInTodayDateTime) {
650+
Assert.assertEquals(days - 1, actualDays);
651+
} else {
652+
Assert.assertEquals(days, actualDays);
653+
}
635654
}
636655

637656
@Test

ui/src/config/section/infra/hosts.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ export default {
3232
},
3333
params: { type: 'routing' },
3434
columns: () => {
35-
const fields = ['name', 'state', 'resourcestate', 'ipaddress', 'arch', 'hypervisor', 'instances', 'powerstate', 'version']
35+
const fields = [
36+
'name', 'state', 'resourcestate', 'ipaddress',
37+
'arch', 'hypervisor', 'instances',
38+
{ field: 'systeminstances', customTitle: 'system.vms' },
39+
'powerstate', 'version'
40+
]
3641
const metricsFields = ['cpunumber', 'cputotalghz', 'cpuusedghz', 'cpuallocatedghz', 'memorytotalgb', 'memoryusedgb', 'memoryallocatedgb', 'networkread', 'networkwrite']
3742
if (store.getters.metrics) {
3843
fields.push(...metricsFields)

0 commit comments

Comments
 (0)