mirror of
https://github.com/taylanbakircioglu/haproxy-openmanager.git
synced 2026-09-21 10:03:29 +00:00
feat: report invalid config format errors to backend for UI display
When config content doesn't look like valid HAProxy config (missing global/defaults/frontend/backend/listen keywords), agent now reports this to backend via config-validation-failed endpoint. This catches backend-side config generation errors (like Python exceptions) that prevented actual HAProxy config from being generated. Changes: - Add invalid config format detection and reporting in daemon mode - Use same curl pattern as existing HAProxy validation failure reporting - Same endpoint, headers, error handling, and spam prevention - Follows exact existing pattern for consistency - Does not affect self-upgrade flow (runs before upgrade check) Both linux and macos scripts updated identically.
This commit is contained in:
@@ -2824,6 +2824,28 @@ CONFIG_RESPONSE_EOF
|
||||
log "ERROR" "DAEMON: Configuration content does not appear to be valid HAProxy config"
|
||||
log "DEBUG" "DAEMON: Config preview: ${daemon_config_content:0:200}..."
|
||||
config_is_valid=false
|
||||
|
||||
# CRITICAL: Report this error to backend for UI display
|
||||
# This catches backend-side config generation errors (Python exceptions, etc.)
|
||||
config_error_preview="${daemon_config_content:0:500}"
|
||||
if [[ -n "$config_version" && "$config_version" != "$last_validation_failed_version" ]]; then
|
||||
log "INFO" "DAEMON: Reporting invalid config format to backend..."
|
||||
curl -k -s -X POST "$MANAGEMENT_URL/api/agents/$AGENT_NAME/config-validation-failed" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $CURRENT_AGENT_TOKEN" \
|
||||
-d "{\"status\": \"invalid_config_format\", \"version\": \"$config_version\", \"validation_error\": $(echo "Configuration does not appear to be valid HAProxy config. Content preview: $config_error_preview" | jq -Rs .)}" \
|
||||
>/dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "INFO" "DAEMON: Invalid config notification sent to backend"
|
||||
else
|
||||
log "WARN" "DAEMON: Failed to send invalid config notification to backend"
|
||||
fi
|
||||
|
||||
# Mark this version as validation failed to prevent repeated error logs
|
||||
# (same pattern as existing HAProxy validation failure at line ~3022)
|
||||
last_validation_failed_version="$config_version"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Only process config if it's valid
|
||||
|
||||
@@ -2772,6 +2772,28 @@ CONFIG_RESPONSE_EOF
|
||||
log "ERROR" "DAEMON: Configuration content does not appear to be valid HAProxy config"
|
||||
log "DEBUG" "DAEMON: Config preview: ${daemon_config_content:0:200}..."
|
||||
config_is_valid=false
|
||||
|
||||
# CRITICAL: Report this error to backend for UI display
|
||||
# This catches backend-side config generation errors (Python exceptions, etc.)
|
||||
config_error_preview="${daemon_config_content:0:500}"
|
||||
if [[ -n "$config_version" && "$config_version" != "$last_validation_failed_version" ]]; then
|
||||
log "INFO" "DAEMON: Reporting invalid config format to backend..."
|
||||
curl -k -s -X POST "$MANAGEMENT_URL/api/agents/$AGENT_NAME/config-validation-failed" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $CURRENT_AGENT_TOKEN" \
|
||||
-d "{\"status\": \"invalid_config_format\", \"version\": \"$config_version\", \"validation_error\": $(echo "Configuration does not appear to be valid HAProxy config. Content preview: $config_error_preview" | jq -Rs .)}" \
|
||||
>/dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "INFO" "DAEMON: Invalid config notification sent to backend"
|
||||
else
|
||||
log "WARN" "DAEMON: Failed to send invalid config notification to backend"
|
||||
fi
|
||||
|
||||
# Mark this version as validation failed to prevent repeated error logs
|
||||
# (same pattern as existing HAProxy validation failure at line ~2965)
|
||||
last_validation_failed_version="$config_version"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Only process config if it's valid
|
||||
|
||||
Reference in New Issue
Block a user