Skip to content

Instantly share code, notes, and snippets.

@jroyalty
Last active August 29, 2015 13:57
Show Gist options
  • Save jroyalty/9378265 to your computer and use it in GitHub Desktop.
Save jroyalty/9378265 to your computer and use it in GitHub Desktop.
Notes on where HAProxy handles the "observe" check

Various HTTP states along the pipline are grouped into HANA_STATUS_* codes, which are defined in checks.h. Then health_adjust() is called with that status code, which ends up calling __health_adjust() if the observe config parameter is enabled.

Example from proxy_http.c:

/* Adjust server's health based on status code. Note: status codes 501
 * and 505 are triggered on demand by client request, so we must not
 * count them as server failures.
 */
if (objt_server(s->target)) {
	if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505))
		health_adjust(objt_server(s->target), HANA_STATUS_HTTP_OK);
	else
		health_adjust(objt_server(s->target), HANA_STATUS_HTTP_STS);
}

Inside __health_adjust() (in checks.c)

  • lookup the status code in struct analyze_status (which is defined in checks.h)
  • if it's determined that we are in an error state then one of the HANA_ONERR_* actions is taken
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment