mirror of
https://github.com/taylanbakircioglu/haproxy-openmanager.git
synced 2026-09-21 01:53:24 +00:00
a36dd87a74
Found during an impact analysis of the agent-script change in PR #58. linux_install.sh contains TWO daemon implementations and which one runs depends on how the agent reached its current state: - Fresh install: the heredoc at lines 923-2646 is written to /usr/local/bin/haproxy-agent and systemd runs that file. - Self-upgrade: perform_agent_upgrade copies the downloaded INSTALLER script over that same path (`cp "$temp_script" "$current_script"` with current_script=/usr/local/bin/haproxy-agent). systemd then runs the installer with `daemon` + SKIP_TO_DAEMON=true, which takes the separate in-script daemon that lives after the heredoc. PR #58 added _kp_discover and the one-shot takeover only to the heredoc copy, so both were absent from the path that self-upgraded agents actually run — and self-upgrade is exactly the path the release notes tell operators to rely on ("nodes will pull the new script through the normal agent-upgrade path"). The feature would have worked on a freshly installed node and been silently inert on every upgraded one. The file's own banner warns about this ("check_agent_upgrade() - Multiple locations ... TIP: Search for function name to find all occurrences!"), and send_heartbeat / fetch_and_deploy_keepalived_config / get_haproxy_stats_csv are already maintained as parallel copies for the same reason. Verified empirically rather than by reading: the script was instrumented and run in a container exactly as systemd invokes it after an upgrade (SKIP_TO_DAEMON=true, `bash linux_install.sh daemon`), inspecting the live `declare -f fetch_and_deploy_keepalived_config`. before: DISCOVERY_YOK TAKEOVER_YOK after: DISCOVERY_VAR TAKEOVER_VAR ENDPOINT_VAR Both blocks are ported verbatim from the heredoc copy with indentation adjusted; no logic changed, so the guard semantics are identical in both paths — takeover still requires allow_takeover AND a non-empty expected hash AND a matching on-disk md5, and anything else falls through to the existing "externally managed — refusing to overwrite" branch. `bash -n` passes. Backend suite unchanged at 1263 passed.