mirror of https://github.com/halo-dev/halo
Merge pull request #7429 from JohnNiang/refactor/improve-failure-message-of-plugin
Show stack trace while failing to start pluginpull/7441/head
commit
3148fc3e31
|
@ -14,6 +14,8 @@ import static run.halo.app.plugin.PluginUtils.isDevelopmentMode;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
@ -302,25 +304,34 @@ public class PluginReconciler implements Reconciler<Request> {
|
|||
return Result.requeue(Duration.ofSeconds(1));
|
||||
}
|
||||
|
||||
PluginState pluginState;
|
||||
try {
|
||||
var pluginState = pluginManager.startPlugin(pluginName);
|
||||
if (!PluginState.STARTED.equals(pluginState)) {
|
||||
throw new IllegalStateException("""
|
||||
Failed to start plugin %s(%s).\
|
||||
""".formatted(pluginName, pluginState));
|
||||
}
|
||||
pluginState = pluginManager.startPlugin(pluginName);
|
||||
} catch (Throwable e) {
|
||||
log.debug("Error occurred when starting plugin {}", pluginName, e);
|
||||
var writer = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(writer));
|
||||
conditions.addAndEvictFIFO(Condition.builder()
|
||||
.type(ConditionType.READY)
|
||||
.status(ConditionStatus.FALSE)
|
||||
.reason(ConditionReason.START_ERROR)
|
||||
.message(e.getMessage())
|
||||
.message(writer.toString())
|
||||
.lastTransitionTime(clock.instant())
|
||||
.build());
|
||||
status.setPhase(Plugin.Phase.FAILED);
|
||||
return Result.doNotRetry();
|
||||
}
|
||||
if (!PluginState.STARTED.equals(pluginState)) {
|
||||
conditions.addAndEvictFIFO(Condition.builder()
|
||||
.type(ConditionType.READY)
|
||||
.status(ConditionStatus.FALSE)
|
||||
.reason(ConditionReason.START_ERROR)
|
||||
.message("Failed to start plugin " + pluginName + "(" + pluginState + ").")
|
||||
.lastTransitionTime(clock.instant())
|
||||
.build());
|
||||
status.setPhase(Plugin.Phase.FAILED);
|
||||
return Result.doNotRetry();
|
||||
}
|
||||
|
||||
removeConditionBy(conditions, ConditionType.PROGRESSING);
|
||||
status.setLastStartTime(clock.instant());
|
||||
|
|
|
@ -72,7 +72,7 @@ const modal = ref();
|
|||
{{ condition.reason || "-" }}
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-sm text-gray-500">
|
||||
{{ condition.message || "-" }}
|
||||
<pre>{{ condition.message || "-" }}</pre>
|
||||
</td>
|
||||
<td
|
||||
v-tooltip="formatDatetime(condition.lastTransitionTime)"
|
||||
|
|
|
@ -117,12 +117,12 @@ const lastCondition = computed(() => {
|
|||
v-if="errorAlertVisible && lastCondition"
|
||||
class="w-full px-4 pb-2 sm:px-6"
|
||||
>
|
||||
<VAlert
|
||||
type="error"
|
||||
:title="lastCondition.reason"
|
||||
:description="lastCondition.message"
|
||||
:closable="false"
|
||||
>
|
||||
<VAlert type="error" :title="lastCondition.reason" :closable="false">
|
||||
<template #description>
|
||||
<div class="overflow-x-auto">
|
||||
<pre>{{ lastCondition.message }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
<template #actions>
|
||||
<VButton size="sm" @click="conditionsModalVisible = true">
|
||||
{{ $t("core.plugin.detail.operations.view_conditions.button") }}
|
||||
|
|
Loading…
Reference in New Issue