fix: keep all follower status compact
This commit is contained in:
@@ -71,7 +71,7 @@ function readConfigMapViaKubectl() {
|
||||
}
|
||||
}
|
||||
|
||||
function compactStateText(text) {
|
||||
function compactStateText(text, includeCommand) {
|
||||
if (typeof text !== "string" || text.length === 0) return null;
|
||||
let state;
|
||||
try {
|
||||
@@ -79,7 +79,7 @@ function compactStateText(text) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
const compact = {
|
||||
id: stringOrNull(state.id),
|
||||
adapter: stringOrNull(state.adapter),
|
||||
enabled: state.enabled === true,
|
||||
@@ -97,8 +97,9 @@ function compactStateText(text) {
|
||||
timings: compactTimings(state.timings),
|
||||
warnings: arrayStrings(state.warnings).slice(0, 6),
|
||||
stateFormat: stringOrNull(state.stateFormat),
|
||||
command: compactCommand(state.command),
|
||||
};
|
||||
if (includeCommand) compact.command = compactCommand(state.command);
|
||||
return compact;
|
||||
}
|
||||
|
||||
function compactCommand(command) {
|
||||
@@ -335,11 +336,12 @@ const valueBytes = {};
|
||||
|
||||
if (result.ok && result.present) {
|
||||
const data = recordOrNull(result.object?.data) || {};
|
||||
const includeCommand = followerIds.length === 1;
|
||||
for (const id of followerIds) {
|
||||
const text = typeof data[id] === "string" ? data[id] : "";
|
||||
if (text.length === 0) continue;
|
||||
valueBytes[id] = Buffer.byteLength(text, "utf8");
|
||||
const compact = compactStateText(text);
|
||||
const compact = compactStateText(text, includeCommand);
|
||||
if (compact === null) errors.push(`${id}: invalid state json`);
|
||||
else stateByFollower[id] = compact;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user