Skip to content

Commit 21191fa

Browse files
Merge branch '4.20' into missing-labels-nsx
2 parents f98bde8 + 1b74c2d commit 21191fa

File tree

54 files changed

+672
-718
lines changed

Some content is hidden

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

54 files changed

+672
-718
lines changed

.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/properties/AgentProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ public static class Property <T>{
823823
private T defaultValue;
824824
private Class<T> typeClass;
825825

826-
Property(String name, T value) {
826+
public Property(String name, T value) {
827827
init(name, value);
828828
}
829829

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);

core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616
// under the License.
1717
package com.cloud.agent.api;
1818

19-
import org.apache.cloudstack.vm.UnmanagedInstanceTO;
20-
2119
public class ConvertInstanceAnswer extends Answer {
2220

2321
private String temporaryConvertUuid;
2422

2523
public ConvertInstanceAnswer() {
2624
super();
2725
}
28-
private UnmanagedInstanceTO convertedInstance;
29-
30-
public ConvertInstanceAnswer(Command command, boolean success, String details) {
31-
super(command, success, details);
32-
}
33-
34-
public ConvertInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
35-
super(command, true, "");
36-
this.convertedInstance = convertedInstance;
37-
}
3826

3927
public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
4028
super(command, true, "");
@@ -44,8 +32,4 @@ public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
4432
public String getTemporaryConvertUuid() {
4533
return temporaryConvertUuid;
4634
}
47-
48-
public UnmanagedInstanceTO getConvertedInstance() {
49-
return convertedInstance;
50-
}
5135
}

core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
import com.cloud.agent.api.to.RemoteInstanceTO;
2121
import com.cloud.hypervisor.Hypervisor;
2222

23-
import java.util.List;
24-
2523
public class ConvertInstanceCommand extends Command {
2624

2725
private RemoteInstanceTO sourceInstance;
2826
private Hypervisor.HypervisorType destinationHypervisorType;
29-
private List<String> destinationStoragePools;
3027
private DataStoreTO conversionTemporaryLocation;
3128
private String templateDirOnConversionLocation;
3229
private boolean checkConversionSupport;
@@ -36,12 +33,10 @@ public class ConvertInstanceCommand extends Command {
3633
public ConvertInstanceCommand() {
3734
}
3835

39-
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType,
40-
List<String> destinationStoragePools, DataStoreTO conversionTemporaryLocation,
36+
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType, DataStoreTO conversionTemporaryLocation,
4137
String templateDirOnConversionLocation, boolean checkConversionSupport, boolean exportOvfToConversionLocation) {
4238
this.sourceInstance = sourceInstance;
4339
this.destinationHypervisorType = destinationHypervisorType;
44-
this.destinationStoragePools = destinationStoragePools;
4540
this.conversionTemporaryLocation = conversionTemporaryLocation;
4641
this.templateDirOnConversionLocation = templateDirOnConversionLocation;
4742
this.checkConversionSupport = checkConversionSupport;
@@ -56,10 +51,6 @@ public Hypervisor.HypervisorType getDestinationHypervisorType() {
5651
return destinationHypervisorType;
5752
}
5853

59-
public List<String> getDestinationStoragePools() {
60-
return destinationStoragePools;
61-
}
62-
6354
public DataStoreTO getConversionTemporaryLocation() {
6455
return conversionTemporaryLocation;
6556
}

core/src/main/java/org/apache/cloudstack/direct/download/HttpsDirectTemplateDownloader.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939

4040
import javax.net.ssl.HttpsURLConnection;
4141
import javax.net.ssl.SSLContext;
42-
import javax.net.ssl.TrustManager;
4342

44-
import org.apache.cloudstack.utils.security.SSLUtils;
4543
import org.apache.commons.collections.MapUtils;
4644
import org.apache.commons.httpclient.HttpStatus;
4745
import org.apache.commons.io.IOUtils;
@@ -55,6 +53,7 @@
5553
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
5654
import org.apache.http.impl.client.CloseableHttpClient;
5755
import org.apache.http.impl.client.HttpClients;
56+
import org.apache.http.ssl.SSLContexts;
5857
import org.apache.http.util.EntityUtils;
5958

6059
import com.cloud.utils.Pair;
@@ -120,10 +119,10 @@ private SSLContext getSSLContext() {
120119
String password = "changeit";
121120
defaultKeystore.load(is, password.toCharArray());
122121
}
123-
TrustManager[] tm = HttpsMultiTrustManager.getTrustManagersFromKeyStores(customKeystore, defaultKeystore);
124-
SSLContext sslContext = SSLUtils.getSSLContext();
125-
sslContext.init(null, tm, null);
126-
return sslContext;
122+
return SSLContexts.custom()
123+
.loadTrustMaterial(customKeystore, null)
124+
.loadTrustMaterial(defaultKeystore, null)
125+
.build();
127126
} catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException | KeyManagementException e) {
128127
logger.error(String.format("Failure getting SSL context for HTTPS downloader, using default SSL context: %s", e.getMessage()), e);
129128
try {

core/src/main/java/org/apache/cloudstack/direct/download/HttpsMultiTrustManager.java

Lines changed: 0 additions & 102 deletions
This file was deleted.

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42000to42010.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ private void addIndexes(Connection conn) {
100100

101101
DbUpgradeUtils.addIndexIfNeeded(conn, "network_offering_details", "name");
102102

103-
DbUpgradeUtils.addIndexIfNeeded(conn, "network_offering_details", "resource_id", "resource_type");
104-
105103
DbUpgradeUtils.addIndexIfNeeded(conn, "service_offering", "cpu");
106104
DbUpgradeUtils.addIndexIfNeeded(conn, "service_offering", "speed");
107105
DbUpgradeUtils.addIndexIfNeeded(conn, "service_offering", "ram_size");

engine/schema/src/main/java/com/cloud/usage/dao/UsageJobDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ public interface UsageJobDao extends GenericDao<UsageJobVO, Long> {
3737
UsageJobVO isOwner(String hostname, int pid);
3838

3939
void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success);
40+
41+
void removeLastOpenJobsOwned(String hostname, int pid);
4042
}

engine/schema/src/main/java/com/cloud/usage/dao/UsageJobDaoImpl.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.List;
2323

2424

25+
import org.apache.commons.collections.CollectionUtils;
2526
import org.springframework.stereotype.Component;
2627

2728
import com.cloud.usage.UsageJobVO;
@@ -114,7 +115,7 @@ public Long checkHeartbeat(String hostname, int pid, int aggregationDuration) {
114115
public UsageJobVO isOwner(String hostname, int pid) {
115116
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
116117
try {
117-
if ((hostname == null) || (pid <= 0)) {
118+
if (hostname == null || pid <= 0) {
118119
return null;
119120
}
120121

@@ -174,7 +175,7 @@ public UsageJobVO getNextImmediateJob() {
174175
SearchCriteria<UsageJobVO> sc = createSearchCriteria();
175176
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
176177
sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(UsageJobVO.JOB_TYPE_SINGLE));
177-
sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0));
178+
sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(UsageJobVO.JOB_NOT_SCHEDULED));
178179
List<UsageJobVO> jobs = search(sc, filter);
179180

180181
if ((jobs == null) || jobs.isEmpty()) {
@@ -194,4 +195,36 @@ public Date getLastHeartbeat() {
194195
}
195196
return jobs.get(0).getHeartbeat();
196197
}
198+
199+
private List<UsageJobVO> getLastOpenJobsOwned(String hostname, int pid) {
200+
SearchCriteria<UsageJobVO> sc = createSearchCriteria();
201+
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
202+
sc.addAnd("host", SearchCriteria.Op.EQ, hostname);
203+
if (pid > 0) {
204+
sc.addAnd("pid", SearchCriteria.Op.EQ, Integer.valueOf(pid));
205+
}
206+
return listBy(sc);
207+
}
208+
209+
@Override
210+
public void removeLastOpenJobsOwned(String hostname, int pid) {
211+
if (hostname == null) {
212+
return;
213+
}
214+
215+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
216+
try {
217+
List<UsageJobVO> jobs = getLastOpenJobsOwned(hostname, pid);
218+
if (CollectionUtils.isNotEmpty(jobs)) {
219+
logger.info("Found {} opens job, to remove", jobs.size());
220+
for (UsageJobVO job : jobs) {
221+
logger.debug("Removing job - id: {}, pid: {}, job type: {}, scheduled: {}, heartbeat: {}",
222+
job.getId(), job.getPid(), job.getJobType(), job.getScheduled(), job.getHeartbeat());
223+
remove(job.getId());
224+
}
225+
}
226+
} finally {
227+
txn.close();
228+
}
229+
}
197230
}

0 commit comments

Comments
 (0)