Skip to content

Commit

Permalink
refactor: Simplify node status JSON generation logging and output
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfreak30 committed Dec 18, 2024
1 parent e54b71d commit 38e3d63
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/etcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,7 @@ generate_node_status_json() {

# Debug logging for JSON generation
log_info "=== Generate Node Status JSON Debug ==="
log_info "Input status='$status' role='$role'"
log_info "HOST='$HOST' PORT='${MYSQL_EXTERNAL_PORT}'"

# Ensure role has a valid value
role="${role:-slave}"
if [ -z "$role" ] || [ "$role" = "null" ]; then
log_warn "Empty or null role detected in generate_node_status_json, forcing to 'slave'"
role="slave"
fi

# Generate JSON first without any logging
local json=$(jq -n \
--arg status "$status" \
--arg role "$role" \
Expand All @@ -177,10 +168,11 @@ generate_node_status_json() {
last_seen: $last_seen,
gtid_position: $gtid
} * $extra')

# Debug logging after JSON generation, not captured in output
log_info "Generated node status JSON for $status role=$role: $json"

log_info "Generated JSON: $json"
log_info "========================="

# Only output the JSON
echo "$json"
}

Expand Down

0 comments on commit 38e3d63

Please sign in to comment.