Skip to content

Commit 5f52664

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 20e8cd9 + fb6adac commit 5f52664

393 files changed

Lines changed: 9538 additions & 2550 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/ui.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
npm run test:unit
5757
5858
- uses: codecov/codecov-action@v4
59+
if: github.repository == 'apache/cloudstack'
5960
with:
6061
working-directory: ui
6162
files: ./coverage/lcov.info

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,22 +453,30 @@ private void scheduleCertificateRenewalTask() {
453453
certExecutor.schedule(new PostCertificateRenewalTask(this), 5, TimeUnit.SECONDS);
454454
}
455455

456-
private void scheduleHostLBCheckerTask(final long checkInterval) {
456+
private void scheduleHostLBCheckerTask(final String lbAlgorithm, final long checkInterval) {
457457
String name = "HostLBCheckerTask";
458458
if (hostLbCheckExecutor != null && !hostLbCheckExecutor.isShutdown()) {
459+
logger.info("Shutting down the preferred host checker task {}", name);
459460
hostLbCheckExecutor.shutdown();
460461
try {
461462
if (!hostLbCheckExecutor.awaitTermination(1, TimeUnit.SECONDS)) {
462463
hostLbCheckExecutor.shutdownNow();
463464
}
464465
} catch (InterruptedException e) {
465-
logger.debug("Forcing {} shutdown as it did not shutdown in the desired time due to: {}",
466+
logger.debug("Forcing the preferred host checker task {} shutdown as it did not shutdown in the desired time due to: {}",
466467
name, e.getMessage());
467468
hostLbCheckExecutor.shutdownNow();
468469
}
469470
}
470471
if (checkInterval > 0L) {
471-
logger.info("Scheduling preferred host task with host.lb.interval={}ms", checkInterval);
472+
if ("shuffle".equalsIgnoreCase(lbAlgorithm)) {
473+
logger.info("Scheduling the preferred host checker task to trigger once (to apply lb algorithm '{}') after host.lb.interval={} ms", lbAlgorithm, checkInterval);
474+
hostLbCheckExecutor = Executors.newSingleThreadScheduledExecutor((new NamedThreadFactory(name)));
475+
hostLbCheckExecutor.schedule(new PreferredHostCheckerTask(), checkInterval, TimeUnit.MILLISECONDS);
476+
return;
477+
}
478+
479+
logger.info("Scheduling a recurring preferred host checker task with lb algorithm '{}' and host.lb.interval={} ms", lbAlgorithm, checkInterval);
472480
hostLbCheckExecutor = Executors.newSingleThreadScheduledExecutor((new NamedThreadFactory(name)));
473481
hostLbCheckExecutor.scheduleAtFixedRate(new PreferredHostCheckerTask(), checkInterval, checkInterval,
474482
TimeUnit.MILLISECONDS);
@@ -928,7 +936,7 @@ private Answer setupAgentCertificate(final SetupCertificateCommand cmd) {
928936
return new SetupCertificateAnswer(true);
929937
}
930938

931-
private void processManagementServerList(final List<String> msList, final List<String> avoidMsList, final String lbAlgorithm, final Long lbCheckInterval) {
939+
private void processManagementServerList(final List<String> msList, final List<String> avoidMsList, final String lbAlgorithm, final Long lbCheckInterval, final boolean triggerHostLB) {
932940
if (CollectionUtils.isNotEmpty(msList) && StringUtils.isNotEmpty(lbAlgorithm)) {
933941
try {
934942
final String newMSHosts = String.format("%s%s%s", com.cloud.utils.StringUtils.toCSVList(msList), IAgentShell.hostLbAlgorithmSeparator, lbAlgorithm);
@@ -941,22 +949,24 @@ private void processManagementServerList(final List<String> msList, final List<S
941949
}
942950
}
943951
shell.setAvoidHosts(avoidMsList);
944-
if ("shuffle".equals(lbAlgorithm)) {
945-
scheduleHostLBCheckerTask(0);
946-
} else {
947-
scheduleHostLBCheckerTask(shell.getLbCheckerInterval(lbCheckInterval));
952+
if (triggerHostLB) {
953+
logger.info("Triggering the preferred host checker task now");
954+
ScheduledExecutorService hostLbExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("HostLB-Executor"));
955+
hostLbExecutor.schedule(new PreferredHostCheckerTask(), 0, TimeUnit.MILLISECONDS);
956+
hostLbExecutor.shutdown();
948957
}
958+
scheduleHostLBCheckerTask(lbAlgorithm, shell.getLbCheckerInterval(lbCheckInterval));
949959
}
950960

951961
private Answer setupManagementServerList(final SetupMSListCommand cmd) {
952-
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval());
962+
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval(), cmd.getTriggerHostLb());
953963
return new SetupMSListAnswer(true);
954964
}
955965

956966
private Answer migrateAgentToOtherMS(final MigrateAgentConnectionCommand cmd) {
957967
try {
958968
if (CollectionUtils.isNotEmpty(cmd.getMsList())) {
959-
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval());
969+
processManagementServerList(cmd.getMsList(), cmd.getAvoidMsList(), cmd.getLbAlgorithm(), cmd.getLbCheckInterval(), false);
960970
}
961971
Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("MigrateAgentConnection-Job")).schedule(() -> {
962972
migrateAgentConnection(cmd.getAvoidMsList());
@@ -1046,7 +1056,7 @@ public void processReadyCommand(final Command cmd) {
10461056
}
10471057

10481058
verifyAgentArch(ready.getArch());
1049-
processManagementServerList(ready.getMsHostList(), ready.getAvoidMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval());
1059+
processManagementServerList(ready.getMsHostList(), ready.getAvoidMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval(), false);
10501060

10511061
logger.info("Ready command is processed for agent [id: {}, uuid: {}, name: {}]", getId(), getUuid(), getName());
10521062
}

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,19 @@ public class EventTypes {
801801
// Resource Limit
802802
public static final String EVENT_RESOURCE_LIMIT_UPDATE = "RESOURCE.LIMIT.UPDATE";
803803

804+
// Management Server
805+
public static final String EVENT_MANAGEMENT_SERVER_REMOVE = "MANAGEMENT.SERVER.REMOVE";
806+
804807
public static final String VM_LEASE_EXPIRED = "VM.LEASE.EXPIRED";
805808
public static final String VM_LEASE_DISABLED = "VM.LEASE.DISABLED";
806809
public static final String VM_LEASE_CANCELLED = "VM.LEASE.CANCELLED";
807810
public static final String VM_LEASE_EXPIRING = "VM.LEASE.EXPIRING";
808811

812+
// GUI Theme
813+
public static final String EVENT_GUI_THEME_CREATE = "GUI.THEME.CREATE";
814+
public static final String EVENT_GUI_THEME_REMOVE = "GUI.THEME.REMOVE";
815+
public static final String EVENT_GUI_THEME_UPDATE = "GUI.THEME.UPDATE";
816+
809817
static {
810818

811819
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@@ -1301,11 +1309,19 @@ public class EventTypes {
13011309
entityEventDetails.put(EVENT_SHAREDFS_EXPUNGE, SharedFS.class);
13021310
entityEventDetails.put(EVENT_SHAREDFS_RECOVER, SharedFS.class);
13031311

1312+
// Management Server
1313+
entityEventDetails.put(EVENT_MANAGEMENT_SERVER_REMOVE, "ManagementServer");
1314+
13041315
// VM Lease
13051316
entityEventDetails.put(VM_LEASE_EXPIRED, VirtualMachine.class);
13061317
entityEventDetails.put(VM_LEASE_EXPIRING, VirtualMachine.class);
13071318
entityEventDetails.put(VM_LEASE_DISABLED, VirtualMachine.class);
13081319
entityEventDetails.put(VM_LEASE_CANCELLED, VirtualMachine.class);
1320+
1321+
// GUI theme
1322+
entityEventDetails.put(EVENT_GUI_THEME_CREATE, "GuiTheme");
1323+
entityEventDetails.put(EVENT_GUI_THEME_REMOVE, "GuiTheme");
1324+
entityEventDetails.put(EVENT_GUI_THEME_UPDATE, "GuiTheme");
13091325
}
13101326

13111327
public static boolean isNetworkEvent(String eventType) {

api/src/main/java/com/cloud/exception/OperationTimedoutException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class OperationTimedoutException extends CloudException {
4040
boolean _isActive;
4141

4242
public OperationTimedoutException(Command[] cmds, long agentId, long seqId, int time, boolean isActive) {
43-
super("Commands " + seqId + " to Host " + agentId + " timed out after " + time);
43+
super("Commands " + seqId + " to Host " + agentId + " timed out after " + time + " secs");
4444
_agentId = agentId;
4545
_seqId = seqId;
4646
_time = time;

api/src/main/java/com/cloud/host/Host.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ public static String[] toStrings(Host.Type... types) {
5353
return strs;
5454
}
5555
}
56-
public static final String HOST_UEFI_ENABLE = "host.uefi.enable";
57-
public static final String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
58-
public static final String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
56+
57+
String HOST_UEFI_ENABLE = "host.uefi.enable";
58+
String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
59+
String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
60+
String HOST_OVFTOOL_VERSION = "host.ovftool.version";
61+
String HOST_VIRTV2V_VERSION = "host.virtv2v.version";
5962

6063
/**
6164
* @return name of the machine.

api/src/main/java/com/cloud/resource/ResourceState.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public static Event toEvent(String e) {
7676
}
7777
}
7878

79+
public static List<ResourceState> s_maintenanceStates = List.of(ResourceState.Maintenance,
80+
ResourceState.ErrorInMaintenance, ResourceState.PrepareForMaintenance,
81+
ResourceState.ErrorInPrepareForMaintenance);
82+
7983
public ResourceState getNextState(Event a) {
8084
return s_fsm.getNextState(this, a);
8185
}
@@ -98,8 +102,7 @@ public static String[] toString(ResourceState... states) {
98102
}
99103

100104
public static boolean isMaintenanceState(ResourceState state) {
101-
return Arrays.asList(ResourceState.Maintenance, ResourceState.ErrorInMaintenance,
102-
ResourceState.PrepareForMaintenance, ResourceState.ErrorInPrepareForMaintenance).contains(state);
105+
return s_maintenanceStates.contains(state);
103106
}
104107

105108
public static boolean canAttemptMaintenance(ResourceState state) {

api/src/main/java/com/cloud/server/ManagementService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsMappingCmd;
3939
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
4040
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
41+
import org.apache.cloudstack.api.command.admin.management.RemoveManagementServerCmd;
4142
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
4243
import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
4344
import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
@@ -506,4 +507,6 @@ VirtualMachine upgradeSystemVM(ScaleSystemVMCmd cmd) throws ResourceUnavailableE
506507

507508
Pair<Boolean, String> patchSystemVM(PatchSystemVMCmd cmd);
508509

510+
boolean removeManagementServer(RemoveManagementServerCmd cmd);
511+
509512
}

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
171171
* </table>
172172
*/
173173
boolean doesStoragePoolSupportDiskOffering(StoragePool destPool, DiskOffering diskOffering);
174+
175+
/**
176+
* Checks if the storage pool supports the required disk offering tags
177+
* destPool the storage pool to check the disk offering tags
178+
* diskOfferingTags the tags that should be supported
179+
* return whether the tags are supported in the storage pool
180+
*/
174181
boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags);
175182

176183
Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package com.cloud.vm;
1818

19+
import com.cloud.storage.Snapshot;
20+
import com.cloud.storage.Volume;
1921
import java.util.LinkedHashMap;
2022
import java.util.List;
2123
import java.util.Map;
@@ -222,7 +224,7 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
222224
String userData, Long userDataId, String userDataDetails, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
223225
List<Long> affinityGroupIdList, Map<String, String> customParameter, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
224226
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
225-
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId) throws InsufficientCapacityException,
227+
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId, Volume volume, Snapshot snapshot) throws InsufficientCapacityException,
226228
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
227229

228230
/**
@@ -298,7 +300,7 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
298300
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
299301
HTTPMethod httpmethod, String userData, Long userDataId, String userDataDetails, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
300302
List<Long> affinityGroupIdList, Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
301-
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap, Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId, String vmType) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
303+
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap, Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId, String vmType, Volume volume, Snapshot snapshot) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
302304

303305
/**
304306
* Creates a User VM in Advanced Zone (Security Group feature is disabled)
@@ -370,7 +372,7 @@ UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
370372
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
371373
Long userDataId, String userDataDetails, List<String> sshKeyPairs, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
372374
Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
373-
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String vmType, Long overrideDiskOfferingId)
375+
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String vmType, Long overrideDiskOfferingId, Volume volume, Snapshot snapshot)
374376

375377
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
376378

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ public class ApiConstants {
441441
public static final String PUBLIC_END_PORT = "publicendport";
442442
public static final String PUBLIC_ZONE = "publiczone";
443443
public static final String PURGE_RESOURCES = "purgeresources";
444+
public static final String REBALANCE = "rebalance";
444445
public static final String RECEIVED_BYTES = "receivedbytes";
445446
public static final String RECONNECT = "reconnect";
446447
public static final String RECOVER = "recover";
@@ -1255,6 +1256,22 @@ public class ApiConstants {
12551256

12561257
public static final String VMWARE_DC = "vmwaredc";
12571258

1259+
public static final String CSS = "css";
1260+
1261+
public static final String JSON_CONFIGURATION = "jsonconfiguration";
1262+
1263+
public static final String COMMON_NAMES = "commonnames";
1264+
1265+
public static final String COMMON_NAME = "commonname";
1266+
1267+
public static final String DOMAIN_IDS = "domainids";
1268+
1269+
public static final String SHOW_PUBLIC = "showpublic";
1270+
1271+
public static final String LIST_ONLY_DEFAULT_THEME = "listonlydefaulttheme";
1272+
1273+
public static final String RECURSIVE_DOMAINS = "recursivedomains";
1274+
12581275
/**
12591276
* This enum specifies IO Drivers, each option controls specific policies on I/O.
12601277
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).

0 commit comments

Comments
 (0)