Setting a server to DRAIN state removes the server from load balancing. That is the existing connections are drained and no new connections are established on the server. In order to conclude that a server has been completely drained, we need to refer to the HAProxy stats properties related to sessions and connections.
OUTPUT:
#pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,
fe_keystone,FRONTEND,0,12,2000,7147,2976789,15461054,0,0,0,OPEN,1,2,0,0,0,0,5938,0,28157,46,31,7002,0,0,5938,35236,0,0,0,0,
be_keystone,op1.example.com,0,0,0,7,28234,2395882,13976630,0,0,0,0,0,UP,1,1,0,1,1,4,5346,1,3,1,28104,2,0,819,L4OK,0,0,28157,46,31,0,0,0,0,0,1193,0,1,8,9,
be_keystone,BACKEND,0,0,0,7,200,35236,2976789,15461054,0,0,7002,0,0,0,UP,1,1,0,4,4,5343,1,3,0,28104,1,0,5938,0,28157,46,31,7002,0,0,0,0,0,0,0,1193,0,1,8,9,
stats,FRONTEND,0,0,2000,0,0,0,0,0,0,OPEN,1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
stats,BACKEND,0,0,0,0,200,0,0,0,0,0,0,0,0,0,UP,0,0,0,0,11537,0,1,4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,
Out of all the stats properties retrieved above, the relevant ones in this case are rate, req_rate and scur.
where,
Therefore, in order to conclude that a server has been completely drained, you need to ensure that the value for rate, req_rate and scur is all zero.