Skip to content

Commit 91280be

Browse files
shwstpprdhslove
authored andcommitted
server,engine-schema: make config - use.https.to.upload zone scoped (apache#11539)
1 parent bfc71b0 commit 91280be

7 files changed

Lines changed: 29 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public interface VolumeApiService {
5858
Boolean.class,
5959
"use.https.to.upload",
6060
"true",
61-
"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'.",
61+
"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",
6262
true,
63-
ConfigKey.Scope.StoragePool);
63+
ConfigKey.Scope.Zone);
6464

6565
/**
6666
* 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
@@ -507,9 +507,10 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
507507
GetUploadParamsResponse response = new GetUploadParamsResponse();
508508

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

512-
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(), protocol);
512+
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(),
513+
protocol);
513514
response.setPostURL(new URL(url));
514515

515516
// set the post url, this is used in the monitoring thread to determine the SSVM
@@ -529,8 +530,10 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
529530
/*
530531
* encoded metadata using the post upload config key
531532
*/
532-
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(), vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(),
533-
vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(), dataObject.getDataStore().getRole().toString());
533+
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(),
534+
vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(),
535+
vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(),
536+
dataObject.getDataStore().getRole().toString(), zoneId);
534537
command.setLocalPath(volumeStore.getLocalDownloadPath());
535538
//using the existing max upload size configuration
536539
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
@@ -417,7 +417,7 @@ private GetUploadParamsResponse registerPostUploadInternal(TemplateAdapter adapt
417417
TemplateOrVolumePostUploadCommand firstCommand = payload.get(0);
418418

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

422422
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, firstCommand.getRemoteEndPoint(), firstCommand.getEntityUUID(), protocol);
423423
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)