mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-16 06:38:03 +00:00
MINOR: checks: use check->state instead of srv->state & SRV_CHECKED
Having the check state partially stored in the server doesn't help. Some functions such as srv_getinter() rely on the server being checked to decide what check frequency to use, instead of relying on the check being configured. So let's get rid of SRV_CHECKED and SRV_AGENT_CHECKED and only use the check's states instead.
This commit is contained in:
parent
2e10f5a759
commit
ff5ae35b9f
@ -48,7 +48,7 @@
|
||||
#define SRV_BACKUP 0x0002 /* this server is a backup server */
|
||||
#define SRV_MAPPORTS 0x0004 /* this server uses mapped ports */
|
||||
/* unused: 0x0008 */
|
||||
#define SRV_CHECKED 0x0010 /* this server needs to be checked */
|
||||
/* unused: 0x0010 */
|
||||
#define SRV_GOINGDOWN 0x0020 /* this server says that it's going down (404) */
|
||||
#define SRV_WARMINGUP 0x0040 /* this server is warming up after a failure */
|
||||
#define SRV_MAINTAIN 0x0080 /* this server is in maintenance mode */
|
||||
@ -56,9 +56,6 @@
|
||||
/* unused: 0x0200, 0x0400 */
|
||||
#define SRV_SEND_PROXY 0x0800 /* this server talks the PROXY protocol */
|
||||
#define SRV_NON_STICK 0x1000 /* never add connections allocated to this server to a stick table */
|
||||
#define SRV_AGENT_CHECKED 0x2000 /* this server needs to be checked using an agent check.
|
||||
* This is run independently of the main check whose
|
||||
* presence is indicated by the SRV_CHECKED flag */
|
||||
|
||||
/* function which act on servers need to return various errors */
|
||||
#define SRV_STATUS_OK 0 /* everything is OK. */
|
||||
|
@ -1443,7 +1443,7 @@ smp_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, unsigned int
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_BOOL;
|
||||
if (!(srv->state & SRV_MAINTAIN) &&
|
||||
(!(srv->state & SRV_CHECKED) || (srv->state & SRV_RUNNING)))
|
||||
(!(srv->check.state & CHK_ST_CONFIGURED) || (srv->state & SRV_RUNNING)))
|
||||
smp->data.uint = 1;
|
||||
else
|
||||
smp->data.uint = 0;
|
||||
|
@ -5124,7 +5124,6 @@ stats_error_parsing:
|
||||
}
|
||||
|
||||
newsrv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
|
||||
newsrv->state |= SRV_CHECKED;
|
||||
}
|
||||
|
||||
if (do_agent) {
|
||||
@ -5147,7 +5146,6 @@ stats_error_parsing:
|
||||
}
|
||||
|
||||
newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
|
||||
newsrv->state |= SRV_AGENT_CHECKED;
|
||||
}
|
||||
|
||||
if (!defsrv) {
|
||||
@ -7018,7 +7016,7 @@ out_uri_auth_compat:
|
||||
goto next_srv;
|
||||
}
|
||||
|
||||
if (!(srv->state & SRV_CHECKED)) {
|
||||
if (!(srv->check.state & CHK_ST_CONFIGURED)) {
|
||||
Alert("config : %s '%s', server '%s': unable to use %s/%s for "
|
||||
"tracking as it does not have checks enabled.\n",
|
||||
proxy_type_str(curproxy), curproxy->id,
|
||||
|
12
src/checks.c
12
src/checks.c
@ -736,8 +736,8 @@ static int httpchk_build_status_header(struct server *s, char *buffer)
|
||||
memcpy(buffer + hlen, "X-Haproxy-Server-State: ", 24);
|
||||
hlen += 24;
|
||||
|
||||
if (!(s->state & SRV_CHECKED))
|
||||
sv_state = 6; /* should obviously never happen */
|
||||
if (!(s->check.state & CHK_ST_ENABLED))
|
||||
sv_state = 6;
|
||||
else if (s->state & SRV_RUNNING) {
|
||||
if (s->check.health == s->check.rise + s->check.fall - 1)
|
||||
sv_state = 3; /* UP */
|
||||
@ -1506,7 +1506,7 @@ static struct task *process_chk(struct task *t)
|
||||
* stopped, the server should not be checked or the check
|
||||
* is disabled.
|
||||
*/
|
||||
if (!(s->state & SRV_CHECKED) ||
|
||||
if (!(s->check.state & CHK_ST_ENABLED) ||
|
||||
s->proxy->state == PR_STSTOPPED ||
|
||||
(s->state & SRV_MAINTAIN) ||
|
||||
!(check->state & CHK_ST_ENABLED))
|
||||
@ -1764,7 +1764,7 @@ int start_checks() {
|
||||
t->expire = TICK_ETERNITY;
|
||||
}
|
||||
|
||||
if (!(s->state & SRV_CHECKED))
|
||||
if (!(s->check.state & CHK_ST_CONFIGURED))
|
||||
continue;
|
||||
|
||||
if ((srv_getinter(&s->check) >= SRV_CHK_INTER_THRES) &&
|
||||
@ -1788,14 +1788,14 @@ int start_checks() {
|
||||
for (px = proxy; px; px = px->next) {
|
||||
for (s = px->srv; s; s = s->next) {
|
||||
/* A task for the main check */
|
||||
if (s->state & SRV_CHECKED) {
|
||||
if (s->check.state & CHK_ST_CONFIGURED) {
|
||||
if (!start_check_task(&s->check, mininter, nbcheck, srvpos))
|
||||
return -1;
|
||||
srvpos++;
|
||||
}
|
||||
|
||||
/* A task for a auxiliary agent check */
|
||||
if (s->state & SRV_AGENT_CHECKED) {
|
||||
if (s->agent.state & CHK_ST_CONFIGURED) {
|
||||
if (!start_check_task(&s->agent, mininter, nbcheck, srvpos)) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -2716,7 +2716,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
|
||||
chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1));
|
||||
chunk_appendf(&trash, "MAINT(via)");
|
||||
}
|
||||
else if (ref->state & SRV_CHECKED) {
|
||||
else if (ref->check.state & CHK_ST_ENABLED) {
|
||||
chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1));
|
||||
chunk_appendf(&trash,
|
||||
srv_hlt_st[state],
|
||||
@ -2724,7 +2724,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
|
||||
(ref->state & SRV_RUNNING) ? (ref->check.fall) : (ref->check.rise));
|
||||
}
|
||||
|
||||
if (sv->state & SRV_CHECKED) {
|
||||
if (sv->check.state & CHK_ST_ENABLED) {
|
||||
chunk_appendf(&trash,
|
||||
"</td><td class=ac><u> %s%s",
|
||||
(sv->check.state & CHK_ST_INPROGRESS) ? "* " : "",
|
||||
@ -2759,7 +2759,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
|
||||
(sv->state & SRV_BACKUP) ? "Y" : "-");
|
||||
|
||||
/* check failures: unique, fatal, down time */
|
||||
if (sv->state & SRV_CHECKED) {
|
||||
if (sv->check.state & CHK_ST_ENABLED) {
|
||||
chunk_appendf(&trash, "<td><u>%lld", ref->counters.failed_checks);
|
||||
|
||||
if (ref->observe)
|
||||
@ -2848,7 +2848,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
|
||||
(sv->state & SRV_BACKUP) ? 1 : 0);
|
||||
|
||||
/* check failures: unique, fatal; last change, total downtime */
|
||||
if (sv->state & SRV_CHECKED)
|
||||
if (sv->check.state & CHK_ST_ENABLED)
|
||||
chunk_appendf(&trash,
|
||||
"%lld,%lld,%d,%d,",
|
||||
sv->counters.failed_checks, sv->counters.down_trans,
|
||||
@ -2885,7 +2885,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
|
||||
read_freq_ctr(&sv->sess_per_sec),
|
||||
sv->counters.sps_max);
|
||||
|
||||
if (sv->state & SRV_CHECKED) {
|
||||
if (sv->check.state & CHK_ST_ENABLED) {
|
||||
/* check_status */
|
||||
chunk_appendf(&trash, "%s,", get_check_status_info(sv->check.status));
|
||||
|
||||
@ -3407,7 +3407,7 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
|
||||
svs = sv;
|
||||
|
||||
/* FIXME: produce some small strings for "UP/DOWN x/y &#xxxx;" */
|
||||
if (!(svs->state & SRV_CHECKED))
|
||||
if (!(svs->check.state & CHK_ST_ENABLED))
|
||||
sv_state = 8;
|
||||
else if (svs->state & SRV_RUNNING) {
|
||||
if (svs->check.health == svs->check.rise + svs->check.fall - 1)
|
||||
|
@ -34,7 +34,7 @@ int srv_getinter(const struct check *check)
|
||||
{
|
||||
const struct server *s = check->server;
|
||||
|
||||
if ((s->state & SRV_CHECKED) && (check->health == check->rise + check->fall - 1))
|
||||
if ((check->state & CHK_ST_CONFIGURED) && (check->health == check->rise + check->fall - 1))
|
||||
return check->inter;
|
||||
|
||||
if (!(s->state & SRV_RUNNING) && check->health == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user