server,engine-schema: make config - use.https.to.upload zone scoped (#11539)

This commit is contained in:
Abhishek Kumar 2026-01-28 17:53:39 +05:30 committed by GitHub
parent 37507e8799
commit 69c69dc537
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 29 additions and 16 deletions

View File

@ -56,9 +56,9 @@ public interface VolumeApiService {
Boolean.class,
"use.https.to.upload",
"true",
"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'.",
"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",
true,
ConfigKey.Scope.StoragePool);
ConfigKey.Scope.Zone);
/**
* Creates the database object for a volume based on the given criteria

View File

@ -57,8 +57,10 @@ public class TemplateOrVolumePostUploadCommand {
private String nfsVersion;
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum, String type, String name, String imageFormat, String dataTo,
String dataToRole) {
private long zoneId;
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum,
String type, String name, String imageFormat, String dataTo, String dataToRole, long zoneId) {
this.entityId = entityId;
this.entityUUID = entityUUID;
this.absolutePath = absolutePath;
@ -68,9 +70,7 @@ public class TemplateOrVolumePostUploadCommand {
this.imageFormat = imageFormat;
this.dataTo = dataTo;
this.dataToRole = dataToRole;
}
public TemplateOrVolumePostUploadCommand() {
this.zoneId = zoneId;
}
public String getRemoteEndPoint() {
@ -216,4 +216,8 @@ public class TemplateOrVolumePostUploadCommand {
public long getProcessTimeout() {
return processTimeout;
}
public long getZoneId() {
return zoneId;
}
}

View File

@ -87,3 +87,8 @@ CALL `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`('MaaS', 'orchestratorrequir
CALL `cloud`.`IDEMPOTENT_DROP_UNIQUE_KEY`('counter', 'uc_counter__provider__source__value');
CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.counter', 'uc_counter__provider__source__value__removed', '(provider, source, value, removed)');
-- Change scope for configuration - 'use.https.to.upload from' from StoragePool to Zone
UPDATE `cloud`.`configuration` SET `scope` = 2 WHERE `name` = 'use.https.to.upload';
-- Delete the configuration for 'use.https.to.upload' from StoragePool
DELETE FROM `cloud`.`storage_pool_details` WHERE `name` = 'use.https.to.upload';

View File

@ -504,9 +504,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
GetUploadParamsResponse response = new GetUploadParamsResponse();
String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
String protocol = UseHttpsToUpload.value() ? "https" : "http";
String protocol = UseHttpsToUpload.valueIn(zoneId) ? "https" : "http";
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(), protocol);
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(),
protocol);
response.setPostURL(new URL(url));
// set the post url, this is used in the monitoring thread to determine the SSVM
@ -526,8 +527,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
/*
* encoded metadata using the post upload config key
*/
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(), vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(),
vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(), dataObject.getDataStore().getRole().toString());
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(),
vol.getUuid(), volumeStore.getInstallPath(), cmd.getChecksum(), vol.getType().toString(),
vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(),
dataObject.getDataStore().getRole().toString(), zoneId);
command.setLocalPath(volumeStore.getLocalDownloadPath());
//using the existing max upload size configuration
command.setProcessTimeout(NumbersUtil.parseLong(_configDao.getValue("vmware.package.ova.timeout"), 3600));

View File

@ -234,9 +234,10 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
throw new CloudRuntimeException(errMsg);
}
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(), template.getUuid(), tmpl.getInstallPath(), tmpl
.getChecksum(), tmpl.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(),
templateOnStore.getDataStore().getRole().toString());
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(),
template.getUuid(), tmpl.getInstallPath(), tmpl.getChecksum(), tmpl.getType().toString(),
template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(),
templateOnStore.getDataStore().getRole().toString(), zoneId_is);
//using the existing max template size configuration
payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key()));

View File

@ -415,7 +415,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
TemplateOrVolumePostUploadCommand firstCommand = payload.get(0);
String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
String protocol = VolumeApiService.UseHttpsToUpload.value() ? "https" : "http";
String protocol = VolumeApiService.UseHttpsToUpload.valueIn(firstCommand.getZoneId()) ? "https" : "http";
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, firstCommand.getRemoteEndPoint(), firstCommand.getEntityUUID(), protocol);
response.setPostURL(new URL(url));

View File

@ -1252,7 +1252,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
logger.debug(String.format("Boot args for machine profile [%s]: [%s].", profile.toString(), bootArgs));
}
boolean useHttpsToUpload = BooleanUtils.toBooleanDefaultIfNull(VolumeApiService.UseHttpsToUpload.value(), true);
boolean useHttpsToUpload = VolumeApiService.UseHttpsToUpload.valueIn(dc.getId());
logger.debug(String.format("Setting UseHttpsToUpload config on cmdline with [%s] value.", useHttpsToUpload));
buf.append(" useHttpsToUpload=").append(useHttpsToUpload);