Skip to content

Commit 9de2cc8

Browse files
committed
server,engine-schema: make config - use.https.to.upload zone scoped
Configuration `use.https.to.upload` should be zone scoped as it affects the upload URL for SSVMs and probably has nothing to do with the storage pools. Also, on changing configuration SSVM seems to be needing recreation as the flag is passed only during deployment. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 889fc62 commit 9de2cc8

File tree

7 files changed

+29
-16
lines changed

7 files changed

+29
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public interface VolumeApiService {
5656
Boolean.class,
5757
"use.https.to.upload",
5858
"true",
59-
"Determines the protocol (HTTPS or HTTP) ACS will use to generate links to upload ISOs, volumes, and templates. When set as 'true', ACS will use protocol HTTPS, otherwise, it will use protocol HTTP. Default value is 'true'.",
59+
"Controls whether upload links for ISOs, volumes, and templates use HTTPS (true, default) or HTTP (false). After changing this setting, the Secondary Storage VM (SSVM) must be recreated",
6060
true,
61-
ConfigKey.Scope.StoragePool);
61+
ConfigKey.Scope.Zone);
6262

6363
/**
6464
* Creates the database object for a volume based on the given criteria

core/src/main/java/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ public class TemplateOrVolumePostUploadCommand {
5757

5858
private String nfsVersion;
5959

60-
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum, String type, String name, String imageFormat, String dataTo,
61-
String dataToRole) {
60+
private long zoneId;
61+
62+
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum,
63+
String type, String name, String imageFormat, String dataTo, String dataToRole, long zoneId) {
6264
this.entityId = entityId;
6365
this.entityUUID = entityUUID;
6466
this.absolutePath = absolutePath;
@@ -68,9 +70,7 @@ public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, Strin
6870
this.imageFormat = imageFormat;
6971
this.dataTo = dataTo;
7072
this.dataToRole = dataToRole;
71-
}
72-
73-
public TemplateOrVolumePostUploadCommand() {
73+
this.zoneId = zoneId;
7474
}
7575

7676
public String getRemoteEndPoint() {
@@ -216,4 +216,8 @@ public void setProcessTimeout(long processTimeout) {
216216
public long getProcessTimeout() {
217217
return processTimeout;
218218
}
219+
220+
public long getZoneId() {
221+
return zoneId;
222+
}
219223
}

engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
--;
1919
-- Schema upgrade from 4.21.0.0 to 4.22.0.0
2020
--;
21+
22+
-- Change scope for configuration - 'use.https.to.upload from' from StoragePool to Zone
23+
UPDATE `cloud`.`configuration` SET `scope` = 2 WHERE `name` = 'use.https.to.upload';
24+
-- Delete the configuration for 'use.https.to.upload' from StoragePool
25+
DELETE FROM `cloud`.`storage_pool_details` WHERE `name` = 'use.https.to.upload';

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
504504
GetUploadParamsResponse response = new GetUploadParamsResponse();
505505

506506
String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
507-
String protocol = UseHttpsToUpload.value() ? "https" : "http";
507+
String protocol = UseHttpsToUpload.valueIn(zoneId) ? "https" : "http";
508508

509-
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(), protocol);
509+
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(),
510+
protocol);
510511
response.setPostURL(new URL(url));
511512

512513
// set the post url, this is used in the monitoring thread to determine the SSVM
@@ -526,8 +527,10 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
526527
/*
527528
* encoded metadata using the post upload config key
528529
*/
529-
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(), vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(),
530-
vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(), dataObject.getDataStore().getRole().toString());
530+
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(),
531+
vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(),
532+
vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(),
533+
dataObject.getDataStore().getRole().toString(), zoneId);
531534
command.setLocalPath(volumeStore.getLocalDownloadPath());
532535
//using the existing max upload size configuration
533536
command.setProcessTimeout(NumbersUtil.parseLong(_configDao.getValue("vmware.package.ova.timeout"), 3600));

server/src/main/java/com/cloud/template/TemplateAdapterBase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ protected void postUploadAllocation(List<DataStore> imageStores, VMTemplateVO te
233233
throw new CloudRuntimeException(errMsg);
234234
}
235235

236-
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(), template.getUuid(), tmpl.getInstallPath(), tmpl
237-
.getChecksum(), tmpl.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(),
238-
templateOnStore.getDataStore().getRole().toString());
236+
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(),
237+
template.getUuid(), tmpl.getInstallPath(), tmpl.getChecksum(), tmpl.getType().toString(),
238+
template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(),
239+
templateOnStore.getDataStore().getRole().toString(), zoneId_is);
239240
//using the existing max template size configuration
240241
payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key()));
241242

server/src/main/java/com/cloud/template/TemplateManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ private GetUploadParamsResponse registerPostUploadInternal(TemplateAdapter adapt
411411
TemplateOrVolumePostUploadCommand firstCommand = payload.get(0);
412412

413413
String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
414-
String protocol = VolumeApiService.UseHttpsToUpload.value() ? "https" : "http";
414+
String protocol = VolumeApiService.UseHttpsToUpload.valueIn(firstCommand.getZoneId()) ? "https" : "http";
415415

416416
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, firstCommand.getRemoteEndPoint(), firstCommand.getEntityUUID(), protocol);
417417
response.setPostURL(new URL(url));

services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl
12321232
logger.debug(String.format("Boot args for machine profile [%s]: [%s].", profile.toString(), bootArgs));
12331233
}
12341234

1235-
boolean useHttpsToUpload = BooleanUtils.toBooleanDefaultIfNull(VolumeApiService.UseHttpsToUpload.value(), true);
1235+
boolean useHttpsToUpload = VolumeApiService.UseHttpsToUpload.valueIn(dc.getId());
12361236
logger.debug(String.format("Setting UseHttpsToUpload config on cmdline with [%s] value.", useHttpsToUpload));
12371237
buf.append(" useHttpsToUpload=").append(useHttpsToUpload);
12381238

0 commit comments

Comments
 (0)