mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MEDIUM: check: server states and weight propagation re-work
The server state and weight was reworked to handle "pending" values updated by checks/CLI/LUA/agent. These values are commited to be propagated to the LB stack. In further dev related to multi-thread, the commit will be handled into a sync point. Pending values are named using the prefix 'next_' Current values used by the LB stack are named 'cur_'
This commit is contained in:
parent
de2075fd21
commit
52a91d3d48
@ -63,18 +63,19 @@ static void inline be_set_sess_last(struct proxy *be)
|
|||||||
be->be_counters.last_sess = now.tv_sec;
|
be->be_counters.last_sess = now.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns non-zero if the designated server is usable for LB
|
/* This function returns non-zero if the designated server will be
|
||||||
* according to its current weight and current state. Otherwise it returns 0.
|
* usable for LB according to pending weight and state.
|
||||||
|
* Otherwise it returns 0.
|
||||||
*/
|
*/
|
||||||
static inline int srv_is_usable(const struct server *srv)
|
static inline int srv_willbe_usable(const struct server *srv)
|
||||||
{
|
{
|
||||||
enum srv_state state = srv->state;
|
enum srv_state state = srv->next_state;
|
||||||
|
|
||||||
if (!srv->eweight)
|
if (!srv->next_eweight)
|
||||||
return 0;
|
return 0;
|
||||||
if (srv->admin & SRV_ADMF_MAINT)
|
if (srv->next_admin & SRV_ADMF_MAINT)
|
||||||
return 0;
|
return 0;
|
||||||
if (srv->admin & SRV_ADMF_DRAIN)
|
if (srv->next_admin & SRV_ADMF_DRAIN)
|
||||||
return 0;
|
return 0;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SRV_ST_STARTING:
|
case SRV_ST_STARTING:
|
||||||
@ -88,17 +89,17 @@ static inline int srv_is_usable(const struct server *srv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns non-zero if the designated server was usable for LB
|
/* This function returns non-zero if the designated server was usable for LB
|
||||||
* according to its current weight and previous state. Otherwise it returns 0.
|
* according to its current weight and state. Otherwise it returns 0.
|
||||||
*/
|
*/
|
||||||
static inline int srv_was_usable(const struct server *srv)
|
static inline int srv_currently_usable(const struct server *srv)
|
||||||
{
|
{
|
||||||
enum srv_state state = srv->prev_state;
|
enum srv_state state = srv->cur_state;
|
||||||
|
|
||||||
if (!srv->prev_eweight)
|
if (!srv->cur_eweight)
|
||||||
return 0;
|
return 0;
|
||||||
if (srv->prev_admin & SRV_ADMF_MAINT)
|
if (srv->cur_admin & SRV_ADMF_MAINT)
|
||||||
return 0;
|
return 0;
|
||||||
if (srv->prev_admin & SRV_ADMF_DRAIN)
|
if (srv->cur_admin & SRV_ADMF_DRAIN)
|
||||||
return 0;
|
return 0;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SRV_ST_STARTING:
|
case SRV_ST_STARTING:
|
||||||
@ -111,14 +112,14 @@ static inline int srv_was_usable(const struct server *srv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function commits the current server state and weight onto the previous
|
/* This function commits the next server state and weight onto the current
|
||||||
* ones in order to detect future changes.
|
* ones in order to detect future changes.
|
||||||
*/
|
*/
|
||||||
static inline void srv_lb_commit_status(struct server *srv)
|
static inline void srv_lb_commit_status(struct server *srv)
|
||||||
{
|
{
|
||||||
srv->prev_state = srv->state;
|
srv->cur_state = srv->next_state;
|
||||||
srv->prev_admin = srv->admin;
|
srv->cur_admin = srv->next_admin;
|
||||||
srv->prev_eweight = srv->eweight;
|
srv->cur_eweight = srv->next_eweight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns true when a server has experienced a change since last
|
/* This function returns true when a server has experienced a change since last
|
||||||
@ -126,9 +127,9 @@ static inline void srv_lb_commit_status(struct server *srv)
|
|||||||
*/
|
*/
|
||||||
static inline int srv_lb_status_changed(const struct server *srv)
|
static inline int srv_lb_status_changed(const struct server *srv)
|
||||||
{
|
{
|
||||||
return (srv->state != srv->prev_state ||
|
return (srv->next_state != srv->cur_state ||
|
||||||
srv->admin != srv->prev_admin ||
|
srv->next_admin != srv->cur_admin ||
|
||||||
srv->eweight != srv->prev_eweight);
|
srv->next_eweight != srv->cur_eweight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sends a log message when a backend goes down, and also sets last
|
/* sends a log message when a backend goes down, and also sets last
|
||||||
|
@ -54,7 +54,7 @@ static inline int server_has_room(const struct server *s) {
|
|||||||
* for and if/else usage.
|
* for and if/else usage.
|
||||||
*/
|
*/
|
||||||
static inline int may_dequeue_tasks(const struct server *s, const struct proxy *p) {
|
static inline int may_dequeue_tasks(const struct server *s, const struct proxy *p) {
|
||||||
return (s && (s->nbpend || (p->nbpend && srv_is_usable(s))) &&
|
return (s && (s->nbpend || (p->nbpend && srv_currently_usable(s))) &&
|
||||||
(!s->maxconn || s->cur_sess < srv_dynamic_maxconn(s)));
|
(!s->maxconn || s->cur_sess < srv_dynamic_maxconn(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ static inline unsigned int server_throttle_rate(struct server *sv)
|
|||||||
if (!sv->uweight)
|
if (!sv->uweight)
|
||||||
return 100;
|
return 100;
|
||||||
|
|
||||||
return (100U * px->lbprm.wmult * sv->eweight + px->lbprm.wdiv - 1) / (px->lbprm.wdiv * sv->uweight);
|
return (100U * px->lbprm.wmult * sv->cur_eweight + px->lbprm.wdiv - 1) / (px->lbprm.wdiv * sv->uweight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -134,7 +134,7 @@ const char *server_parse_maxconn_change_request(struct server *sv,
|
|||||||
*/
|
*/
|
||||||
static inline int server_is_draining(const struct server *s)
|
static inline int server_is_draining(const struct server *s)
|
||||||
{
|
{
|
||||||
return !s->uweight || (s->admin & SRV_ADMF_DRAIN);
|
return !s->uweight || (s->cur_admin & SRV_ADMF_DRAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shutdown all connections of a server. The caller must pass a termination
|
/* Shutdown all connections of a server. The caller must pass a termination
|
||||||
|
@ -186,8 +186,8 @@ struct tree_occ {
|
|||||||
|
|
||||||
struct server {
|
struct server {
|
||||||
enum obj_type obj_type; /* object type == OBJ_TYPE_SERVER */
|
enum obj_type obj_type; /* object type == OBJ_TYPE_SERVER */
|
||||||
enum srv_state state, prev_state; /* server state among SRV_ST_* */
|
enum srv_state next_state, cur_state; /* server state among SRV_ST_* */
|
||||||
enum srv_admin admin, prev_admin; /* server maintenance status : SRV_ADMF_* */
|
enum srv_admin next_admin, cur_admin; /* server maintenance status : SRV_ADMF_* */
|
||||||
unsigned char pp_opts; /* proxy protocol options (SRV_PP_*) */
|
unsigned char pp_opts; /* proxy protocol options (SRV_PP_*) */
|
||||||
unsigned int flags; /* server flags (SRV_F_*) */
|
unsigned int flags; /* server flags (SRV_F_*) */
|
||||||
struct server *next;
|
struct server *next;
|
||||||
@ -226,9 +226,9 @@ struct server {
|
|||||||
int slowstart; /* slowstart time in seconds (ms in the conf) */
|
int slowstart; /* slowstart time in seconds (ms in the conf) */
|
||||||
|
|
||||||
char *id; /* just for identification */
|
char *id; /* just for identification */
|
||||||
unsigned iweight,uweight, eweight; /* initial weight, user-specified weight, and effective weight */
|
unsigned iweight,uweight, cur_eweight; /* initial weight, user-specified weight, and effective weight */
|
||||||
unsigned wscore; /* weight score, used during srv map computation */
|
unsigned wscore; /* weight score, used during srv map computation */
|
||||||
unsigned prev_eweight; /* eweight before last change */
|
unsigned next_eweight; /* next pending eweight to commit */
|
||||||
unsigned rweight; /* remainer of weight in the current LB tree */
|
unsigned rweight; /* remainer of weight in the current LB tree */
|
||||||
unsigned cumulative_weight; /* weight of servers prior to this one in the same group, for chash balancing */
|
unsigned cumulative_weight; /* weight of servers prior to this one in the same group, for chash balancing */
|
||||||
unsigned npos, lpos; /* next and last positions in the LB tree */
|
unsigned npos, lpos; /* next and last positions in the LB tree */
|
||||||
|
@ -97,6 +97,8 @@ static unsigned int gen_hash(const struct proxy* px, const char* key, unsigned l
|
|||||||
* This function also recomputes the total active and backup weights. However,
|
* This function also recomputes the total active and backup weights. However,
|
||||||
* it does not update tot_weight nor tot_used. Use update_backend_weight() for
|
* it does not update tot_weight nor tot_used. Use update_backend_weight() for
|
||||||
* this.
|
* this.
|
||||||
|
* This functions is designed to be called before server's weight and state
|
||||||
|
* commit so it uses 'next' weight and states values.
|
||||||
*/
|
*/
|
||||||
void recount_servers(struct proxy *px)
|
void recount_servers(struct proxy *px)
|
||||||
{
|
{
|
||||||
@ -106,7 +108,7 @@ void recount_servers(struct proxy *px)
|
|||||||
px->lbprm.tot_wact = px->lbprm.tot_wbck = 0;
|
px->lbprm.tot_wact = px->lbprm.tot_wbck = 0;
|
||||||
px->lbprm.fbck = NULL;
|
px->lbprm.fbck = NULL;
|
||||||
for (srv = px->srv; srv != NULL; srv = srv->next) {
|
for (srv = px->srv; srv != NULL; srv = srv->next) {
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_willbe_usable(srv))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
@ -115,11 +117,11 @@ void recount_servers(struct proxy *px)
|
|||||||
px->lbprm.fbck = srv;
|
px->lbprm.fbck = srv;
|
||||||
px->srv_bck++;
|
px->srv_bck++;
|
||||||
srv->cumulative_weight = px->lbprm.tot_wbck;
|
srv->cumulative_weight = px->lbprm.tot_wbck;
|
||||||
px->lbprm.tot_wbck += srv->eweight;
|
px->lbprm.tot_wbck += srv->next_eweight;
|
||||||
} else {
|
} else {
|
||||||
px->srv_act++;
|
px->srv_act++;
|
||||||
srv->cumulative_weight = px->lbprm.tot_wact;
|
srv->cumulative_weight = px->lbprm.tot_wact;
|
||||||
px->lbprm.tot_wact += srv->eweight;
|
px->lbprm.tot_wact += srv->next_eweight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +138,7 @@ void update_backend_weight(struct proxy *px)
|
|||||||
}
|
}
|
||||||
else if (px->lbprm.fbck) {
|
else if (px->lbprm.fbck) {
|
||||||
/* use only the first backup server */
|
/* use only the first backup server */
|
||||||
px->lbprm.tot_weight = px->lbprm.fbck->eweight;
|
px->lbprm.tot_weight = px->lbprm.fbck->next_eweight;
|
||||||
px->lbprm.tot_used = 1;
|
px->lbprm.tot_used = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -567,7 +569,7 @@ int assign_server(struct stream *s)
|
|||||||
(!s->be->max_ka_queue ||
|
(!s->be->max_ka_queue ||
|
||||||
server_has_room(__objt_server(conn->target)) ||
|
server_has_room(__objt_server(conn->target)) ||
|
||||||
(__objt_server(conn->target)->nbpend + 1) < s->be->max_ka_queue))) &&
|
(__objt_server(conn->target)->nbpend + 1) < s->be->max_ka_queue))) &&
|
||||||
srv_is_usable(__objt_server(conn->target))) {
|
srv_currently_usable(__objt_server(conn->target))) {
|
||||||
/* This stream was relying on a server in a previous request
|
/* This stream was relying on a server in a previous request
|
||||||
* and the proxy has "option prefer-last-server" set
|
* and the proxy has "option prefer-last-server" set
|
||||||
* and balance algorithm dont tell us to do otherwise, so
|
* and balance algorithm dont tell us to do otherwise, so
|
||||||
@ -1387,7 +1389,7 @@ int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit)
|
|||||||
if (srv->addr.ss_family == AF_INET &&
|
if (srv->addr.ss_family == AF_INET &&
|
||||||
port == srv->svc_port &&
|
port == srv->svc_port &&
|
||||||
addr == ((struct sockaddr_in *)&srv->addr)->sin_addr.s_addr) {
|
addr == ((struct sockaddr_in *)&srv->addr)->sin_addr.s_addr) {
|
||||||
if ((srv->state != SRV_ST_STOPPED) || (px->options & PR_O_PERSIST)) {
|
if ((srv->cur_state != SRV_ST_STOPPED) || (px->options & PR_O_PERSIST)) {
|
||||||
/* we found the server and it is usable */
|
/* we found the server and it is usable */
|
||||||
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
||||||
s->target = &srv->obj_type;
|
s->target = &srv->obj_type;
|
||||||
@ -1631,8 +1633,8 @@ smp_fetch_srv_is_up(const struct arg *args, struct sample *smp, const char *kw,
|
|||||||
|
|
||||||
smp->flags = SMP_F_VOL_TEST;
|
smp->flags = SMP_F_VOL_TEST;
|
||||||
smp->data.type = SMP_T_BOOL;
|
smp->data.type = SMP_T_BOOL;
|
||||||
if (!(srv->admin & SRV_ADMF_MAINT) &&
|
if (!(srv->cur_admin & SRV_ADMF_MAINT) &&
|
||||||
(!(srv->check.state & CHK_ST_CONFIGURED) || (srv->state != SRV_ST_STOPPED)))
|
(!(srv->check.state & CHK_ST_CONFIGURED) || (srv->cur_state != SRV_ST_STOPPED)))
|
||||||
smp->data.u.sint = 1;
|
smp->data.u.sint = 1;
|
||||||
else
|
else
|
||||||
smp->data.u.sint = 0;
|
smp->data.u.sint = 0;
|
||||||
@ -1653,7 +1655,7 @@ smp_fetch_connslots(const struct arg *args, struct sample *smp, const char *kw,
|
|||||||
smp->data.u.sint = 0;
|
smp->data.u.sint = 0;
|
||||||
|
|
||||||
for (iterator = args->data.prx->srv; iterator; iterator = iterator->next) {
|
for (iterator = args->data.prx->srv; iterator; iterator = iterator->next) {
|
||||||
if (iterator->state == SRV_ST_STOPPED)
|
if (iterator->cur_state == SRV_ST_STOPPED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iterator->maxconn == 0 || iterator->maxqueue == 0) {
|
if (iterator->maxconn == 0 || iterator->maxqueue == 0) {
|
||||||
|
32
src/checks.c
32
src/checks.c
@ -359,10 +359,10 @@ static void check_notify_success(struct check *check)
|
|||||||
{
|
{
|
||||||
struct server *s = check->server;
|
struct server *s = check->server;
|
||||||
|
|
||||||
if (s->admin & SRV_ADMF_MAINT)
|
if (s->next_admin & SRV_ADMF_MAINT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s->track && s->track->state == SRV_ST_STOPPED)
|
if (s->track && s->track->next_state == SRV_ST_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((s->check.state & CHK_ST_ENABLED) && (s->check.health < s->check.rise))
|
if ((s->check.state & CHK_ST_ENABLED) && (s->check.health < s->check.rise))
|
||||||
@ -371,7 +371,7 @@ static void check_notify_success(struct check *check)
|
|||||||
if ((s->agent.state & CHK_ST_ENABLED) && (s->agent.health < s->agent.rise))
|
if ((s->agent.state & CHK_ST_ENABLED) && (s->agent.health < s->agent.rise))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((check->state & CHK_ST_AGENT) && s->state == SRV_ST_STOPPING)
|
if ((check->state & CHK_ST_AGENT) && s->next_state == SRV_ST_STOPPING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
srv_set_running(s, (!s->track && !(s->proxy->options2 & PR_O2_LOGHCHKS)) ? check_reason_string(check) : NULL);
|
srv_set_running(s, (!s->track && !(s->proxy->options2 & PR_O2_LOGHCHKS)) ? check_reason_string(check) : NULL);
|
||||||
@ -387,13 +387,13 @@ static void check_notify_stopping(struct check *check)
|
|||||||
{
|
{
|
||||||
struct server *s = check->server;
|
struct server *s = check->server;
|
||||||
|
|
||||||
if (s->admin & SRV_ADMF_MAINT)
|
if (s->next_admin & SRV_ADMF_MAINT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (check->state & CHK_ST_AGENT)
|
if (check->state & CHK_ST_AGENT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s->track && s->track->state == SRV_ST_STOPPED)
|
if (s->track && s->track->next_state == SRV_ST_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((s->check.state & CHK_ST_ENABLED) && (s->check.health < s->check.rise))
|
if ((s->check.state & CHK_ST_ENABLED) && (s->check.health < s->check.rise))
|
||||||
@ -506,13 +506,13 @@ static int httpchk_build_status_header(struct server *s, char *buffer, int size)
|
|||||||
|
|
||||||
if (!(s->check.state & CHK_ST_ENABLED))
|
if (!(s->check.state & CHK_ST_ENABLED))
|
||||||
sv_state = 6;
|
sv_state = 6;
|
||||||
else if (s->state != SRV_ST_STOPPED) {
|
else if (s->cur_state != SRV_ST_STOPPED) {
|
||||||
if (s->check.health == s->check.rise + s->check.fall - 1)
|
if (s->check.health == s->check.rise + s->check.fall - 1)
|
||||||
sv_state = 3; /* UP */
|
sv_state = 3; /* UP */
|
||||||
else
|
else
|
||||||
sv_state = 2; /* going down */
|
sv_state = 2; /* going down */
|
||||||
|
|
||||||
if (s->state == SRV_ST_STOPPING)
|
if (s->cur_state == SRV_ST_STOPPING)
|
||||||
sv_state += 2;
|
sv_state += 2;
|
||||||
} else {
|
} else {
|
||||||
if (s->check.health)
|
if (s->check.health)
|
||||||
@ -523,8 +523,8 @@ static int httpchk_build_status_header(struct server *s, char *buffer, int size)
|
|||||||
|
|
||||||
hlen += snprintf(buffer + hlen, size - hlen,
|
hlen += snprintf(buffer + hlen, size - hlen,
|
||||||
srv_hlt_st[sv_state],
|
srv_hlt_st[sv_state],
|
||||||
(s->state != SRV_ST_STOPPED) ? (s->check.health - s->check.rise + 1) : (s->check.health),
|
(s->cur_state != SRV_ST_STOPPED) ? (s->check.health - s->check.rise + 1) : (s->check.health),
|
||||||
(s->state != SRV_ST_STOPPED) ? (s->check.fall) : (s->check.rise));
|
(s->cur_state != SRV_ST_STOPPED) ? (s->check.fall) : (s->check.rise));
|
||||||
|
|
||||||
addr_to_str(&s->addr, addr, sizeof(addr));
|
addr_to_str(&s->addr, addr, sizeof(addr));
|
||||||
if (s->addr.ss_family == AF_INET || s->addr.ss_family == AF_INET6)
|
if (s->addr.ss_family == AF_INET || s->addr.ss_family == AF_INET6)
|
||||||
@ -535,12 +535,12 @@ static int httpchk_build_status_header(struct server *s, char *buffer, int size)
|
|||||||
hlen += snprintf(buffer + hlen, size - hlen, "; address=%s; port=%s; name=%s/%s; node=%s; weight=%d/%d; scur=%d/%d; qcur=%d",
|
hlen += snprintf(buffer + hlen, size - hlen, "; address=%s; port=%s; name=%s/%s; node=%s; weight=%d/%d; scur=%d/%d; qcur=%d",
|
||||||
addr, port, s->proxy->id, s->id,
|
addr, port, s->proxy->id, s->id,
|
||||||
global.node,
|
global.node,
|
||||||
(s->eweight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,
|
(s->cur_eweight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,
|
||||||
(s->proxy->lbprm.tot_weight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,
|
(s->proxy->lbprm.tot_weight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,
|
||||||
s->cur_sess, s->proxy->beconn - s->proxy->nbpend,
|
s->cur_sess, s->proxy->beconn - s->proxy->nbpend,
|
||||||
s->nbpend);
|
s->nbpend);
|
||||||
|
|
||||||
if ((s->state == SRV_ST_STARTING) &&
|
if ((s->cur_state == SRV_ST_STARTING) &&
|
||||||
now.tv_sec < s->last_change + s->slowstart &&
|
now.tv_sec < s->last_change + s->slowstart &&
|
||||||
now.tv_sec >= s->last_change) {
|
now.tv_sec >= s->last_change) {
|
||||||
ratio = MAX(1, 100 * (now.tv_sec - s->last_change) / s->slowstart);
|
ratio = MAX(1, 100 * (now.tv_sec - s->last_change) / s->slowstart);
|
||||||
@ -879,7 +879,7 @@ static void event_srv_chk_r(struct connection *conn)
|
|||||||
desc = ltrim(check->bi->data + 12, ' ');
|
desc = ltrim(check->bi->data + 12, ' ');
|
||||||
|
|
||||||
if ((s->proxy->options & PR_O_DISABLE404) &&
|
if ((s->proxy->options & PR_O_DISABLE404) &&
|
||||||
(s->state != SRV_ST_STOPPED) && (check->code == 404)) {
|
(s->next_state != SRV_ST_STOPPED) && (check->code == 404)) {
|
||||||
/* 404 may be accepted as "stopping" only if the server was up */
|
/* 404 may be accepted as "stopping" only if the server was up */
|
||||||
cut_crlf(desc);
|
cut_crlf(desc);
|
||||||
set_server_check_status(check, HCHK_STATUS_L7OKCD, desc);
|
set_server_check_status(check, HCHK_STATUS_L7OKCD, desc);
|
||||||
@ -1427,8 +1427,8 @@ static struct task *server_warmup(struct task *t)
|
|||||||
|
|
||||||
/* by default, plan on stopping the task */
|
/* by default, plan on stopping the task */
|
||||||
t->expire = TICK_ETERNITY;
|
t->expire = TICK_ETERNITY;
|
||||||
if ((s->admin & SRV_ADMF_MAINT) ||
|
if ((s->next_admin & SRV_ADMF_MAINT) ||
|
||||||
(s->state != SRV_ST_STARTING))
|
(s->next_state != SRV_ST_STARTING))
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
/* recalculate the weights and update the state */
|
/* recalculate the weights and update the state */
|
||||||
@ -1440,7 +1440,7 @@ static struct task *server_warmup(struct task *t)
|
|||||||
/* get back there in 1 second or 1/20th of the slowstart interval,
|
/* get back there in 1 second or 1/20th of the slowstart interval,
|
||||||
* whichever is greater, resulting in small 5% steps.
|
* whichever is greater, resulting in small 5% steps.
|
||||||
*/
|
*/
|
||||||
if (s->state == SRV_ST_STARTING)
|
if (s->next_state == SRV_ST_STARTING)
|
||||||
t->expire = tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20)));
|
t->expire = tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20)));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -2276,7 +2276,7 @@ static int start_checks()
|
|||||||
t->process = server_warmup;
|
t->process = server_warmup;
|
||||||
t->context = s;
|
t->context = s;
|
||||||
/* server can be in this state only because of */
|
/* server can be in this state only because of */
|
||||||
if (s->state == SRV_ST_STARTING)
|
if (s->next_state == SRV_ST_STARTING)
|
||||||
task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, (now.tv_sec - s->last_change)) / 20)));
|
task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, (now.tv_sec - s->last_change)) / 20)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ static void sig_dump_state(struct sig_handler *sh)
|
|||||||
chunk_printf(&trash,
|
chunk_printf(&trash,
|
||||||
"SIGHUP: Server %s/%s is %s. Conn: %d act, %d pend, %lld tot.",
|
"SIGHUP: Server %s/%s is %s. Conn: %d act, %d pend, %lld tot.",
|
||||||
p->id, s->id,
|
p->id, s->id,
|
||||||
(s->state != SRV_ST_STOPPED) ? "UP" : "DOWN",
|
(s->cur_state != SRV_ST_STOPPED) ? "UP" : "DOWN",
|
||||||
s->cur_sess, s->nbpend, s->counters.cum_sess);
|
s->cur_sess, s->nbpend, s->counters.cum_sess);
|
||||||
Warning("%s\n", trash.str);
|
Warning("%s\n", trash.str);
|
||||||
send_log(p, LOG_NOTICE, "%s\n", trash.str);
|
send_log(p, LOG_NOTICE, "%s\n", trash.str);
|
||||||
|
@ -7625,7 +7625,7 @@ void hlua_init(void)
|
|||||||
LIST_INIT(&socket_tcp.priv_conns);
|
LIST_INIT(&socket_tcp.priv_conns);
|
||||||
LIST_INIT(&socket_tcp.idle_conns);
|
LIST_INIT(&socket_tcp.idle_conns);
|
||||||
LIST_INIT(&socket_tcp.safe_conns);
|
LIST_INIT(&socket_tcp.safe_conns);
|
||||||
socket_tcp.state = SRV_ST_RUNNING; /* early server setup */
|
socket_tcp.next_state = SRV_ST_RUNNING; /* early server setup */
|
||||||
socket_tcp.last_change = 0;
|
socket_tcp.last_change = 0;
|
||||||
socket_tcp.id = "LUA-TCP-CONN";
|
socket_tcp.id = "LUA-TCP-CONN";
|
||||||
socket_tcp.check.state &= ~CHK_ST_ENABLED; /* Disable health checks. */
|
socket_tcp.check.state &= ~CHK_ST_ENABLED; /* Disable health checks. */
|
||||||
@ -7671,7 +7671,7 @@ void hlua_init(void)
|
|||||||
LIST_INIT(&socket_ssl.priv_conns);
|
LIST_INIT(&socket_ssl.priv_conns);
|
||||||
LIST_INIT(&socket_ssl.idle_conns);
|
LIST_INIT(&socket_ssl.idle_conns);
|
||||||
LIST_INIT(&socket_ssl.safe_conns);
|
LIST_INIT(&socket_ssl.safe_conns);
|
||||||
socket_ssl.state = SRV_ST_RUNNING; /* early server setup */
|
socket_ssl.next_state = SRV_ST_RUNNING; /* early server setup */
|
||||||
socket_ssl.last_change = 0;
|
socket_ssl.last_change = 0;
|
||||||
socket_ssl.id = "LUA-SSL-CONN";
|
socket_ssl.id = "LUA-SSL-CONN";
|
||||||
socket_ssl.check.state &= ~CHK_ST_ENABLED; /* Disable health checks. */
|
socket_ssl.check.state &= ~CHK_ST_ENABLED; /* Disable health checks. */
|
||||||
|
@ -69,7 +69,7 @@ static inline void chash_dequeue_srv(struct server *s)
|
|||||||
*/
|
*/
|
||||||
static inline void chash_queue_dequeue_srv(struct server *s)
|
static inline void chash_queue_dequeue_srv(struct server *s)
|
||||||
{
|
{
|
||||||
while (s->lb_nodes_now > s->eweight) {
|
while (s->lb_nodes_now > s->next_eweight) {
|
||||||
if (s->lb_nodes_now >= s->lb_nodes_tot) // should always be false anyway
|
if (s->lb_nodes_now >= s->lb_nodes_tot) // should always be false anyway
|
||||||
s->lb_nodes_now = s->lb_nodes_tot;
|
s->lb_nodes_now = s->lb_nodes_tot;
|
||||||
s->lb_nodes_now--;
|
s->lb_nodes_now--;
|
||||||
@ -78,7 +78,7 @@ static inline void chash_queue_dequeue_srv(struct server *s)
|
|||||||
eb32_delete(&s->lb_nodes[s->lb_nodes_now].node);
|
eb32_delete(&s->lb_nodes[s->lb_nodes_now].node);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s->lb_nodes_now < s->eweight) {
|
while (s->lb_nodes_now < s->next_eweight) {
|
||||||
if (s->lb_nodes_now >= s->lb_nodes_tot) // should always be false anyway
|
if (s->lb_nodes_now >= s->lb_nodes_tot) // should always be false anyway
|
||||||
break;
|
break;
|
||||||
if (s->proxy->lbprm.chash.last == &s->lb_nodes[s->lb_nodes_now].node)
|
if (s->proxy->lbprm.chash.last == &s->lb_nodes[s->lb_nodes_now].node)
|
||||||
@ -101,15 +101,15 @@ static void chash_set_server_status_down(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (srv_is_usable(srv))
|
if (srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (!srv_was_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
/* server was already down */
|
/* server was already down */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck -= srv->prev_eweight;
|
p->lbprm.tot_wbck -= srv->cur_eweight;
|
||||||
p->srv_bck--;
|
p->srv_bck--;
|
||||||
|
|
||||||
if (srv == p->lbprm.fbck) {
|
if (srv == p->lbprm.fbck) {
|
||||||
@ -121,11 +121,11 @@ static void chash_set_server_status_down(struct server *srv)
|
|||||||
srv2 = srv2->next;
|
srv2 = srv2->next;
|
||||||
} while (srv2 &&
|
} while (srv2 &&
|
||||||
!((srv2->flags & SRV_F_BACKUP) &&
|
!((srv2->flags & SRV_F_BACKUP) &&
|
||||||
srv_is_usable(srv2)));
|
srv_willbe_usable(srv2)));
|
||||||
p->lbprm.fbck = srv2;
|
p->lbprm.fbck = srv2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p->lbprm.tot_wact -= srv->prev_eweight;
|
p->lbprm.tot_wact -= srv->cur_eweight;
|
||||||
p->srv_act--;
|
p->srv_act--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,15 +152,15 @@ static void chash_set_server_status_up(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (srv_was_usable(srv))
|
if (srv_currently_usable(srv))
|
||||||
/* server was already up */
|
/* server was already up */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck += srv->eweight;
|
p->lbprm.tot_wbck += srv->next_eweight;
|
||||||
p->srv_bck++;
|
p->srv_bck++;
|
||||||
|
|
||||||
if (!(p->options & PR_O_USE_ALL_BK)) {
|
if (!(p->options & PR_O_USE_ALL_BK)) {
|
||||||
@ -180,7 +180,7 @@ static void chash_set_server_status_up(struct server *srv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p->lbprm.tot_wact += srv->eweight;
|
p->lbprm.tot_wact += srv->next_eweight;
|
||||||
p->srv_act++;
|
p->srv_act++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,8 +213,8 @@ static void chash_update_server_weight(struct server *srv)
|
|||||||
* possibly a new tree for this server.
|
* possibly a new tree for this server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
old_state = srv_was_usable(srv);
|
old_state = srv_currently_usable(srv);
|
||||||
new_state = srv_is_usable(srv);
|
new_state = srv_willbe_usable(srv);
|
||||||
|
|
||||||
if (!old_state && !new_state) {
|
if (!old_state && !new_state) {
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
@ -233,9 +233,9 @@ static void chash_update_server_weight(struct server *srv)
|
|||||||
chash_queue_dequeue_srv(srv);
|
chash_queue_dequeue_srv(srv);
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP)
|
if (srv->flags & SRV_F_BACKUP)
|
||||||
p->lbprm.tot_wbck += srv->eweight - srv->prev_eweight;
|
p->lbprm.tot_wbck += srv->next_eweight - srv->cur_eweight;
|
||||||
else
|
else
|
||||||
p->lbprm.tot_wact += srv->eweight - srv->prev_eweight;
|
p->lbprm.tot_wact += srv->next_eweight - srv->cur_eweight;
|
||||||
|
|
||||||
update_backend_weight(p);
|
update_backend_weight(p);
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
@ -256,10 +256,10 @@ int chash_server_is_eligible(struct server *s)
|
|||||||
unsigned remainder = tot_slots % s->proxy->lbprm.tot_weight;
|
unsigned remainder = tot_slots % s->proxy->lbprm.tot_weight;
|
||||||
|
|
||||||
/* Allocate a whole number of slots per weight unit... */
|
/* Allocate a whole number of slots per weight unit... */
|
||||||
unsigned slots = s->eweight * slots_per_weight;
|
unsigned slots = s->cur_eweight * slots_per_weight;
|
||||||
|
|
||||||
/* And then distribute the rest among servers proportionally to their weight. */
|
/* And then distribute the rest among servers proportionally to their weight. */
|
||||||
slots += ((s->cumulative_weight + s->eweight) * remainder) / s->proxy->lbprm.tot_weight
|
slots += ((s->cumulative_weight + s->cur_eweight) * remainder) / s->proxy->lbprm.tot_weight
|
||||||
- (s->cumulative_weight * remainder) / s->proxy->lbprm.tot_weight;
|
- (s->cumulative_weight * remainder) / s->proxy->lbprm.tot_weight;
|
||||||
|
|
||||||
/* But never leave a server with 0. */
|
/* But never leave a server with 0. */
|
||||||
@ -418,7 +418,7 @@ void chash_init_server_tree(struct proxy *p)
|
|||||||
|
|
||||||
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
srv->eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
srv->next_eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ void chash_init_server_tree(struct proxy *p)
|
|||||||
srv->lb_nodes[node].node.key = full_hash(srv->puid * SRV_EWGHT_RANGE + node);
|
srv->lb_nodes[node].node.key = full_hash(srv->puid * SRV_EWGHT_RANGE + node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srv_is_usable(srv))
|
if (srv_currently_usable(srv))
|
||||||
chash_queue_dequeue_srv(srv);
|
chash_queue_dequeue_srv(srv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
src/lb_fas.c
30
src/lb_fas.c
@ -80,15 +80,15 @@ static void fas_set_server_status_down(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (srv_is_usable(srv))
|
if (srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (!srv_was_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
/* server was already down */
|
/* server was already down */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck -= srv->prev_eweight;
|
p->lbprm.tot_wbck -= srv->cur_eweight;
|
||||||
p->srv_bck--;
|
p->srv_bck--;
|
||||||
|
|
||||||
if (srv == p->lbprm.fbck) {
|
if (srv == p->lbprm.fbck) {
|
||||||
@ -100,11 +100,11 @@ static void fas_set_server_status_down(struct server *srv)
|
|||||||
srv2 = srv2->next;
|
srv2 = srv2->next;
|
||||||
} while (srv2 &&
|
} while (srv2 &&
|
||||||
!((srv2->flags & SRV_F_BACKUP) &&
|
!((srv2->flags & SRV_F_BACKUP) &&
|
||||||
srv_is_usable(srv2)));
|
srv_willbe_usable(srv2)));
|
||||||
p->lbprm.fbck = srv2;
|
p->lbprm.fbck = srv2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p->lbprm.tot_wact -= srv->prev_eweight;
|
p->lbprm.tot_wact -= srv->cur_eweight;
|
||||||
p->srv_act--;
|
p->srv_act--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,16 +132,16 @@ static void fas_set_server_status_up(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (srv_was_usable(srv))
|
if (srv_currently_usable(srv))
|
||||||
/* server was already up */
|
/* server was already up */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
srv->lb_tree = &p->lbprm.fas.bck;
|
srv->lb_tree = &p->lbprm.fas.bck;
|
||||||
p->lbprm.tot_wbck += srv->eweight;
|
p->lbprm.tot_wbck += srv->next_eweight;
|
||||||
p->srv_bck++;
|
p->srv_bck++;
|
||||||
|
|
||||||
if (!(p->options & PR_O_USE_ALL_BK)) {
|
if (!(p->options & PR_O_USE_ALL_BK)) {
|
||||||
@ -162,7 +162,7 @@ static void fas_set_server_status_up(struct server *srv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
srv->lb_tree = &p->lbprm.fas.act;
|
srv->lb_tree = &p->lbprm.fas.act;
|
||||||
p->lbprm.tot_wact += srv->eweight;
|
p->lbprm.tot_wact += srv->next_eweight;
|
||||||
p->srv_act++;
|
p->srv_act++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +195,8 @@ static void fas_update_server_weight(struct server *srv)
|
|||||||
* possibly a new tree for this server.
|
* possibly a new tree for this server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
old_state = srv_was_usable(srv);
|
old_state = srv_currently_usable(srv);
|
||||||
new_state = srv_is_usable(srv);
|
new_state = srv_willbe_usable(srv);
|
||||||
|
|
||||||
if (!old_state && !new_state) {
|
if (!old_state && !new_state) {
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
@ -215,10 +215,10 @@ static void fas_update_server_weight(struct server *srv)
|
|||||||
fas_dequeue_srv(srv);
|
fas_dequeue_srv(srv);
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck += srv->eweight - srv->prev_eweight;
|
p->lbprm.tot_wbck += srv->next_eweight - srv->cur_eweight;
|
||||||
srv->lb_tree = &p->lbprm.fas.bck;
|
srv->lb_tree = &p->lbprm.fas.bck;
|
||||||
} else {
|
} else {
|
||||||
p->lbprm.tot_wact += srv->eweight - srv->prev_eweight;
|
p->lbprm.tot_wact += srv->next_eweight - srv->cur_eweight;
|
||||||
srv->lb_tree = &p->lbprm.fas.act;
|
srv->lb_tree = &p->lbprm.fas.act;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ void fas_init_server_tree(struct proxy *p)
|
|||||||
|
|
||||||
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
srv->eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
srv->next_eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ void fas_init_server_tree(struct proxy *p)
|
|||||||
|
|
||||||
/* queue active and backup servers in two distinct groups */
|
/* queue active and backup servers in two distinct groups */
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
continue;
|
continue;
|
||||||
srv->lb_tree = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fas.bck : &p->lbprm.fas.act;
|
srv->lb_tree = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fas.bck : &p->lbprm.fas.act;
|
||||||
fas_queue_srv(srv);
|
fas_queue_srv(srv);
|
||||||
|
@ -43,7 +43,7 @@ static inline void fwlc_dequeue_srv(struct server *s)
|
|||||||
*/
|
*/
|
||||||
static inline void fwlc_queue_srv(struct server *s)
|
static inline void fwlc_queue_srv(struct server *s)
|
||||||
{
|
{
|
||||||
s->lb_node.key = s->served * SRV_EWGHT_MAX / s->eweight;
|
s->lb_node.key = s->served * SRV_EWGHT_MAX / s->next_eweight;
|
||||||
eb32_insert(s->lb_tree, &s->lb_node);
|
eb32_insert(s->lb_tree, &s->lb_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,15 +72,15 @@ static void fwlc_set_server_status_down(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (srv_is_usable(srv))
|
if (srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (!srv_was_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
/* server was already down */
|
/* server was already down */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck -= srv->prev_eweight;
|
p->lbprm.tot_wbck -= srv->cur_eweight;
|
||||||
p->srv_bck--;
|
p->srv_bck--;
|
||||||
|
|
||||||
if (srv == p->lbprm.fbck) {
|
if (srv == p->lbprm.fbck) {
|
||||||
@ -92,11 +92,11 @@ static void fwlc_set_server_status_down(struct server *srv)
|
|||||||
srv2 = srv2->next;
|
srv2 = srv2->next;
|
||||||
} while (srv2 &&
|
} while (srv2 &&
|
||||||
!((srv2->flags & SRV_F_BACKUP) &&
|
!((srv2->flags & SRV_F_BACKUP) &&
|
||||||
srv_is_usable(srv2)));
|
srv_willbe_usable(srv2)));
|
||||||
p->lbprm.fbck = srv2;
|
p->lbprm.fbck = srv2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p->lbprm.tot_wact -= srv->prev_eweight;
|
p->lbprm.tot_wact -= srv->cur_eweight;
|
||||||
p->srv_act--;
|
p->srv_act--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,16 +124,16 @@ static void fwlc_set_server_status_up(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (srv_was_usable(srv))
|
if (srv_currently_usable(srv))
|
||||||
/* server was already up */
|
/* server was already up */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
srv->lb_tree = &p->lbprm.fwlc.bck;
|
srv->lb_tree = &p->lbprm.fwlc.bck;
|
||||||
p->lbprm.tot_wbck += srv->eweight;
|
p->lbprm.tot_wbck += srv->next_eweight;
|
||||||
p->srv_bck++;
|
p->srv_bck++;
|
||||||
|
|
||||||
if (!(p->options & PR_O_USE_ALL_BK)) {
|
if (!(p->options & PR_O_USE_ALL_BK)) {
|
||||||
@ -154,7 +154,7 @@ static void fwlc_set_server_status_up(struct server *srv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
srv->lb_tree = &p->lbprm.fwlc.act;
|
srv->lb_tree = &p->lbprm.fwlc.act;
|
||||||
p->lbprm.tot_wact += srv->eweight;
|
p->lbprm.tot_wact += srv->next_eweight;
|
||||||
p->srv_act++;
|
p->srv_act++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,8 +187,8 @@ static void fwlc_update_server_weight(struct server *srv)
|
|||||||
* possibly a new tree for this server.
|
* possibly a new tree for this server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
old_state = srv_was_usable(srv);
|
old_state = srv_currently_usable(srv);
|
||||||
new_state = srv_is_usable(srv);
|
new_state = srv_willbe_usable(srv);
|
||||||
|
|
||||||
if (!old_state && !new_state) {
|
if (!old_state && !new_state) {
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
@ -207,10 +207,10 @@ static void fwlc_update_server_weight(struct server *srv)
|
|||||||
fwlc_dequeue_srv(srv);
|
fwlc_dequeue_srv(srv);
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck += srv->eweight - srv->prev_eweight;
|
p->lbprm.tot_wbck += srv->next_eweight - srv->cur_eweight;
|
||||||
srv->lb_tree = &p->lbprm.fwlc.bck;
|
srv->lb_tree = &p->lbprm.fwlc.bck;
|
||||||
} else {
|
} else {
|
||||||
p->lbprm.tot_wact += srv->eweight - srv->prev_eweight;
|
p->lbprm.tot_wact += srv->next_eweight - srv->cur_eweight;
|
||||||
srv->lb_tree = &p->lbprm.fwlc.act;
|
srv->lb_tree = &p->lbprm.fwlc.act;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ void fwlc_init_server_tree(struct proxy *p)
|
|||||||
|
|
||||||
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
srv->eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
srv->next_eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ void fwlc_init_server_tree(struct proxy *p)
|
|||||||
|
|
||||||
/* queue active and backup servers in two distinct groups */
|
/* queue active and backup servers in two distinct groups */
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
continue;
|
continue;
|
||||||
srv->lb_tree = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwlc.bck : &p->lbprm.fwlc.act;
|
srv->lb_tree = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwlc.bck : &p->lbprm.fwlc.act;
|
||||||
fwlc_queue_srv(srv);
|
fwlc_queue_srv(srv);
|
||||||
|
@ -42,15 +42,15 @@ static void fwrr_set_server_status_down(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (srv_is_usable(srv))
|
if (srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (!srv_was_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
/* server was already down */
|
/* server was already down */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
grp = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwrr.bck : &p->lbprm.fwrr.act;
|
grp = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwrr.bck : &p->lbprm.fwrr.act;
|
||||||
grp->next_weight -= srv->prev_eweight;
|
grp->next_weight -= srv->cur_eweight;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck = p->lbprm.fwrr.bck.next_weight;
|
p->lbprm.tot_wbck = p->lbprm.fwrr.bck.next_weight;
|
||||||
@ -65,7 +65,7 @@ static void fwrr_set_server_status_down(struct server *srv)
|
|||||||
srv2 = srv2->next;
|
srv2 = srv2->next;
|
||||||
} while (srv2 &&
|
} while (srv2 &&
|
||||||
!((srv2->flags & SRV_F_BACKUP) &&
|
!((srv2->flags & SRV_F_BACKUP) &&
|
||||||
srv_is_usable(srv2)));
|
srv_willbe_usable(srv2)));
|
||||||
p->lbprm.fbck = srv2;
|
p->lbprm.fbck = srv2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -98,15 +98,15 @@ static void fwrr_set_server_status_up(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
if (srv_was_usable(srv))
|
if (srv_currently_usable(srv))
|
||||||
/* server was already up */
|
/* server was already up */
|
||||||
goto out_update_backend;
|
goto out_update_backend;
|
||||||
|
|
||||||
grp = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwrr.bck : &p->lbprm.fwrr.act;
|
grp = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwrr.bck : &p->lbprm.fwrr.act;
|
||||||
grp->next_weight += srv->eweight;
|
grp->next_weight += srv->next_eweight;
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP) {
|
if (srv->flags & SRV_F_BACKUP) {
|
||||||
p->lbprm.tot_wbck = p->lbprm.fwrr.bck.next_weight;
|
p->lbprm.tot_wbck = p->lbprm.fwrr.bck.next_weight;
|
||||||
@ -135,7 +135,7 @@ static void fwrr_set_server_status_up(struct server *srv)
|
|||||||
|
|
||||||
/* note that eweight cannot be 0 here */
|
/* note that eweight cannot be 0 here */
|
||||||
fwrr_get_srv(srv);
|
fwrr_get_srv(srv);
|
||||||
srv->npos = grp->curr_pos + (grp->next_weight + grp->curr_weight - grp->curr_pos) / srv->eweight;
|
srv->npos = grp->curr_pos + (grp->next_weight + grp->curr_weight - grp->curr_pos) / srv->next_eweight;
|
||||||
fwrr_queue_srv(srv);
|
fwrr_queue_srv(srv);
|
||||||
|
|
||||||
out_update_backend:
|
out_update_backend:
|
||||||
@ -165,8 +165,8 @@ static void fwrr_update_server_weight(struct server *srv)
|
|||||||
* possibly a new tree for this server.
|
* possibly a new tree for this server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
old_state = srv_was_usable(srv);
|
old_state = srv_currently_usable(srv);
|
||||||
new_state = srv_is_usable(srv);
|
new_state = srv_willbe_usable(srv);
|
||||||
|
|
||||||
if (!old_state && !new_state) {
|
if (!old_state && !new_state) {
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
@ -182,7 +182,7 @@ static void fwrr_update_server_weight(struct server *srv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
grp = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwrr.bck : &p->lbprm.fwrr.act;
|
grp = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwrr.bck : &p->lbprm.fwrr.act;
|
||||||
grp->next_weight = grp->next_weight - srv->prev_eweight + srv->eweight;
|
grp->next_weight = grp->next_weight - srv->cur_eweight + srv->next_eweight;
|
||||||
|
|
||||||
p->lbprm.tot_wact = p->lbprm.fwrr.act.next_weight;
|
p->lbprm.tot_wact = p->lbprm.fwrr.act.next_weight;
|
||||||
p->lbprm.tot_wbck = p->lbprm.fwrr.bck.next_weight;
|
p->lbprm.tot_wbck = p->lbprm.fwrr.bck.next_weight;
|
||||||
@ -197,7 +197,7 @@ static void fwrr_update_server_weight(struct server *srv)
|
|||||||
*/
|
*/
|
||||||
fwrr_dequeue_srv(srv);
|
fwrr_dequeue_srv(srv);
|
||||||
fwrr_get_srv(srv);
|
fwrr_get_srv(srv);
|
||||||
srv->npos = grp->curr_pos + (grp->next_weight + grp->curr_weight - grp->curr_pos) / srv->eweight;
|
srv->npos = grp->curr_pos + (grp->next_weight + grp->curr_weight - grp->curr_pos) / srv->next_eweight;
|
||||||
fwrr_queue_srv(srv);
|
fwrr_queue_srv(srv);
|
||||||
} else {
|
} else {
|
||||||
/* The server is either active or in the next queue. If it's
|
/* The server is either active or in the next queue. If it's
|
||||||
@ -206,9 +206,9 @@ static void fwrr_update_server_weight(struct server *srv)
|
|||||||
*/
|
*/
|
||||||
fwrr_get_srv(srv);
|
fwrr_get_srv(srv);
|
||||||
|
|
||||||
if (srv->eweight > 0) {
|
if (srv->next_eweight > 0) {
|
||||||
int prev_next = srv->npos;
|
int prev_next = srv->npos;
|
||||||
int step = grp->next_weight / srv->eweight;
|
int step = grp->next_weight / srv->next_eweight;
|
||||||
|
|
||||||
srv->npos = srv->lpos + step;
|
srv->npos = srv->lpos + step;
|
||||||
srv->rweight = 0;
|
srv->rweight = 0;
|
||||||
@ -245,7 +245,7 @@ static inline void fwrr_remove_from_tree(struct server *s)
|
|||||||
*/
|
*/
|
||||||
static inline void fwrr_queue_by_weight(struct eb_root *root, struct server *s)
|
static inline void fwrr_queue_by_weight(struct eb_root *root, struct server *s)
|
||||||
{
|
{
|
||||||
s->lb_node.key = SRV_EWGHT_MAX - s->eweight;
|
s->lb_node.key = SRV_EWGHT_MAX - s->next_eweight;
|
||||||
eb32_insert(root, &s->lb_node);
|
eb32_insert(root, &s->lb_node);
|
||||||
s->lb_tree = root;
|
s->lb_tree = root;
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ void fwrr_init_server_groups(struct proxy *p)
|
|||||||
|
|
||||||
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
p->lbprm.wdiv = BE_WEIGHT_SCALE;
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
srv->eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
srv->next_eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
||||||
srv_lb_commit_status(srv);
|
srv_lb_commit_status(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ void fwrr_init_server_groups(struct proxy *p)
|
|||||||
|
|
||||||
/* queue active and backup servers in two distinct groups */
|
/* queue active and backup servers in two distinct groups */
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_currently_usable(srv))
|
||||||
continue;
|
continue;
|
||||||
fwrr_queue_by_weight((srv->flags & SRV_F_BACKUP) ?
|
fwrr_queue_by_weight((srv->flags & SRV_F_BACKUP) ?
|
||||||
p->lbprm.fwrr.bck.init :
|
p->lbprm.fwrr.bck.init :
|
||||||
@ -319,10 +319,10 @@ static void fwrr_queue_srv(struct server *s)
|
|||||||
/* Delay everything which does not fit into the window and everything
|
/* Delay everything which does not fit into the window and everything
|
||||||
* which does not fit into the theorical new window.
|
* which does not fit into the theorical new window.
|
||||||
*/
|
*/
|
||||||
if (!srv_is_usable(s)) {
|
if (!srv_willbe_usable(s)) {
|
||||||
fwrr_remove_from_tree(s);
|
fwrr_remove_from_tree(s);
|
||||||
}
|
}
|
||||||
else if (s->eweight <= 0 ||
|
else if (s->next_eweight <= 0 ||
|
||||||
s->npos >= 2 * grp->curr_weight ||
|
s->npos >= 2 * grp->curr_weight ||
|
||||||
s->npos >= grp->curr_weight + grp->next_weight) {
|
s->npos >= grp->curr_weight + grp->next_weight) {
|
||||||
/* put into next tree, and readjust npos in case we could
|
/* put into next tree, and readjust npos in case we could
|
||||||
@ -339,7 +339,7 @@ static void fwrr_queue_srv(struct server *s)
|
|||||||
* so we can use eb32_insert().
|
* so we can use eb32_insert().
|
||||||
*/
|
*/
|
||||||
s->lb_node.key = SRV_UWGHT_RANGE * s->npos +
|
s->lb_node.key = SRV_UWGHT_RANGE * s->npos +
|
||||||
(unsigned)(SRV_EWGHT_MAX + s->rweight - s->eweight) / BE_WEIGHT_SCALE;
|
(unsigned)(SRV_EWGHT_MAX + s->rweight - s->next_eweight) / BE_WEIGHT_SCALE;
|
||||||
|
|
||||||
eb32_insert(&grp->curr, &s->lb_node);
|
eb32_insert(&grp->curr, &s->lb_node);
|
||||||
s->lb_tree = &grp->curr;
|
s->lb_tree = &grp->curr;
|
||||||
@ -423,7 +423,7 @@ static struct server *fwrr_get_server_from_group(struct fwrr_group *grp)
|
|||||||
node = node2;
|
node = node2;
|
||||||
s = eb32_entry(node, struct server, lb_node);
|
s = eb32_entry(node, struct server, lb_node);
|
||||||
fwrr_get_srv_init(s);
|
fwrr_get_srv_init(s);
|
||||||
if (s->eweight == 0) /* FIXME: is it possible at all ? */
|
if (s->cur_eweight == 0) /* FIXME: is it possible at all ? */
|
||||||
node = NULL;
|
node = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,20 +441,20 @@ static inline void fwrr_update_position(struct fwrr_group *grp, struct server *s
|
|||||||
if (!s->npos) {
|
if (!s->npos) {
|
||||||
/* first time ever for this server */
|
/* first time ever for this server */
|
||||||
s->lpos = grp->curr_pos;
|
s->lpos = grp->curr_pos;
|
||||||
s->npos = grp->curr_pos + grp->next_weight / s->eweight;
|
s->npos = grp->curr_pos + grp->next_weight / s->cur_eweight;
|
||||||
s->rweight += grp->next_weight % s->eweight;
|
s->rweight += grp->next_weight % s->cur_eweight;
|
||||||
|
|
||||||
if (s->rweight >= s->eweight) {
|
if (s->rweight >= s->cur_eweight) {
|
||||||
s->rweight -= s->eweight;
|
s->rweight -= s->cur_eweight;
|
||||||
s->npos++;
|
s->npos++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s->lpos = s->npos;
|
s->lpos = s->npos;
|
||||||
s->npos += grp->next_weight / s->eweight;
|
s->npos += grp->next_weight / s->cur_eweight;
|
||||||
s->rweight += grp->next_weight % s->eweight;
|
s->rweight += grp->next_weight % s->cur_eweight;
|
||||||
|
|
||||||
if (s->rweight >= s->eweight) {
|
if (s->rweight >= s->cur_eweight) {
|
||||||
s->rweight -= s->eweight;
|
s->rweight -= s->cur_eweight;
|
||||||
s->npos++;
|
s->npos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
src/lb_map.c
16
src/lb_map.c
@ -31,7 +31,7 @@ static void map_set_server_status_down(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (srv_is_usable(srv))
|
if (srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
/* FIXME: could be optimized since we know what changed */
|
/* FIXME: could be optimized since we know what changed */
|
||||||
@ -50,7 +50,7 @@ static void map_set_server_status_up(struct server *srv)
|
|||||||
if (!srv_lb_status_changed(srv))
|
if (!srv_lb_status_changed(srv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!srv_is_usable(srv))
|
if (!srv_willbe_usable(srv))
|
||||||
goto out_update_state;
|
goto out_update_state;
|
||||||
|
|
||||||
/* FIXME: could be optimized since we know what changed */
|
/* FIXME: could be optimized since we know what changed */
|
||||||
@ -100,7 +100,7 @@ void recalc_server_map(struct proxy *px)
|
|||||||
best = NULL;
|
best = NULL;
|
||||||
for (cur = px->srv; cur; cur = cur->next) {
|
for (cur = px->srv; cur; cur = cur->next) {
|
||||||
if ((cur->flags & SRV_F_BACKUP) == flag &&
|
if ((cur->flags & SRV_F_BACKUP) == flag &&
|
||||||
srv_is_usable(cur)) {
|
srv_willbe_usable(cur)) {
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
/* If we are forced to return only one server, we don't want to
|
/* If we are forced to return only one server, we don't want to
|
||||||
@ -113,7 +113,7 @@ void recalc_server_map(struct proxy *px)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->wscore += cur->eweight;
|
cur->wscore += cur->next_eweight;
|
||||||
v = (cur->wscore + tot) / tot; /* result between 0 and 3 */
|
v = (cur->wscore + tot) / tot; /* result between 0 and 3 */
|
||||||
if (best == NULL || v > max) {
|
if (best == NULL || v > max) {
|
||||||
max = v;
|
max = v;
|
||||||
@ -175,13 +175,13 @@ void init_server_map(struct proxy *p)
|
|||||||
|
|
||||||
act = bck = 0;
|
act = bck = 0;
|
||||||
for (srv = p->srv; srv; srv = srv->next) {
|
for (srv = p->srv; srv; srv = srv->next) {
|
||||||
srv->eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
srv->next_eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult;
|
||||||
srv_lb_commit_status(srv);
|
|
||||||
|
|
||||||
if (srv->flags & SRV_F_BACKUP)
|
if (srv->flags & SRV_F_BACKUP)
|
||||||
bck += srv->eweight;
|
bck += srv->next_eweight;
|
||||||
else
|
else
|
||||||
act += srv->eweight;
|
act += srv->next_eweight;
|
||||||
|
srv_lb_commit_status(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is the largest map we will ever need for this servers list */
|
/* this is the largest map we will ever need for this servers list */
|
||||||
|
@ -7861,12 +7861,12 @@ void manage_client_side_cookies(struct stream *s, struct channel *req)
|
|||||||
while (srv) {
|
while (srv) {
|
||||||
if (srv->cookie && (srv->cklen == delim - val_beg) &&
|
if (srv->cookie && (srv->cklen == delim - val_beg) &&
|
||||||
!memcmp(val_beg, srv->cookie, delim - val_beg)) {
|
!memcmp(val_beg, srv->cookie, delim - val_beg)) {
|
||||||
if ((srv->state != SRV_ST_STOPPED) ||
|
if ((srv->cur_state != SRV_ST_STOPPED) ||
|
||||||
(s->be->options & PR_O_PERSIST) ||
|
(s->be->options & PR_O_PERSIST) ||
|
||||||
(s->flags & SF_FORCE_PRST)) {
|
(s->flags & SF_FORCE_PRST)) {
|
||||||
/* we found the server and we can use it */
|
/* we found the server and we can use it */
|
||||||
txn->flags &= ~TX_CK_MASK;
|
txn->flags &= ~TX_CK_MASK;
|
||||||
txn->flags |= (srv->state != SRV_ST_STOPPED) ? TX_CK_VALID : TX_CK_DOWN;
|
txn->flags |= (srv->cur_state != SRV_ST_STOPPED) ? TX_CK_VALID : TX_CK_DOWN;
|
||||||
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
||||||
s->target = &srv->obj_type;
|
s->target = &srv->obj_type;
|
||||||
break;
|
break;
|
||||||
|
@ -1463,7 +1463,7 @@ static int dump_servers_state(struct stream_interface *si, struct chunk *buf)
|
|||||||
"\n",
|
"\n",
|
||||||
px->uuid, px->id,
|
px->uuid, px->id,
|
||||||
srv->puid, srv->id, srv_addr,
|
srv->puid, srv->id, srv_addr,
|
||||||
srv->state, srv->admin, srv->uweight, srv->iweight, (long int)srv_time_since_last_change,
|
srv->cur_state, srv->cur_admin, srv->uweight, srv->iweight, (long int)srv_time_since_last_change,
|
||||||
srv->check.status, srv->check.result, srv->check.health, srv->check.state, srv->agent.state,
|
srv->check.status, srv->check.result, srv->check.health, srv->check.state, srv->agent.state,
|
||||||
bk_f_forced_id, srv_f_forced_id, srv->hostname ? srv->hostname : "-", srv->svc_port);
|
bk_f_forced_id, srv_f_forced_id, srv->hostname ? srv->hostname : "-", srv->svc_port);
|
||||||
if (bi_putchk(si_ic(si), &trash) == -1) {
|
if (bi_putchk(si_ic(si), &trash) == -1) {
|
||||||
|
@ -50,7 +50,7 @@ unsigned int srv_dynamic_maxconn(const struct server *s)
|
|||||||
else max = MAX(s->minconn,
|
else max = MAX(s->minconn,
|
||||||
s->proxy->beconn * s->maxconn / s->proxy->fullconn);
|
s->proxy->beconn * s->maxconn / s->proxy->fullconn);
|
||||||
|
|
||||||
if ((s->state == SRV_ST_STARTING) &&
|
if ((s->cur_state == SRV_ST_STARTING) &&
|
||||||
now.tv_sec < s->last_change + s->slowstart &&
|
now.tv_sec < s->last_change + s->slowstart &&
|
||||||
now.tv_sec >= s->last_change) {
|
now.tv_sec >= s->last_change) {
|
||||||
unsigned int ratio;
|
unsigned int ratio;
|
||||||
@ -107,7 +107,7 @@ static struct stream *pendconn_get_next_strm(struct server *srv, struct proxy *p
|
|||||||
ps = pendconn_from_srv(srv);
|
ps = pendconn_from_srv(srv);
|
||||||
pp = pendconn_from_px(px);
|
pp = pendconn_from_px(px);
|
||||||
/* we want to get the definitive pendconn in <ps> */
|
/* we want to get the definitive pendconn in <ps> */
|
||||||
if (!pp || !srv_is_usable(rsrv)) {
|
if (!pp || !srv_currently_usable(rsrv)) {
|
||||||
if (!ps)
|
if (!ps)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -226,7 +226,7 @@ int pendconn_grab_from_px(struct server *s)
|
|||||||
{
|
{
|
||||||
int xferred;
|
int xferred;
|
||||||
|
|
||||||
if (!srv_is_usable(s))
|
if (!srv_currently_usable(s))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (xferred = 0; !s->maxconn || xferred < srv_dynamic_maxconn(s); xferred++) {
|
for (xferred = 0; !s->maxconn || xferred < srv_dynamic_maxconn(s); xferred++) {
|
||||||
|
148
src/server.c
148
src/server.c
@ -55,7 +55,7 @@ static struct srv_kw_list srv_keywords = {
|
|||||||
|
|
||||||
int srv_downtime(const struct server *s)
|
int srv_downtime(const struct server *s)
|
||||||
{
|
{
|
||||||
if ((s->state != SRV_ST_STOPPED) && s->last_change < now.tv_sec) // ignore negative time
|
if ((s->cur_state != SRV_ST_STOPPED) && s->last_change < now.tv_sec) // ignore negative time
|
||||||
return s->down_time;
|
return s->down_time;
|
||||||
|
|
||||||
return now.tv_sec - s->last_change + s->down_time;
|
return now.tv_sec - s->last_change + s->down_time;
|
||||||
@ -76,7 +76,7 @@ int srv_getinter(const struct check *check)
|
|||||||
if ((check->state & CHK_ST_CONFIGURED) && (check->health == check->rise + check->fall - 1))
|
if ((check->state & CHK_ST_CONFIGURED) && (check->health == check->rise + check->fall - 1))
|
||||||
return check->inter;
|
return check->inter;
|
||||||
|
|
||||||
if ((s->state == SRV_ST_STOPPED) && check->health == 0)
|
if ((s->next_state == SRV_ST_STOPPED) && check->health == 0)
|
||||||
return (check->downinter)?(check->downinter):(check->inter);
|
return (check->downinter)?(check->downinter):(check->inter);
|
||||||
|
|
||||||
return (check->fastinter)?(check->fastinter):(check->inter);
|
return (check->fastinter)?(check->fastinter):(check->inter);
|
||||||
@ -317,8 +317,8 @@ static int srv_parse_cookie(char **args, int *cur_arg,
|
|||||||
static int srv_parse_disabled(char **args, int *cur_arg,
|
static int srv_parse_disabled(char **args, int *cur_arg,
|
||||||
struct proxy *curproxy, struct server *newsrv, char **err)
|
struct proxy *curproxy, struct server *newsrv, char **err)
|
||||||
{
|
{
|
||||||
newsrv->admin |= SRV_ADMF_CMAINT | SRV_ADMF_FMAINT;
|
newsrv->next_admin |= SRV_ADMF_CMAINT | SRV_ADMF_FMAINT;
|
||||||
newsrv->state = SRV_ST_STOPPED;
|
newsrv->next_state = SRV_ST_STOPPED;
|
||||||
newsrv->check.state |= CHK_ST_PAUSED;
|
newsrv->check.state |= CHK_ST_PAUSED;
|
||||||
newsrv->check.health = 0;
|
newsrv->check.health = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@ -328,8 +328,8 @@ static int srv_parse_disabled(char **args, int *cur_arg,
|
|||||||
static int srv_parse_enabled(char **args, int *cur_arg,
|
static int srv_parse_enabled(char **args, int *cur_arg,
|
||||||
struct proxy *curproxy, struct server *newsrv, char **err)
|
struct proxy *curproxy, struct server *newsrv, char **err)
|
||||||
{
|
{
|
||||||
newsrv->admin &= ~SRV_ADMF_CMAINT & ~SRV_ADMF_FMAINT;
|
newsrv->next_admin &= ~SRV_ADMF_CMAINT & ~SRV_ADMF_FMAINT;
|
||||||
newsrv->state = SRV_ST_RUNNING;
|
newsrv->next_state = SRV_ST_RUNNING;
|
||||||
newsrv->check.state &= ~CHK_ST_PAUSED;
|
newsrv->check.state &= ~CHK_ST_PAUSED;
|
||||||
newsrv->check.health = newsrv->check.rise;
|
newsrv->check.health = newsrv->check.rise;
|
||||||
return 0;
|
return 0;
|
||||||
@ -793,7 +793,7 @@ void srv_append_status(struct chunk *msg, struct server *s, const char *reason,
|
|||||||
chunk_appendf(msg, " via %s/%s", s->track->proxy->id, s->track->id);
|
chunk_appendf(msg, " via %s/%s", s->track->proxy->id, s->track->id);
|
||||||
|
|
||||||
if (xferred >= 0) {
|
if (xferred >= 0) {
|
||||||
if (s->state == SRV_ST_STOPPED)
|
if (s->next_state == SRV_ST_STOPPED)
|
||||||
chunk_appendf(msg, ". %d active and %d backup servers left.%s"
|
chunk_appendf(msg, ". %d active and %d backup servers left.%s"
|
||||||
" %d sessions active, %d requeued, %d remaining in queue",
|
" %d sessions active, %d requeued, %d remaining in queue",
|
||||||
s->proxy->srv_act, s->proxy->srv_bck,
|
s->proxy->srv_act, s->proxy->srv_bck,
|
||||||
@ -820,15 +820,15 @@ void srv_set_stopped(struct server *s, const char *reason)
|
|||||||
{
|
{
|
||||||
struct server *srv;
|
struct server *srv;
|
||||||
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
|
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
|
||||||
int srv_was_stopping = (s->state == SRV_ST_STOPPING);
|
int srv_was_stopping = (s->next_state == SRV_ST_STOPPING);
|
||||||
int log_level;
|
int log_level;
|
||||||
int xferred;
|
int xferred;
|
||||||
|
|
||||||
if ((s->admin & SRV_ADMF_MAINT) || s->state == SRV_ST_STOPPED)
|
if ((s->next_admin & SRV_ADMF_MAINT) || s->next_state == SRV_ST_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s->last_change = now.tv_sec;
|
s->last_change = now.tv_sec;
|
||||||
s->state = SRV_ST_STOPPED;
|
s->next_state = SRV_ST_STOPPED;
|
||||||
if (s->proxy->lbprm.set_server_status_down)
|
if (s->proxy->lbprm.set_server_status_down)
|
||||||
s->proxy->lbprm.set_server_status_down(s);
|
s->proxy->lbprm.set_server_status_down(s);
|
||||||
|
|
||||||
@ -875,10 +875,10 @@ void srv_set_running(struct server *s, const char *reason)
|
|||||||
struct server *srv;
|
struct server *srv;
|
||||||
int xferred;
|
int xferred;
|
||||||
|
|
||||||
if (s->admin & SRV_ADMF_MAINT)
|
if (s->next_admin & SRV_ADMF_MAINT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s->state == SRV_ST_STARTING || s->state == SRV_ST_RUNNING)
|
if (s->next_state == SRV_ST_STARTING || s->next_state == SRV_ST_RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
|
if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
|
||||||
@ -887,16 +887,16 @@ void srv_set_running(struct server *s, const char *reason)
|
|||||||
s->proxy->last_change = now.tv_sec;
|
s->proxy->last_change = now.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->state == SRV_ST_STOPPED && s->last_change < now.tv_sec) // ignore negative times
|
if (s->next_state == SRV_ST_STOPPED && s->last_change < now.tv_sec) // ignore negative times
|
||||||
s->down_time += now.tv_sec - s->last_change;
|
s->down_time += now.tv_sec - s->last_change;
|
||||||
|
|
||||||
s->last_change = now.tv_sec;
|
s->last_change = now.tv_sec;
|
||||||
|
|
||||||
s->state = SRV_ST_STARTING;
|
s->next_state = SRV_ST_STARTING;
|
||||||
if (s->slowstart > 0)
|
if (s->slowstart > 0)
|
||||||
task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20))));
|
task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20))));
|
||||||
else
|
else
|
||||||
s->state = SRV_ST_RUNNING;
|
s->next_state = SRV_ST_RUNNING;
|
||||||
|
|
||||||
server_recalc_eweight(s);
|
server_recalc_eweight(s);
|
||||||
|
|
||||||
@ -906,7 +906,7 @@ void srv_set_running(struct server *s, const char *reason)
|
|||||||
* on all backup servers.
|
* on all backup servers.
|
||||||
*/
|
*/
|
||||||
if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
|
if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
|
||||||
!(s->flags & SRV_F_BACKUP) && s->eweight)
|
!(s->flags & SRV_F_BACKUP) && s->next_eweight)
|
||||||
srv_shutdown_backup_streams(s->proxy, SF_ERR_UP);
|
srv_shutdown_backup_streams(s->proxy, SF_ERR_UP);
|
||||||
|
|
||||||
/* check if we can handle some connections queued at the proxy. We
|
/* check if we can handle some connections queued at the proxy. We
|
||||||
@ -940,14 +940,14 @@ void srv_set_stopping(struct server *s, const char *reason)
|
|||||||
struct server *srv;
|
struct server *srv;
|
||||||
int xferred;
|
int xferred;
|
||||||
|
|
||||||
if (s->admin & SRV_ADMF_MAINT)
|
if (s->next_admin & SRV_ADMF_MAINT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s->state == SRV_ST_STOPPING)
|
if (s->next_state == SRV_ST_STOPPING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s->last_change = now.tv_sec;
|
s->last_change = now.tv_sec;
|
||||||
s->state = SRV_ST_STOPPING;
|
s->next_state = SRV_ST_STOPPING;
|
||||||
if (s->proxy->lbprm.set_server_status_down)
|
if (s->proxy->lbprm.set_server_status_down)
|
||||||
s->proxy->lbprm.set_server_status_down(s);
|
s->proxy->lbprm.set_server_status_down(s);
|
||||||
|
|
||||||
@ -991,14 +991,14 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode, const char *cause
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* stop going down as soon as we meet a server already in the same state */
|
/* stop going down as soon as we meet a server already in the same state */
|
||||||
if (s->admin & mode)
|
if (s->next_admin & mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s->admin |= mode;
|
s->next_admin |= mode;
|
||||||
|
|
||||||
/* stop going down if the equivalent flag was already present (forced or inherited) */
|
/* stop going down if the equivalent flag was already present (forced or inherited) */
|
||||||
if (((mode & SRV_ADMF_MAINT) && (s->admin & ~mode & SRV_ADMF_MAINT)) ||
|
if (((mode & SRV_ADMF_MAINT) && (s->next_admin & ~mode & SRV_ADMF_MAINT)) ||
|
||||||
((mode & SRV_ADMF_DRAIN) && (s->admin & ~mode & SRV_ADMF_DRAIN)))
|
((mode & SRV_ADMF_DRAIN) && (s->next_admin & ~mode & SRV_ADMF_DRAIN)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Maintenance must also disable health checks */
|
/* Maintenance must also disable health checks */
|
||||||
@ -1008,7 +1008,7 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode, const char *cause
|
|||||||
check->health = 0;
|
check->health = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->state == SRV_ST_STOPPED) { /* server was already down */
|
if (s->next_state == SRV_ST_STOPPED) { /* server was already down */
|
||||||
chunk_printf(&trash,
|
chunk_printf(&trash,
|
||||||
"%sServer %s/%s was DOWN and now enters maintenance%s%s%s",
|
"%sServer %s/%s was DOWN and now enters maintenance%s%s%s",
|
||||||
s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id,
|
s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id,
|
||||||
@ -1022,12 +1022,12 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode, const char *cause
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* server was still running */
|
else { /* server was still running */
|
||||||
int srv_was_stopping = (s->state == SRV_ST_STOPPING) || (s->admin & SRV_ADMF_DRAIN);
|
int srv_was_stopping = (s->next_state == SRV_ST_STOPPING) || (s->next_admin & SRV_ADMF_DRAIN);
|
||||||
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
|
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
|
||||||
|
|
||||||
check->health = 0; /* failure */
|
check->health = 0; /* failure */
|
||||||
s->last_change = now.tv_sec;
|
s->last_change = now.tv_sec;
|
||||||
s->state = SRV_ST_STOPPED;
|
s->next_state = SRV_ST_STOPPED;
|
||||||
if (s->proxy->lbprm.set_server_status_down)
|
if (s->proxy->lbprm.set_server_status_down)
|
||||||
s->proxy->lbprm.set_server_status_down(s);
|
s->proxy->lbprm.set_server_status_down(s);
|
||||||
|
|
||||||
@ -1061,7 +1061,7 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode, const char *cause
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* drain state is applied only if not yet in maint */
|
/* drain state is applied only if not yet in maint */
|
||||||
if ((mode & SRV_ADMF_DRAIN) && !(s->admin & SRV_ADMF_MAINT)) {
|
if ((mode & SRV_ADMF_DRAIN) && !(s->next_admin & SRV_ADMF_MAINT)) {
|
||||||
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
|
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
|
||||||
|
|
||||||
s->last_change = now.tv_sec;
|
s->last_change = now.tv_sec;
|
||||||
@ -1115,12 +1115,12 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* stop going down as soon as we see the flag is not there anymore */
|
/* stop going down as soon as we see the flag is not there anymore */
|
||||||
if (!(s->admin & mode))
|
if (!(s->next_admin & mode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s->admin &= ~mode;
|
s->next_admin &= ~mode;
|
||||||
|
|
||||||
if (s->admin & SRV_ADMF_MAINT) {
|
if (s->next_admin & SRV_ADMF_MAINT) {
|
||||||
/* remaining in maintenance mode, let's inform precisely about the
|
/* remaining in maintenance mode, let's inform precisely about the
|
||||||
* situation.
|
* situation.
|
||||||
*/
|
*/
|
||||||
@ -1180,7 +1180,7 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
check->health = check->rise; /* start OK but check immediately */
|
check->health = check->rise; /* start OK but check immediately */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!s->track || s->track->state != SRV_ST_STOPPED) &&
|
if ((!s->track || s->track->next_state != SRV_ST_STOPPED) &&
|
||||||
(!(s->agent.state & CHK_ST_ENABLED) || (s->agent.health >= s->agent.rise)) &&
|
(!(s->agent.state & CHK_ST_ENABLED) || (s->agent.health >= s->agent.rise)) &&
|
||||||
(!(s->check.state & CHK_ST_ENABLED) || (s->check.health >= s->check.rise))) {
|
(!(s->check.state & CHK_ST_ENABLED) || (s->check.health >= s->check.rise))) {
|
||||||
if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
|
if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
|
||||||
@ -1193,14 +1193,14 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
s->down_time += now.tv_sec - s->last_change;
|
s->down_time += now.tv_sec - s->last_change;
|
||||||
s->last_change = now.tv_sec;
|
s->last_change = now.tv_sec;
|
||||||
|
|
||||||
if (s->track && s->track->state == SRV_ST_STOPPING)
|
if (s->track && s->track->next_state == SRV_ST_STOPPING)
|
||||||
s->state = SRV_ST_STOPPING;
|
s->next_state = SRV_ST_STOPPING;
|
||||||
else {
|
else {
|
||||||
s->state = SRV_ST_STARTING;
|
s->next_state = SRV_ST_STARTING;
|
||||||
if (s->slowstart > 0)
|
if (s->slowstart > 0)
|
||||||
task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20))));
|
task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, s->slowstart / 20))));
|
||||||
else
|
else
|
||||||
s->state = SRV_ST_RUNNING;
|
s->next_state = SRV_ST_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_recalc_eweight(s);
|
server_recalc_eweight(s);
|
||||||
@ -1211,7 +1211,7 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
* on all backup servers.
|
* on all backup servers.
|
||||||
*/
|
*/
|
||||||
if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
|
if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
|
||||||
!(s->flags & SRV_F_BACKUP) && s->eweight)
|
!(s->flags & SRV_F_BACKUP) && s->next_eweight)
|
||||||
srv_shutdown_backup_streams(s->proxy, SF_ERR_UP);
|
srv_shutdown_backup_streams(s->proxy, SF_ERR_UP);
|
||||||
|
|
||||||
/* check if we can handle some connections queued at the proxy. We
|
/* check if we can handle some connections queued at the proxy. We
|
||||||
@ -1225,30 +1225,30 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
"%sServer %s/%s is %s/%s (leaving forced maintenance)",
|
"%sServer %s/%s is %s/%s (leaving forced maintenance)",
|
||||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||||
s->proxy->id, s->id,
|
s->proxy->id, s->id,
|
||||||
(s->state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
(s->next_state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
||||||
(s->admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
(s->next_admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
||||||
}
|
}
|
||||||
else if (mode & SRV_ADMF_RMAINT) {
|
else if (mode & SRV_ADMF_RMAINT) {
|
||||||
chunk_printf(&trash,
|
chunk_printf(&trash,
|
||||||
"%sServer %s/%s ('%s') is %s/%s (resolves again)",
|
"%sServer %s/%s ('%s') is %s/%s (resolves again)",
|
||||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||||
s->proxy->id, s->id, s->hostname,
|
s->proxy->id, s->id, s->hostname,
|
||||||
(s->state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
(s->next_state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
||||||
(s->admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
(s->next_admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chunk_printf(&trash,
|
chunk_printf(&trash,
|
||||||
"%sServer %s/%s is %s/%s (leaving maintenance)",
|
"%sServer %s/%s is %s/%s (leaving maintenance)",
|
||||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||||
s->proxy->id, s->id,
|
s->proxy->id, s->id,
|
||||||
(s->state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
(s->next_state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
||||||
(s->admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
(s->next_admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
||||||
srv_append_status(&trash, s, NULL, xferred, 0);
|
srv_append_status(&trash, s, NULL, xferred, 0);
|
||||||
}
|
}
|
||||||
Warning("%s.\n", trash.str);
|
Warning("%s.\n", trash.str);
|
||||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
|
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
|
||||||
}
|
}
|
||||||
else if ((mode & SRV_ADMF_DRAIN) && (s->admin & SRV_ADMF_DRAIN)) {
|
else if ((mode & SRV_ADMF_DRAIN) && (s->next_admin & SRV_ADMF_DRAIN)) {
|
||||||
/* remaining in drain mode after removing one of its flags */
|
/* remaining in drain mode after removing one of its flags */
|
||||||
|
|
||||||
if (mode & SRV_ADMF_FDRAIN) {
|
if (mode & SRV_ADMF_FDRAIN) {
|
||||||
@ -1288,14 +1288,14 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
"%sServer %s/%s is %s (leaving forced drain)",
|
"%sServer %s/%s is %s (leaving forced drain)",
|
||||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||||
s->proxy->id, s->id,
|
s->proxy->id, s->id,
|
||||||
(s->state == SRV_ST_STOPPED) ? "DOWN" : "UP");
|
(s->next_state == SRV_ST_STOPPED) ? "DOWN" : "UP");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chunk_printf(&trash,
|
chunk_printf(&trash,
|
||||||
"%sServer %s/%s is %s (leaving drain)",
|
"%sServer %s/%s is %s (leaving drain)",
|
||||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||||
s->proxy->id, s->id,
|
s->proxy->id, s->id,
|
||||||
(s->state == SRV_ST_STOPPED) ? "DOWN" : "UP");
|
(s->next_state == SRV_ST_STOPPED) ? "DOWN" : "UP");
|
||||||
if (s->track) /* normally it's mandatory here */
|
if (s->track) /* normally it's mandatory here */
|
||||||
chunk_appendf(&trash, " via %s/%s",
|
chunk_appendf(&trash, " via %s/%s",
|
||||||
s->track->proxy->id, s->track->id);
|
s->track->proxy->id, s->track->id);
|
||||||
@ -1305,8 +1305,8 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* stop going down if the equivalent flag is still present (forced or inherited) */
|
/* stop going down if the equivalent flag is still present (forced or inherited) */
|
||||||
if (((mode & SRV_ADMF_MAINT) && (s->admin & SRV_ADMF_MAINT)) ||
|
if (((mode & SRV_ADMF_MAINT) && (s->next_admin & SRV_ADMF_MAINT)) ||
|
||||||
((mode & SRV_ADMF_DRAIN) && (s->admin & SRV_ADMF_DRAIN)))
|
((mode & SRV_ADMF_DRAIN) && (s->next_admin & SRV_ADMF_DRAIN)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mode & SRV_ADMF_MAINT)
|
if (mode & SRV_ADMF_MAINT)
|
||||||
@ -1329,10 +1329,10 @@ static void srv_propagate_admin_state(struct server *srv)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (srv2 = srv->trackers; srv2; srv2 = srv2->tracknext) {
|
for (srv2 = srv->trackers; srv2; srv2 = srv2->tracknext) {
|
||||||
if (srv->admin & (SRV_ADMF_MAINT | SRV_ADMF_CMAINT))
|
if (srv->next_admin & (SRV_ADMF_MAINT | SRV_ADMF_CMAINT))
|
||||||
srv_set_admin_flag(srv2, SRV_ADMF_IMAINT, NULL);
|
srv_set_admin_flag(srv2, SRV_ADMF_IMAINT, NULL);
|
||||||
|
|
||||||
if (srv->admin & SRV_ADMF_DRAIN)
|
if (srv->next_admin & SRV_ADMF_DRAIN)
|
||||||
srv_set_admin_flag(srv2, SRV_ADMF_IDRAIN, NULL);
|
srv_set_admin_flag(srv2, SRV_ADMF_IDRAIN, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1405,24 +1405,24 @@ void server_recalc_eweight(struct server *sv)
|
|||||||
|
|
||||||
if (now.tv_sec < sv->last_change || now.tv_sec >= sv->last_change + sv->slowstart) {
|
if (now.tv_sec < sv->last_change || now.tv_sec >= sv->last_change + sv->slowstart) {
|
||||||
/* go to full throttle if the slowstart interval is reached */
|
/* go to full throttle if the slowstart interval is reached */
|
||||||
if (sv->state == SRV_ST_STARTING)
|
if (sv->next_state == SRV_ST_STARTING)
|
||||||
sv->state = SRV_ST_RUNNING;
|
sv->next_state = SRV_ST_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We must take care of not pushing the server to full throttle during slow starts.
|
/* We must take care of not pushing the server to full throttle during slow starts.
|
||||||
* It must also start immediately, at least at the minimal step when leaving maintenance.
|
* It must also start immediately, at least at the minimal step when leaving maintenance.
|
||||||
*/
|
*/
|
||||||
if ((sv->state == SRV_ST_STARTING) && (px->lbprm.algo & BE_LB_PROP_DYN))
|
if ((sv->next_state == SRV_ST_STARTING) && (px->lbprm.algo & BE_LB_PROP_DYN))
|
||||||
w = (px->lbprm.wdiv * (now.tv_sec - sv->last_change) + sv->slowstart) / sv->slowstart;
|
w = (px->lbprm.wdiv * (now.tv_sec - sv->last_change) + sv->slowstart) / sv->slowstart;
|
||||||
else
|
else
|
||||||
w = px->lbprm.wdiv;
|
w = px->lbprm.wdiv;
|
||||||
|
|
||||||
sv->eweight = (sv->uweight * w + px->lbprm.wmult - 1) / px->lbprm.wmult;
|
sv->next_eweight = (sv->uweight * w + px->lbprm.wmult - 1) / px->lbprm.wmult;
|
||||||
|
|
||||||
/* now propagate the status change to any LB algorithms */
|
/* now propagate the status change to any LB algorithms */
|
||||||
if (px->lbprm.update_server_eweight)
|
if (px->lbprm.update_server_eweight)
|
||||||
px->lbprm.update_server_eweight(sv);
|
px->lbprm.update_server_eweight(sv);
|
||||||
else if (srv_is_usable(sv)) {
|
else if (srv_willbe_usable(sv)) {
|
||||||
if (px->lbprm.set_server_status_up)
|
if (px->lbprm.set_server_status_up)
|
||||||
px->lbprm.set_server_status_up(sv);
|
px->lbprm.set_server_status_up(sv);
|
||||||
}
|
}
|
||||||
@ -1791,9 +1791,9 @@ static void srv_settings_cpy(struct server *srv, struct server *src, int srv_tmp
|
|||||||
srv->check.fall = src->check.fall;
|
srv->check.fall = src->check.fall;
|
||||||
|
|
||||||
/* Here we check if 'disabled' is the default server state */
|
/* Here we check if 'disabled' is the default server state */
|
||||||
if (src->admin & (SRV_ADMF_CMAINT | SRV_ADMF_FMAINT)) {
|
if (src->next_admin & (SRV_ADMF_CMAINT | SRV_ADMF_FMAINT)) {
|
||||||
srv->admin |= SRV_ADMF_CMAINT | SRV_ADMF_FMAINT;
|
srv->next_admin |= SRV_ADMF_CMAINT | SRV_ADMF_FMAINT;
|
||||||
srv->state = SRV_ST_STOPPED;
|
srv->next_state = SRV_ST_STOPPED;
|
||||||
srv->check.state |= CHK_ST_PAUSED;
|
srv->check.state |= CHK_ST_PAUSED;
|
||||||
srv->check.health = 0;
|
srv->check.health = 0;
|
||||||
}
|
}
|
||||||
@ -1840,7 +1840,7 @@ static struct server *new_server(struct proxy *proxy)
|
|||||||
LIST_INIT(&srv->idle_conns);
|
LIST_INIT(&srv->idle_conns);
|
||||||
LIST_INIT(&srv->safe_conns);
|
LIST_INIT(&srv->safe_conns);
|
||||||
|
|
||||||
srv->state = SRV_ST_RUNNING; /* early server setup */
|
srv->next_state = SRV_ST_RUNNING; /* early server setup */
|
||||||
srv->last_change = now.tv_sec;
|
srv->last_change = now.tv_sec;
|
||||||
|
|
||||||
srv->check.status = HCHK_STATUS_INI;
|
srv->check.status = HCHK_STATUS_INI;
|
||||||
@ -3115,7 +3115,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
|||||||
srv_set_stopped(srv, "changed from server-state after a reload");
|
srv_set_stopped(srv, "changed from server-state after a reload");
|
||||||
break;
|
break;
|
||||||
case SRV_ST_STARTING:
|
case SRV_ST_STARTING:
|
||||||
srv->state = srv_op_state;
|
srv->next_state = srv_op_state;
|
||||||
break;
|
break;
|
||||||
case SRV_ST_STOPPING:
|
case SRV_ST_STOPPING:
|
||||||
srv->check.health = srv->check.rise + srv->check.fall - 1;
|
srv->check.health = srv->check.rise + srv->check.fall - 1;
|
||||||
@ -3134,21 +3134,21 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
|||||||
* state is different from new configuration state
|
* state is different from new configuration state
|
||||||
*/
|
*/
|
||||||
/* configuration has changed */
|
/* configuration has changed */
|
||||||
if ((srv_admin_state & SRV_ADMF_CMAINT) != (srv->admin & SRV_ADMF_CMAINT)) {
|
if ((srv_admin_state & SRV_ADMF_CMAINT) != (srv->next_admin & SRV_ADMF_CMAINT)) {
|
||||||
if (srv->admin & SRV_ADMF_CMAINT)
|
if (srv->next_admin & SRV_ADMF_CMAINT)
|
||||||
srv_adm_set_maint(srv);
|
srv_adm_set_maint(srv);
|
||||||
else
|
else
|
||||||
srv_adm_set_ready(srv);
|
srv_adm_set_ready(srv);
|
||||||
}
|
}
|
||||||
/* configuration is the same, let's compate old running state and new conf state */
|
/* configuration is the same, let's compate old running state and new conf state */
|
||||||
else {
|
else {
|
||||||
if (srv_admin_state & SRV_ADMF_FMAINT && !(srv->admin & SRV_ADMF_CMAINT))
|
if (srv_admin_state & SRV_ADMF_FMAINT && !(srv->next_admin & SRV_ADMF_CMAINT))
|
||||||
srv_adm_set_maint(srv);
|
srv_adm_set_maint(srv);
|
||||||
else if (!(srv_admin_state & SRV_ADMF_FMAINT) && (srv->admin & SRV_ADMF_CMAINT))
|
else if (!(srv_admin_state & SRV_ADMF_FMAINT) && (srv->next_admin & SRV_ADMF_CMAINT))
|
||||||
srv_adm_set_ready(srv);
|
srv_adm_set_ready(srv);
|
||||||
}
|
}
|
||||||
/* apply drain mode if server is currently enabled */
|
/* apply drain mode if server is currently enabled */
|
||||||
if (!(srv->admin & SRV_ADMF_FMAINT) && (srv_admin_state & SRV_ADMF_FDRAIN)) {
|
if (!(srv->next_admin & SRV_ADMF_FMAINT) && (srv_admin_state & SRV_ADMF_FDRAIN)) {
|
||||||
/* The SRV_ADMF_FDRAIN flag is inherited when srv->iweight is 0
|
/* The SRV_ADMF_FDRAIN flag is inherited when srv->iweight is 0
|
||||||
* (srv->iweight is the weight set up in configuration).
|
* (srv->iweight is the weight set up in configuration).
|
||||||
* There are two possible reasons for FDRAIN to have been present :
|
* There are two possible reasons for FDRAIN to have been present :
|
||||||
@ -3220,7 +3220,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
|||||||
* So we must reset the 'set from stats socket FQDN' flag to be consistent with
|
* So we must reset the 'set from stats socket FQDN' flag to be consistent with
|
||||||
* any futher FQDN modification.
|
* any futher FQDN modification.
|
||||||
*/
|
*/
|
||||||
srv->admin &= ~SRV_ADMF_HMAINT;
|
srv->next_admin &= ~SRV_ADMF_HMAINT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* If the FDQN has been changed from stats socket,
|
/* If the FDQN has been changed from stats socket,
|
||||||
@ -3229,7 +3229,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
|||||||
*/
|
*/
|
||||||
if (fqdn_set_by_cli) {
|
if (fqdn_set_by_cli) {
|
||||||
srv_set_fqdn(srv, fqdn);
|
srv_set_fqdn(srv, fqdn);
|
||||||
srv->admin |= SRV_ADMF_HMAINT;
|
srv->next_admin |= SRV_ADMF_HMAINT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3827,13 +3827,13 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
|
|||||||
* server will be turned back on if health check is safe
|
* server will be turned back on if health check is safe
|
||||||
*/
|
*/
|
||||||
if (has_no_ip) {
|
if (has_no_ip) {
|
||||||
if (s->admin & SRV_ADMF_RMAINT)
|
if (s->next_admin & SRV_ADMF_RMAINT)
|
||||||
return 1;
|
return 1;
|
||||||
srv_set_admin_flag(s, SRV_ADMF_RMAINT,
|
srv_set_admin_flag(s, SRV_ADMF_RMAINT,
|
||||||
"No IP for server ");
|
"No IP for server ");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (!(s->admin & SRV_ADMF_RMAINT))
|
if (!(s->next_admin & SRV_ADMF_RMAINT))
|
||||||
return 1;
|
return 1;
|
||||||
srv_clr_admin_flag(s, SRV_ADMF_RMAINT);
|
srv_clr_admin_flag(s, SRV_ADMF_RMAINT);
|
||||||
chunk_printf(&trash, "Server %s/%s administratively READY thanks to valid DNS answer",
|
chunk_printf(&trash, "Server %s/%s administratively READY thanks to valid DNS answer",
|
||||||
@ -3846,7 +3846,7 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
|
|||||||
case RSLV_STATUS_NX:
|
case RSLV_STATUS_NX:
|
||||||
/* stop server if resolution is NX for a long enough period */
|
/* stop server if resolution is NX for a long enough period */
|
||||||
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.nx), now_ms)) {
|
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.nx), now_ms)) {
|
||||||
if (s->admin & SRV_ADMF_RMAINT)
|
if (s->next_admin & SRV_ADMF_RMAINT)
|
||||||
return 1;
|
return 1;
|
||||||
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "DNS NX status");
|
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "DNS NX status");
|
||||||
return 0;
|
return 0;
|
||||||
@ -3856,7 +3856,7 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
|
|||||||
case RSLV_STATUS_TIMEOUT:
|
case RSLV_STATUS_TIMEOUT:
|
||||||
/* stop server if resolution is TIMEOUT for a long enough period */
|
/* stop server if resolution is TIMEOUT for a long enough period */
|
||||||
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.timeout), now_ms)) {
|
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.timeout), now_ms)) {
|
||||||
if (s->admin & SRV_ADMF_RMAINT)
|
if (s->next_admin & SRV_ADMF_RMAINT)
|
||||||
return 1;
|
return 1;
|
||||||
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "DNS timeout status");
|
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "DNS timeout status");
|
||||||
return 0;
|
return 0;
|
||||||
@ -3866,7 +3866,7 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
|
|||||||
case RSLV_STATUS_REFUSED:
|
case RSLV_STATUS_REFUSED:
|
||||||
/* stop server if resolution is REFUSED for a long enough period */
|
/* stop server if resolution is REFUSED for a long enough period */
|
||||||
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.refused), now_ms)) {
|
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.refused), now_ms)) {
|
||||||
if (s->admin & SRV_ADMF_RMAINT)
|
if (s->next_admin & SRV_ADMF_RMAINT)
|
||||||
return 1;
|
return 1;
|
||||||
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "DNS refused status");
|
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "DNS refused status");
|
||||||
return 0;
|
return 0;
|
||||||
@ -3876,7 +3876,7 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
|
|||||||
default:
|
default:
|
||||||
/* stop server if resolution is in unmatched error for a long enough period */
|
/* stop server if resolution is in unmatched error for a long enough period */
|
||||||
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.other), now_ms)) {
|
if (tick_is_expired(tick_add(resolution->last_status_change, resolvers->hold.other), now_ms)) {
|
||||||
if (s->admin & SRV_ADMF_RMAINT)
|
if (s->next_admin & SRV_ADMF_RMAINT)
|
||||||
return 1;
|
return 1;
|
||||||
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "unspecified DNS error");
|
srv_set_admin_flag(s, SRV_ADMF_RMAINT, "unspecified DNS error");
|
||||||
return 0;
|
return 0;
|
||||||
@ -4057,7 +4057,7 @@ struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* If the server has been taken down, don't consider it */
|
/* If the server has been taken down, don't consider it */
|
||||||
if (tmpsrv->admin & SRV_ADMF_RMAINT)
|
if (tmpsrv->next_admin & SRV_ADMF_RMAINT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* At this point, we have 2 different servers using the same DNS hostname
|
/* At this point, we have 2 different servers using the same DNS hostname
|
||||||
@ -4315,7 +4315,7 @@ const char *update_server_fqdn(struct server *server, const char *fqdn, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Flag as FQDN set from stats socket. */
|
/* Flag as FQDN set from stats socket. */
|
||||||
server->admin |= SRV_ADMF_HMAINT;
|
server->next_admin |= SRV_ADMF_HMAINT;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (updater)
|
if (updater)
|
||||||
|
32
src/stats.c
32
src/stats.c
@ -1491,7 +1491,7 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
|
|||||||
while (ref->track)
|
while (ref->track)
|
||||||
ref = ref->track;
|
ref = ref->track;
|
||||||
|
|
||||||
if (sv->state == SRV_ST_RUNNING || sv->state == SRV_ST_STARTING) {
|
if (sv->cur_state == SRV_ST_RUNNING || sv->cur_state == SRV_ST_STARTING) {
|
||||||
if ((ref->check.state & CHK_ST_ENABLED) &&
|
if ((ref->check.state & CHK_ST_ENABLED) &&
|
||||||
(ref->check.health < ref->check.rise + ref->check.fall - 1)) {
|
(ref->check.health < ref->check.rise + ref->check.fall - 1)) {
|
||||||
state = SRV_STATS_STATE_UP_GOING_DOWN;
|
state = SRV_STATS_STATE_UP_GOING_DOWN;
|
||||||
@ -1499,7 +1499,7 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
|
|||||||
state = SRV_STATS_STATE_UP;
|
state = SRV_STATS_STATE_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sv->admin & SRV_ADMF_DRAIN) {
|
if (sv->cur_admin & SRV_ADMF_DRAIN) {
|
||||||
if (ref->agent.state & CHK_ST_ENABLED)
|
if (ref->agent.state & CHK_ST_ENABLED)
|
||||||
state = SRV_STATS_STATE_DRAIN_AGENT;
|
state = SRV_STATS_STATE_DRAIN_AGENT;
|
||||||
else if (state == SRV_STATS_STATE_UP_GOING_DOWN)
|
else if (state == SRV_STATS_STATE_UP_GOING_DOWN)
|
||||||
@ -1512,7 +1512,7 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
|
|||||||
state = SRV_STATS_STATE_NO_CHECK;
|
state = SRV_STATS_STATE_NO_CHECK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sv->state == SRV_ST_STOPPING) {
|
else if (sv->cur_state == SRV_ST_STOPPING) {
|
||||||
if ((!(sv->check.state & CHK_ST_ENABLED) && !sv->track) ||
|
if ((!(sv->check.state & CHK_ST_ENABLED) && !sv->track) ||
|
||||||
(ref->check.health == ref->check.rise + ref->check.fall - 1)) {
|
(ref->check.health == ref->check.rise + ref->check.fall - 1)) {
|
||||||
state = SRV_STATS_STATE_NOLB;
|
state = SRV_STATS_STATE_NOLB;
|
||||||
@ -1556,21 +1556,21 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
|
|||||||
|
|
||||||
/* status */
|
/* status */
|
||||||
fld_status = chunk_newstr(out);
|
fld_status = chunk_newstr(out);
|
||||||
if (sv->admin & SRV_ADMF_RMAINT)
|
if (sv->cur_admin & SRV_ADMF_RMAINT)
|
||||||
chunk_appendf(out, "MAINT (resolution)");
|
chunk_appendf(out, "MAINT (resolution)");
|
||||||
else if (sv->admin & SRV_ADMF_IMAINT)
|
else if (sv->cur_admin & SRV_ADMF_IMAINT)
|
||||||
chunk_appendf(out, "MAINT (via %s/%s)", via->proxy->id, via->id);
|
chunk_appendf(out, "MAINT (via %s/%s)", via->proxy->id, via->id);
|
||||||
else if (sv->admin & SRV_ADMF_MAINT)
|
else if (sv->cur_admin & SRV_ADMF_MAINT)
|
||||||
chunk_appendf(out, "MAINT");
|
chunk_appendf(out, "MAINT");
|
||||||
else
|
else
|
||||||
chunk_appendf(out,
|
chunk_appendf(out,
|
||||||
srv_hlt_st[state],
|
srv_hlt_st[state],
|
||||||
(ref->state != SRV_ST_STOPPED) ? (ref->check.health - ref->check.rise + 1) : (ref->check.health),
|
(ref->cur_state != SRV_ST_STOPPED) ? (ref->check.health - ref->check.rise + 1) : (ref->check.health),
|
||||||
(ref->state != SRV_ST_STOPPED) ? (ref->check.fall) : (ref->check.rise));
|
(ref->cur_state != SRV_ST_STOPPED) ? (ref->check.fall) : (ref->check.rise));
|
||||||
|
|
||||||
stats[ST_F_STATUS] = mkf_str(FO_STATUS, fld_status);
|
stats[ST_F_STATUS] = mkf_str(FO_STATUS, fld_status);
|
||||||
stats[ST_F_LASTCHG] = mkf_u32(FN_AGE, now.tv_sec - sv->last_change);
|
stats[ST_F_LASTCHG] = mkf_u32(FN_AGE, now.tv_sec - sv->last_change);
|
||||||
stats[ST_F_WEIGHT] = mkf_u32(FN_AVG, (sv->eweight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv);
|
stats[ST_F_WEIGHT] = mkf_u32(FN_AVG, (sv->cur_eweight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv);
|
||||||
stats[ST_F_ACT] = mkf_u32(FO_STATUS, (sv->flags & SRV_F_BACKUP) ? 0 : 1);
|
stats[ST_F_ACT] = mkf_u32(FO_STATUS, (sv->flags & SRV_F_BACKUP) ? 0 : 1);
|
||||||
stats[ST_F_BCK] = mkf_u32(FO_STATUS, (sv->flags & SRV_F_BACKUP) ? 1 : 0);
|
stats[ST_F_BCK] = mkf_u32(FO_STATUS, (sv->flags & SRV_F_BACKUP) ? 1 : 0);
|
||||||
|
|
||||||
@ -1588,7 +1588,7 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
|
|||||||
stats[ST_F_IID] = mkf_u32(FO_KEY|FS_SERVICE, px->uuid);
|
stats[ST_F_IID] = mkf_u32(FO_KEY|FS_SERVICE, px->uuid);
|
||||||
stats[ST_F_SID] = mkf_u32(FO_KEY|FS_SERVICE, sv->puid);
|
stats[ST_F_SID] = mkf_u32(FO_KEY|FS_SERVICE, sv->puid);
|
||||||
|
|
||||||
if (sv->state == SRV_ST_STARTING && !server_is_draining(sv))
|
if (sv->cur_state == SRV_ST_STARTING && !server_is_draining(sv))
|
||||||
stats[ST_F_THROTTLE] = mkf_u32(FN_AVG, server_throttle_rate(sv));
|
stats[ST_F_THROTTLE] = mkf_u32(FN_AVG, server_throttle_rate(sv));
|
||||||
|
|
||||||
stats[ST_F_LBTOT] = mkf_u64(FN_COUNTER, sv->counters.cum_lbconn);
|
stats[ST_F_LBTOT] = mkf_u64(FN_COUNTER, sv->counters.cum_lbconn);
|
||||||
@ -2088,8 +2088,8 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
|
|||||||
|
|
||||||
/* do not report servers which are DOWN and not changing state */
|
/* do not report servers which are DOWN and not changing state */
|
||||||
if ((appctx->ctx.stats.flags & STAT_HIDE_DOWN) &&
|
if ((appctx->ctx.stats.flags & STAT_HIDE_DOWN) &&
|
||||||
((sv->admin & SRV_ADMF_MAINT) || /* server is in maintenance */
|
((sv->cur_admin & SRV_ADMF_MAINT) || /* server is in maintenance */
|
||||||
(sv->state == SRV_ST_STOPPED && /* server is down */
|
(sv->cur_state == SRV_ST_STOPPED && /* server is down */
|
||||||
(!((svs->agent.state | svs->check.state) & CHK_ST_ENABLED) ||
|
(!((svs->agent.state | svs->check.state) & CHK_ST_ENABLED) ||
|
||||||
((svs->agent.state & CHK_ST_ENABLED) && !svs->agent.health) ||
|
((svs->agent.state & CHK_ST_ENABLED) && !svs->agent.health) ||
|
||||||
((svs->check.state & CHK_ST_ENABLED) && !svs->check.health))))) {
|
((svs->check.state & CHK_ST_ENABLED) && !svs->check.health))))) {
|
||||||
@ -2767,28 +2767,28 @@ static int stats_process_http_post(struct stream_interface *si)
|
|||||||
else if ((sv = findserver(px, value)) != NULL) {
|
else if ((sv = findserver(px, value)) != NULL) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ST_ADM_ACTION_DISABLE:
|
case ST_ADM_ACTION_DISABLE:
|
||||||
if (!(sv->admin & SRV_ADMF_FMAINT)) {
|
if (!(sv->cur_admin & SRV_ADMF_FMAINT)) {
|
||||||
altered_servers++;
|
altered_servers++;
|
||||||
total_servers++;
|
total_servers++;
|
||||||
srv_set_admin_flag(sv, SRV_ADMF_FMAINT, "'disable' on stats page");
|
srv_set_admin_flag(sv, SRV_ADMF_FMAINT, "'disable' on stats page");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ST_ADM_ACTION_ENABLE:
|
case ST_ADM_ACTION_ENABLE:
|
||||||
if (sv->admin & SRV_ADMF_FMAINT) {
|
if (sv->cur_admin & SRV_ADMF_FMAINT) {
|
||||||
altered_servers++;
|
altered_servers++;
|
||||||
total_servers++;
|
total_servers++;
|
||||||
srv_clr_admin_flag(sv, SRV_ADMF_FMAINT);
|
srv_clr_admin_flag(sv, SRV_ADMF_FMAINT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ST_ADM_ACTION_STOP:
|
case ST_ADM_ACTION_STOP:
|
||||||
if (!(sv->admin & SRV_ADMF_FDRAIN)) {
|
if (!(sv->cur_admin & SRV_ADMF_FDRAIN)) {
|
||||||
srv_set_admin_flag(sv, SRV_ADMF_FDRAIN, "'stop' on stats page");
|
srv_set_admin_flag(sv, SRV_ADMF_FDRAIN, "'stop' on stats page");
|
||||||
altered_servers++;
|
altered_servers++;
|
||||||
total_servers++;
|
total_servers++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ST_ADM_ACTION_START:
|
case ST_ADM_ACTION_START:
|
||||||
if (sv->admin & SRV_ADMF_FDRAIN) {
|
if (sv->cur_admin & SRV_ADMF_FDRAIN) {
|
||||||
srv_clr_admin_flag(sv, SRV_ADMF_FDRAIN);
|
srv_clr_admin_flag(sv, SRV_ADMF_FDRAIN);
|
||||||
altered_servers++;
|
altered_servers++;
|
||||||
total_servers++;
|
total_servers++;
|
||||||
|
@ -696,7 +696,7 @@ static int sess_update_st_cer(struct stream *s)
|
|||||||
*/
|
*/
|
||||||
if (objt_server(s->target) &&
|
if (objt_server(s->target) &&
|
||||||
(s->be->options & PR_O_REDISP) && !(s->flags & SF_FORCE_PRST) &&
|
(s->be->options & PR_O_REDISP) && !(s->flags & SF_FORCE_PRST) &&
|
||||||
((__objt_server(s->target)->state < SRV_ST_RUNNING) ||
|
((__objt_server(s->target)->cur_state < SRV_ST_RUNNING) ||
|
||||||
(((s->be->redispatch_after > 0) &&
|
(((s->be->redispatch_after > 0) &&
|
||||||
((s->be->conn_retries - si->conn_retries) %
|
((s->be->conn_retries - si->conn_retries) %
|
||||||
s->be->redispatch_after == 0)) ||
|
s->be->redispatch_after == 0)) ||
|
||||||
@ -1297,7 +1297,7 @@ static int process_server_rules(struct stream *s, struct channel *req, int an_bi
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
struct server *srv = rule->srv.ptr;
|
struct server *srv = rule->srv.ptr;
|
||||||
|
|
||||||
if ((srv->state != SRV_ST_STOPPED) ||
|
if ((srv->cur_state != SRV_ST_STOPPED) ||
|
||||||
(px->options & PR_O_PERSIST) ||
|
(px->options & PR_O_PERSIST) ||
|
||||||
(s->flags & SF_FORCE_PRST)) {
|
(s->flags & SF_FORCE_PRST)) {
|
||||||
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
||||||
@ -1383,7 +1383,7 @@ static int process_sticking_rules(struct stream *s, struct channel *req, int an_
|
|||||||
struct server *srv;
|
struct server *srv;
|
||||||
|
|
||||||
srv = container_of(node, struct server, conf.id);
|
srv = container_of(node, struct server, conf.id);
|
||||||
if ((srv->state != SRV_ST_STOPPED) ||
|
if ((srv->cur_state != SRV_ST_STOPPED) ||
|
||||||
(px->options & PR_O_PERSIST) ||
|
(px->options & PR_O_PERSIST) ||
|
||||||
(s->flags & SF_FORCE_PRST)) {
|
(s->flags & SF_FORCE_PRST)) {
|
||||||
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
s->flags |= SF_DIRECT | SF_ASSIGNED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user