mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
refactor: remove use of term entry-point from extensions code base (#11488)
Addresses #11483 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
09b63bc2e8
commit
a15fbd9bcc
@ -56,7 +56,8 @@ public class DeleteExtensionCmd extends BaseCmd {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN,
|
@Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN,
|
||||||
entityType = ExtensionResponse.class, description = "Whether cleanup entry-point files for the extension")
|
entityType = ExtensionResponse.class,
|
||||||
|
description = "Whether to cleanup files for the extension. If true, the extension files will be deleted from all the management servers.")
|
||||||
private Boolean cleanup;
|
private Boolean cleanup;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -152,7 +152,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
|
|
||||||
ConfigKey<Integer> PathStateCheckInterval = new ConfigKey<>("Advanced", Integer.class,
|
ConfigKey<Integer> PathStateCheckInterval = new ConfigKey<>("Advanced", Integer.class,
|
||||||
"extension.path.state.check.interval", "300",
|
"extension.path.state.check.interval", "300",
|
||||||
"Interval (in seconds) for checking entry-point state of extensions",
|
"Interval (in seconds) for checking state of extensions path",
|
||||||
false, ConfigKey.Scope.Global);
|
false, ConfigKey.Scope.Global);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -264,11 +264,11 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
|
|
||||||
protected boolean prepareExtensionPathOnMSPeer(Extension extension, ManagementServerHostVO msHost) {
|
protected boolean prepareExtensionPathOnMSPeer(Extension extension, ManagementServerHostVO msHost) {
|
||||||
final String msPeer = Long.toString(msHost.getMsid());
|
final String msPeer = Long.toString(msHost.getMsid());
|
||||||
logger.debug("Sending prepare extension entry-point for {} command to MS: {}", extension, msPeer);
|
logger.debug("Sending prepare extension path for {} command to MS: {}", extension, msPeer);
|
||||||
final Command[] commands = new Command[1];
|
final Command[] commands = new Command[1];
|
||||||
commands[0] = new PrepareExtensionPathCommand(ManagementServerNode.getManagementServerId(), extension);
|
commands[0] = new PrepareExtensionPathCommand(ManagementServerNode.getManagementServerId(), extension);
|
||||||
String answersStr = clusterManager.execute(msPeer, 0L, GsonHelper.getGson().toJson(commands), true);
|
String answersStr = clusterManager.execute(msPeer, 0L, GsonHelper.getGson().toJson(commands), true);
|
||||||
return getResultFromAnswersString(answersStr, extension, msHost, "prepare entry-point").first();
|
return getResultFromAnswersString(answersStr, extension, msHost, "prepare path").first();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Pair<Boolean, String> prepareExtensionPathOnCurrentServer(String name, boolean userDefined,
|
protected Pair<Boolean, String> prepareExtensionPathOnCurrentServer(String name, boolean userDefined,
|
||||||
@ -276,7 +276,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
try {
|
try {
|
||||||
externalProvisioner.prepareExtensionPath(name, userDefined, relativePath);
|
externalProvisioner.prepareExtensionPath(name, userDefined, relativePath);
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
logger.error("Failed to prepare entry-point for Extension [name: {}, userDefined: {}, relativePath: {}] on this server",
|
logger.error("Failed to prepare path for Extension [name: {}, userDefined: {}, relativePath: {}] on this server",
|
||||||
name, userDefined, relativePath, e);
|
name, userDefined, relativePath, e);
|
||||||
return new Pair<>(false, e.getMessage());
|
return new Pair<>(false, e.getMessage());
|
||||||
}
|
}
|
||||||
@ -285,11 +285,11 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
|
|
||||||
protected boolean cleanupExtensionFilesOnMSPeer(Extension extension, ManagementServerHostVO msHost) {
|
protected boolean cleanupExtensionFilesOnMSPeer(Extension extension, ManagementServerHostVO msHost) {
|
||||||
final String msPeer = Long.toString(msHost.getMsid());
|
final String msPeer = Long.toString(msHost.getMsid());
|
||||||
logger.debug("Sending cleanup extension entry-point for {} command to MS: {}", extension, msPeer);
|
logger.debug("Sending cleanup extension files for {} command to MS: {}", extension, msPeer);
|
||||||
final Command[] commands = new Command[1];
|
final Command[] commands = new Command[1];
|
||||||
commands[0] = new CleanupExtensionFilesCommand(ManagementServerNode.getManagementServerId(), extension);
|
commands[0] = new CleanupExtensionFilesCommand(ManagementServerNode.getManagementServerId(), extension);
|
||||||
String answersStr = clusterManager.execute(msPeer, 0L, GsonHelper.getGson().toJson(commands), true);
|
String answersStr = clusterManager.execute(msPeer, 0L, GsonHelper.getGson().toJson(commands), true);
|
||||||
return getResultFromAnswersString(answersStr, extension, msHost, "cleanup entry-point").first();
|
return getResultFromAnswersString(answersStr, extension, msHost, "cleanup files").first();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Pair<Boolean, String> cleanupExtensionFilesOnCurrentServer(String name, String relativePath) {
|
protected Pair<Boolean, String> cleanupExtensionFilesOnCurrentServer(String name, String relativePath) {
|
||||||
@ -297,7 +297,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
externalProvisioner.cleanupExtensionPath(name, relativePath);
|
externalProvisioner.cleanupExtensionPath(name, relativePath);
|
||||||
externalProvisioner.cleanupExtensionData(name, 0, true);
|
externalProvisioner.cleanupExtensionData(name, 0, true);
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
logger.error("Failed to cleanup entry-point files for Extension [name: {}, relativePath: {}] on this server",
|
logger.error("Failed to cleanup files for Extension [name: {}, relativePath: {}] on this server",
|
||||||
name, relativePath, e);
|
name, relativePath, e);
|
||||||
return new Pair<>(false, e.getMessage());
|
return new Pair<>(false, e.getMessage());
|
||||||
}
|
}
|
||||||
@ -305,18 +305,18 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanupExtensionFilesAcrossServers(Extension extension) {
|
protected void cleanupExtensionFilesAcrossServers(Extension extension) {
|
||||||
boolean cleanup = true;
|
boolean cleanedUp = true;
|
||||||
List<ManagementServerHostVO> msHosts = managementServerHostDao.listBy(ManagementServerHost.State.Up);
|
List<ManagementServerHostVO> msHosts = managementServerHostDao.listBy(ManagementServerHost.State.Up);
|
||||||
for (ManagementServerHostVO msHost : msHosts) {
|
for (ManagementServerHostVO msHost : msHosts) {
|
||||||
if (msHost.getMsid() == ManagementServerNode.getManagementServerId()) {
|
if (msHost.getMsid() == ManagementServerNode.getManagementServerId()) {
|
||||||
cleanup = cleanup && cleanupExtensionFilesOnCurrentServer(extension.getName(),
|
cleanedUp = cleanedUp && cleanupExtensionFilesOnCurrentServer(extension.getName(),
|
||||||
extension.getRelativePath()).first();
|
extension.getRelativePath()).first();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cleanup = cleanup && cleanupExtensionFilesOnMSPeer(extension, msHost);
|
cleanedUp = cleanedUp && cleanupExtensionFilesOnMSPeer(extension, msHost);
|
||||||
}
|
}
|
||||||
if (!cleanup) {
|
if (!cleanedUp) {
|
||||||
throw new CloudRuntimeException("Extension is deleted but its entry-point files are not cleaned up across servers");
|
throw new CloudRuntimeException("Extension is deleted but its files are not cleaned up across servers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
cmds[0] = new GetExtensionPathChecksumCommand(ManagementServerNode.getManagementServerId(),
|
cmds[0] = new GetExtensionPathChecksumCommand(ManagementServerNode.getManagementServerId(),
|
||||||
extension);
|
extension);
|
||||||
String answersStr = clusterManager.execute(msPeer, 0L, GsonHelper.getGson().toJson(cmds), true);
|
String answersStr = clusterManager.execute(msPeer, 0L, GsonHelper.getGson().toJson(cmds), true);
|
||||||
return getResultFromAnswersString(answersStr, extension, msHost, "prepare entry-point");
|
return getResultFromAnswersString(answersStr, extension, msHost, "get path checksum");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<ExtensionCustomAction.Parameter> getParametersListFromMap(String actionName, Map parametersMap) {
|
protected List<ExtensionCustomAction.Parameter> getParametersListFromMap(String actionName, Map parametersMap) {
|
||||||
@ -549,7 +549,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
final Pair<Boolean, String> msPeerChecksumResult = getChecksumForExtensionPathOnMSPeer(extension,
|
final Pair<Boolean, String> msPeerChecksumResult = getChecksumForExtensionPathOnMSPeer(extension,
|
||||||
msHost);
|
msHost);
|
||||||
if (!msPeerChecksumResult.first() || !checksum.equals(msPeerChecksumResult.second())) {
|
if (!msPeerChecksumResult.first() || !checksum.equals(msPeerChecksumResult.second())) {
|
||||||
logger.error("Entry-point checksum for {} is different [msid: {}, checksum: {}] and [msid: {}, checksum: {}]",
|
logger.error("Path checksum for {} is different [msid: {}, checksum: {}] and [msid: {}, checksum: {}]",
|
||||||
extension, ManagementServerNode.getManagementServerId(), checksum, msHost.getMsid(),
|
extension, ManagementServerNode.getManagementServerId(), checksum, msHost.getMsid(),
|
||||||
(msPeerChecksumResult.first() ? msPeerChecksumResult.second() : "unknown"));
|
(msPeerChecksumResult.first() ? msPeerChecksumResult.second() : "unknown"));
|
||||||
updateExtensionPathReady(extension, false);
|
updateExtensionPathReady(extension, false);
|
||||||
@ -630,7 +630,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
!prepareExtensionPathAcrossServers(extensionVO)) {
|
!prepareExtensionPathAcrossServers(extensionVO)) {
|
||||||
disableExtension(extensionVO.getId());
|
disableExtension(extensionVO.getId());
|
||||||
throw new CloudRuntimeException(String.format(
|
throw new CloudRuntimeException(String.format(
|
||||||
"Failed to enable extension: %s as it entry-point is not ready",
|
"Failed to enable extension: %s as its path is not ready",
|
||||||
extensionVO.getName()));
|
extensionVO.getName()));
|
||||||
}
|
}
|
||||||
return extensionVO;
|
return extensionVO;
|
||||||
@ -736,7 +736,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana
|
|||||||
!prepareExtensionPathAcrossServers(result)) {
|
!prepareExtensionPathAcrossServers(result)) {
|
||||||
disableExtension(result.getId());
|
disableExtension(result.getId());
|
||||||
throw new CloudRuntimeException(String.format(
|
throw new CloudRuntimeException(String.format(
|
||||||
"Failed to enable extension: %s as it entry-point is not ready",
|
"Failed to enable extension: %s as it path is not ready",
|
||||||
extensionVO.getName()));
|
extensionVO.getName()));
|
||||||
}
|
}
|
||||||
updateAllExtensionHosts(extensionVO, null, false);
|
updateAllExtensionHosts(extensionVO, null, false);
|
||||||
|
|||||||
@ -631,18 +631,18 @@ public class ExternalPathPayloadProvisioner extends ManagerBase implements Exter
|
|||||||
}
|
}
|
||||||
if (!Files.isDirectory(filePath) && !Files.isRegularFile(filePath)) {
|
if (!Files.isDirectory(filePath) && !Files.isRegularFile(filePath)) {
|
||||||
throw new CloudRuntimeException(
|
throw new CloudRuntimeException(
|
||||||
String.format("Failed to cleanup extension entry-point: %s for extension: %s as it either " +
|
String.format("Failed to cleanup path: %s for extension: %s as it either " +
|
||||||
"does not exist or is not a regular file/directory",
|
"does not exist or is not a regular file/directory",
|
||||||
extensionName, extensionRelativePath));
|
extensionName, extensionRelativePath));
|
||||||
}
|
}
|
||||||
if (!FileUtil.deleteRecursively(filePath)) {
|
if (!FileUtil.deleteRecursively(filePath)) {
|
||||||
throw new CloudRuntimeException(
|
throw new CloudRuntimeException(
|
||||||
String.format("Failed to delete extension entry-point: %s for extension: %s",
|
String.format("Failed to delete path: %s for extension: %s",
|
||||||
extensionName, filePath));
|
extensionName, filePath));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new CloudRuntimeException(
|
throw new CloudRuntimeException(
|
||||||
String.format("Failed to cleanup extension entry-point: %s for extension: %s due to: %s",
|
String.format("Failed to cleanup path: %s for extension: %s due to: %s",
|
||||||
extensionName, normalizedPath, e.getMessage()), e);
|
extensionName, normalizedPath, e.getMessage()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,15 +46,15 @@
|
|||||||
<template #label>
|
<template #label>
|
||||||
<tooltip-label :title="$t('label.path')" :tooltip="apiParams.path.description"/>
|
<tooltip-label :title="$t('label.path')" :tooltip="apiParams.path.description"/>
|
||||||
</template>
|
</template>
|
||||||
<div class="entry-point-input-container">
|
<div class="path-input-container">
|
||||||
<span v-if="!!safeName" :title="extenstionBasePath" class="entry-point-input-base-path">
|
<span v-if="!!safeName" :title="extenstionBasePath" class="path-input-base">
|
||||||
{{ extenstionBasePath }}
|
{{ extenstionBasePath }}
|
||||||
</span>
|
</span>
|
||||||
<a-input
|
<a-input
|
||||||
v-model:value="form.path"
|
v-model:value="form.path"
|
||||||
:placeholder="apiParams.path.description"
|
:placeholder="apiParams.path.description"
|
||||||
@input="markPathModified"
|
@input="markPathModified"
|
||||||
class="entry-point-input-relative-path"
|
class="path-input-relative"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -236,20 +236,20 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry-point-input-container {
|
.path-input-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry-point-input-base-path {
|
.path-input-base {
|
||||||
max-width: 70%;
|
max-width: 70%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry-point-input-relative-path {
|
.path-input-relative {
|
||||||
flex: 1 1 0%;
|
flex: 1 1 0%;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user