Skip to content

Commit 69c69dc

Browse files
authored
server,engine-schema: make config - use.https.to.upload zone scoped (#11539)
1 parent 37507e8 commit 69c69dc

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
@@ -87,3 +87,8 @@ CALL `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`('MaaS', 'orchestratorrequir
8787

8888
CALL `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY`('counter', 'uc_counter__provider__source__value');
8989
CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value__removed', '(provider, source, value, removed)');
90+
91+
-- Change scope for configuration - 'use.https.to.upload from' from StoragePool to Zone
92+
UPDATE `cloud`.`configuration` SET `scope` = 2 WHERE `name` = 'use.https.to.upload';
93+
-- Delete the configuration for 'use.https.to.upload' from StoragePool
94+
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
@@ -234,9 +234,10 @@ protected void postUploadAllocation(List<DataStore> imageStores, VMTemplateVO te
234234
throw new CloudRuntimeException(errMsg);
235235
}
236236

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

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

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

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

420420
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, firstCommand.getRemoteEndPoint(), firstCommand.getEntityUUID(), protocol);
421421
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
@@ -1252,7 +1252,7 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl
12521252
logger.debug(String.format("Boot args for machine profile [%s]: [%s].", profile.toString(), bootArgs));
12531253
}
12541254

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

0 commit comments

Comments
 (0)