Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public class DeleteExtensionCmd extends BaseCmd {
private Long id;

@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;

/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class ExtensionsManagerImpl extends ManagerBase implements ExtensionsMana

ConfigKey<Integer> PathStateCheckInterval = new ConfigKey<>("Advanced", Integer.class,
"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);

@Inject
Expand Down Expand Up @@ -260,19 +260,19 @@ protected Pair<Boolean, String> getResultFromAnswersString(String answersStr, Ex

protected boolean prepareExtensionPathOnMSPeer(Extension extension, ManagementServerHostVO msHost) {
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];
commands[0] = new PrepareExtensionPathCommand(ManagementServerNode.getManagementServerId(), extension);
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,
String relativePath) {
try {
externalProvisioner.prepareExtensionPath(name, userDefined, relativePath);
} 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);
return new Pair<>(false, e.getMessage());
}
Expand All @@ -281,38 +281,38 @@ protected Pair<Boolean, String> prepareExtensionPathOnCurrentServer(String name,

protected boolean cleanupExtensionFilesOnMSPeer(Extension extension, ManagementServerHostVO msHost) {
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];
commands[0] = new CleanupExtensionFilesCommand(ManagementServerNode.getManagementServerId(), extension);
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) {
try {
externalProvisioner.cleanupExtensionPath(name, relativePath);
externalProvisioner.cleanupExtensionData(name, 0, true);
} 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);
return new Pair<>(false, e.getMessage());
}
return new Pair<>(true, null);
}

protected void cleanupExtensionFilesAcrossServers(Extension extension) {
boolean cleanup = true;
boolean cleanedUp = true;
List<ManagementServerHostVO> msHosts = managementServerHostDao.listBy(ManagementServerHost.State.Up);
for (ManagementServerHostVO msHost : msHosts) {
if (msHost.getMsid() == ManagementServerNode.getManagementServerId()) {
cleanup = cleanup && cleanupExtensionFilesOnCurrentServer(extension.getName(),
cleanedUp = cleanedUp && cleanupExtensionFilesOnCurrentServer(extension.getName(),
extension.getRelativePath()).first();
continue;
}
cleanup = cleanup && cleanupExtensionFilesOnMSPeer(extension, msHost);
cleanedUp = cleanedUp && cleanupExtensionFilesOnMSPeer(extension, msHost);
}
if (!cleanup) {
throw new CloudRuntimeException("Extension is deleted but its entry-point files are not cleaned up across servers");
if (!cleanedUp) {
throw new CloudRuntimeException("Extension is deleted but its files are not cleaned up across servers");
}
}

Expand All @@ -323,7 +323,7 @@ protected Pair<Boolean, String> getChecksumForExtensionPathOnMSPeer(Extension ex
cmds[0] = new GetExtensionPathChecksumCommand(ManagementServerNode.getManagementServerId(),
extension);
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) {
Expand Down Expand Up @@ -518,7 +518,7 @@ protected void checkExtensionPathState(Extension extension, List<ManagementServe
final Pair<Boolean, String> msPeerChecksumResult = getChecksumForExtensionPathOnMSPeer(extension,
msHost);
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(),
(msPeerChecksumResult.first() ? msPeerChecksumResult.second() : "unknown"));
updateExtensionPathReady(extension, false);
Expand Down Expand Up @@ -599,7 +599,7 @@ public Extension createExtension(CreateExtensionCmd cmd) {
!prepareExtensionPathAcrossServers(extensionVO)) {
disableExtension(extensionVO.getId());
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()));
}
return extensionVO;
Expand Down Expand Up @@ -705,7 +705,7 @@ public Extension updateExtension(UpdateExtensionCmd cmd) {
!prepareExtensionPathAcrossServers(result)) {
disableExtension(result.getId());
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()));
}
updateAllExtensionHosts(extensionVO, null, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,18 +564,18 @@ public void cleanupExtensionPath(String extensionName, String extensionRelativeP
}
if (!Files.isDirectory(filePath) && !Files.isRegularFile(filePath)) {
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",
extensionName, extensionRelativePath));
}
if (!FileUtil.deleteRecursively(filePath)) {
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));
}
} catch (IOException e) {
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);
}
}
Expand Down
12 changes: 6 additions & 6 deletions ui/src/views/extension/CreateExtension.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
<template #label>
<tooltip-label :title="$t('label.path')" :tooltip="apiParams.path.description"/>
</template>
<div class="entry-point-input-container">
<span v-if="!!safeName" :title="extenstionBasePath" class="entry-point-input-base-path">
<div class="path-input-container">
<span v-if="!!safeName" :title="extenstionBasePath" class="path-input-base">
{{ extenstionBasePath }}
</span>
<a-input
v-model:value="form.path"
:placeholder="apiParams.path.description"
@input="markPathModified"
class="entry-point-input-relative-path"
class="path-input-relative"
/>
</div>
</a-form-item>
Expand Down Expand Up @@ -236,20 +236,20 @@ export default {
}
}

.entry-point-input-container {
.path-input-container {
display: flex;
align-items: center;
gap: 8px;
}

.entry-point-input-base-path {
.path-input-base {
max-width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.entry-point-input-relative-path {
.path-input-relative {
flex: 1 1 0%;
min-width: 0;
}
Expand Down
Loading