Skip to content

Commit 0c6b243

Browse files
committed
Merge remote-tracking branch 'apache/4.19' into fix-volattach-uploaded
2 parents af21605 + 0a77eb7 commit 0c6b243

File tree

25 files changed

+331
-597
lines changed

25 files changed

+331
-597
lines changed

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

Lines changed: 1 addition & 430 deletions
Large diffs are not rendered by default.

client/conf/server.properties.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ session.timeout=30
3232
# Max allowed API request payload/content size in bytes
3333
request.content.size=1048576
3434

35+
# Max allowed API request form keys
36+
request.max.form.keys=5000
37+
3538
# Options to configure and enable HTTPS on the management server
3639
#
3740
# For the management server to pick up these configuration settings, the configured

client/src/main/java/org/apache/cloudstack/ServerDaemon.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public class ServerDaemon implements Daemon {
8181
private static final String ACCESS_LOG = "access.log";
8282
private static final String REQUEST_CONTENT_SIZE_KEY = "request.content.size";
8383
private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576;
84+
private static final String REQUEST_MAX_FORM_KEYS_KEY = "request.max.form.keys";
85+
private static final int DEFAULT_REQUEST_MAX_FORM_KEYS = 5000;
8486

8587
////////////////////////////////////////////////////////
8688
/////////////// Server Configuration ///////////////////
@@ -93,6 +95,7 @@ public class ServerDaemon implements Daemon {
9395
private int httpsPort = 8443;
9496
private int sessionTimeout = 30;
9597
private int maxFormContentSize = DEFAULT_REQUEST_CONTENT_SIZE;
98+
private int maxFormKeys = DEFAULT_REQUEST_MAX_FORM_KEYS;
9699
private boolean httpsEnable = false;
97100
private String accessLogFile = "access.log";
98101
private String bindInterface = null;
@@ -140,6 +143,7 @@ public void init(final DaemonContext context) {
140143
setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log"));
141144
setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30")));
142145
setMaxFormContentSize(Integer.valueOf(properties.getProperty(REQUEST_CONTENT_SIZE_KEY, String.valueOf(DEFAULT_REQUEST_CONTENT_SIZE))));
146+
setMaxFormKeys(Integer.valueOf(properties.getProperty(REQUEST_MAX_FORM_KEYS_KEY, String.valueOf(DEFAULT_REQUEST_MAX_FORM_KEYS))));
143147
} catch (final IOException e) {
144148
LOG.warn("Failed to read configuration from server.properties file", e);
145149
} finally {
@@ -191,6 +195,7 @@ public void start() throws Exception {
191195
// Extra config options
192196
server.setStopAtShutdown(true);
193197
server.setAttribute(ContextHandler.MAX_FORM_CONTENT_SIZE_KEY, maxFormContentSize);
198+
server.setAttribute(ContextHandler.MAX_FORM_KEYS_KEY, maxFormKeys);
194199

195200
// HTTPS Connector
196201
createHttpsConnector(httpConfig);
@@ -263,6 +268,7 @@ private Pair<SessionHandler,HandlerCollection> createHandlers() {
263268
webApp.setContextPath(contextPath);
264269
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
265270
webApp.setMaxFormContentSize(maxFormContentSize);
271+
webApp.setMaxFormKeys(maxFormKeys);
266272

267273
// GZIP handler
268274
final GzipHandler gzipHandler = new GzipHandler();
@@ -365,4 +371,8 @@ public void setSessionTimeout(int sessionTimeout) {
365371
public void setMaxFormContentSize(int maxFormContentSize) {
366372
this.maxFormContentSize = maxFormContentSize;
367373
}
374+
375+
public void setMaxFormKeys(int maxFormKeys) {
376+
this.maxFormKeys = maxFormKeys;
377+
}
368378
}

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
5353
import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
5454
import org.apache.cloudstack.utils.identity.ManagementServerNode;
55+
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
5556
import org.apache.commons.lang3.BooleanUtils;
5657
import org.apache.log4j.Logger;
5758
import org.apache.log4j.MDC;
@@ -569,27 +570,27 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
569570
}
570571
for (int i = 0; i < cmd.length; i++) {
571572
try {
573+
if (s_logger.isDebugEnabled()) {
574+
s_logger.debug("process connection to issue " + ReflectionToStringBuilderUtils.reflectCollection(cmd[i]) + " forRebalance == " + forRebalance);
575+
}
572576
monitor.second().processConnect(host, cmd[i], forRebalance);
573-
} catch (final Exception e) {
574-
if (e instanceof ConnectionException) {
575-
final ConnectionException ce = (ConnectionException)e;
576-
if (ce.isSetupError()) {
577-
s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage());
578-
handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
579-
throw ce;
580-
} else {
581-
s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + e.getMessage());
582-
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
583-
return attache;
584-
}
585-
} else if (e instanceof HypervisorVersionChangedException) {
586-
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
587-
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
588-
} else {
589-
s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage(), e);
577+
} catch (final ConnectionException ce) {
578+
if (ce.isSetupError()) {
579+
s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + ce.getMessage());
590580
handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
591-
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
581+
throw ce;
582+
} else {
583+
s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + ce.getMessage());
584+
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
585+
return attache;
592586
}
587+
} catch (final HypervisorVersionChangedException hvce) {
588+
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
589+
throw new CloudRuntimeException("Unable to connect " + attache.getId(), hvce);
590+
} catch (final Exception e) {
591+
s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage(), e);
592+
handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
593+
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
593594
}
594595
}
595596
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
431431

432432
protected static final String LOCAL_STORAGE_PATH = "local.storage.path";
433433
protected static final String LOCAL_STORAGE_UUID = "local.storage.uuid";
434-
protected static final String DEFAULT_LOCAL_STORAGE_PATH = "/var/lib/libvirt/images/";
434+
public static final String DEFAULT_LOCAL_STORAGE_PATH = "/var/lib/libvirt/images";
435435

436436
protected List<String> localStoragePaths = new ArrayList<>();
437437
protected List<String> localStorageUUIDs = new ArrayList<>();
@@ -2646,7 +2646,7 @@ protected DevicesDef createDevicesDef(VirtualMachineTO vmTO, GuestDef guest, int
26462646
Map<String, String> details = vmTO.getDetails();
26472647

26482648
boolean isIothreadsEnabled = details != null && details.containsKey(VmDetailConstants.IOTHREADS);
2649-
devices.addDevice(createSCSIDef(vcpus, isIothreadsEnabled));
2649+
addSCSIControllers(devices, vcpus, vmTO.getDisks().length, isIothreadsEnabled);
26502650
}
26512651
return devices;
26522652
}
@@ -2684,8 +2684,19 @@ protected ChannelDef createChannelDef(VirtualMachineTO vmTO) {
26842684
* Creates Virtio SCSI controller. <br>
26852685
* The respective Virtio SCSI XML definition is generated only if the VM's Disk Bus is of ISCSI.
26862686
*/
2687-
protected SCSIDef createSCSIDef(int vcpus, boolean isIothreadsEnabled) {
2688-
return new SCSIDef((short)0, 0, 0, 9, 0, vcpus, isIothreadsEnabled);
2687+
protected SCSIDef createSCSIDef(short index, int vcpus, boolean isIothreadsEnabled) {
2688+
return new SCSIDef(index, 0, 0, 9 + index, 0, vcpus, isIothreadsEnabled);
2689+
}
2690+
2691+
2692+
private void addSCSIControllers(DevicesDef devices, int vcpus, int diskCount, boolean isIothreadsEnabled) {
2693+
int controllers = diskCount / 7;
2694+
if (diskCount % 7 != 0) {
2695+
controllers++;
2696+
}
2697+
for (int i = 0; i < controllers; i++) {
2698+
devices.addDevice(createSCSIDef((short)i, vcpus, isIothreadsEnabled));
2699+
}
26892700
}
26902701

26912702
protected ConsoleDef createConsoleDef() {

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteStoragePoolCommandWrapper.java

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,78 @@
2222
import com.cloud.agent.api.Answer;
2323
import com.cloud.agent.api.DeleteStoragePoolCommand;
2424
import com.cloud.agent.api.to.StorageFilerTO;
25+
import com.cloud.agent.dao.impl.PropertiesStorage;
26+
import com.cloud.agent.properties.AgentProperties;
27+
import com.cloud.agent.properties.AgentPropertiesFileHandler;
2528
import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
2629
import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
2730
import com.cloud.resource.CommandWrapper;
2831
import com.cloud.resource.ResourceWrapper;
32+
import com.cloud.storage.Storage;
2933
import com.cloud.utils.exception.CloudRuntimeException;
3034

35+
import java.util.Arrays;
36+
import java.util.HashMap;
37+
import java.util.stream.Collectors;
38+
3139
@ResourceWrapper(handles = DeleteStoragePoolCommand.class)
3240
public final class LibvirtDeleteStoragePoolCommandWrapper extends CommandWrapper<DeleteStoragePoolCommand, Answer, LibvirtComputingResource> {
3341
@Override
3442
public Answer execute(final DeleteStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) {
3543
try {
3644
// if getRemoveDatastore() is true, then we are dealing with managed storage and can skip the delete logic here
3745
if (!command.getRemoveDatastore()) {
38-
final StorageFilerTO pool = command.getPool();
39-
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
40-
41-
storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid());
46+
handleStoragePoolDeletion(command, libvirtComputingResource);
4247
}
43-
4448
return new Answer(command);
4549
} catch (final CloudRuntimeException e) {
4650
return new Answer(command, false, e.toString());
4751
}
4852
}
53+
54+
private void handleStoragePoolDeletion(final DeleteStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) {
55+
final StorageFilerTO pool = command.getPool();
56+
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
57+
storagePoolMgr.deleteStoragePool(pool.getType(), pool.getUuid());
58+
59+
if (isLocalStorageAndNotHavingDefaultPath(pool, libvirtComputingResource)) {
60+
updateLocalStorageProperties(pool);
61+
}
62+
}
63+
64+
private boolean isLocalStorageAndNotHavingDefaultPath(final StorageFilerTO pool, final LibvirtComputingResource libvirtComputingResource) {
65+
return Storage.StoragePoolType.Filesystem.equals(pool.getType())
66+
&& !libvirtComputingResource.DEFAULT_LOCAL_STORAGE_PATH.equals(pool.getPath());
67+
}
68+
69+
private void updateLocalStorageProperties(final StorageFilerTO pool) {
70+
String localStoragePath = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LOCAL_STORAGE_PATH);
71+
String localStorageUuid = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LOCAL_STORAGE_UUID);
72+
73+
String uuidToRemove = pool.getUuid();
74+
String pathToRemove = pool.getPath();
75+
76+
if (localStorageUuid != null && uuidToRemove != null) {
77+
localStorageUuid = Arrays.stream(localStorageUuid.split(","))
78+
.filter(uuid -> !uuid.equals(uuidToRemove))
79+
.collect(Collectors.joining(","));
80+
}
81+
82+
if (localStoragePath != null && pathToRemove != null) {
83+
localStoragePath = Arrays.stream(localStoragePath.split(","))
84+
.filter(path -> !path.equals(pathToRemove))
85+
.collect(Collectors.joining(","));
86+
}
87+
88+
PropertiesStorage agentProperties = new PropertiesStorage();
89+
agentProperties.configure("AgentProperties", new HashMap<String, Object>());
90+
91+
if (localStorageUuid != null) {
92+
agentProperties.persist(AgentProperties.LOCAL_STORAGE_UUID.getName(), localStorageUuid);
93+
}
94+
95+
if (localStoragePath != null) {
96+
agentProperties.persist(AgentProperties.LOCAL_STORAGE_PATH.getName(), localStoragePath);
97+
}
98+
}
4999
}

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ public void testCreateDevicesWithSCSIDisk() {
453453
to.setDetails(new HashMap<>());
454454
to.setPlatformEmulator("Other PV Virtio-SCSI");
455455

456+
final DiskTO diskTO = Mockito.mock(DiskTO.class);
457+
to.setDisks(new DiskTO[]{diskTO});
458+
456459
GuestDef guest = new GuestDef();
457460
guest.setGuestType(GuestType.KVM);
458461

@@ -640,7 +643,7 @@ public void testCreateChannelDef() {
640643
public void testCreateSCSIDef() {
641644
VirtualMachineTO to = createDefaultVM(false);
642645

643-
SCSIDef scsiDef = libvirtComputingResourceSpy.createSCSIDef(to.getCpus(), false);
646+
SCSIDef scsiDef = libvirtComputingResourceSpy.createSCSIDef((short)0, to.getCpus(), false);
644647
Document domainDoc = parse(scsiDef.toString());
645648
verifyScsi(to, domainDoc, "");
646649
}

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ public KubernetesClusterResponse createKubernetesClusterResponse(long kubernetes
560560
if (template != null) {
561561
response.setTemplateId(template.getUuid());
562562
}
563-
ServiceOfferingVO offering = serviceOfferingDao.findById(kubernetesCluster.getServiceOfferingId());
563+
ServiceOfferingVO offering = serviceOfferingDao.findByIdIncludingRemoved(kubernetesCluster.getServiceOfferingId());
564564
if (offering != null) {
565565
response.setServiceOfferingId(offering.getUuid());
566566
response.setServiceOfferingName(offering.getName());

plugins/metrics/src/main/java/org/apache/cloudstack/api/ListSystemVMsUsageHistoryCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
@APICommand(name = "listSystemVmsUsageHistory", description = "Lists System VM stats", responseObject = VmMetricsStatsResponse.class,
2828
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.18.0",
29-
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin})
29+
authorized = {RoleType.Admin})
3030
public class ListSystemVMsUsageHistoryCmd extends BaseResourceUsageHistoryCmd {
3131

3232
/////////////////////////////////////////////////////

plugins/storage/volume/linstor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2025-01-20]
9+
10+
### Fixed
11+
12+
- Volume snapshots on zfs used the wrong dataset path to hide/unhide snapdev
13+
814
## [2024-12-13]
915

1016
### Fixed

0 commit comments

Comments
 (0)