MINOR: server: change srv_op_st_chg_cause storage type
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 4 Apr 2023 08:17:40 +0000 (10:17 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 21 Apr 2023 12:36:45 +0000 (14:36 +0200)
commit1746b56e687e59d096233a852746dfbf89fcfddb
tree534c47effed4eba107bb93f4d0cd3a734f7cceb2
parentf3b48a808e63f7e041326e0a71ad916b2600fad4
MINOR: server: change srv_op_st_chg_cause storage type

This one is greatly inspired by "MINOR: server: change adm_st_chg_cause storage type".

While looking at current srv_op_st_chg_cause usage, it was clear that
the struct needed some cleanup since some leftovers from asynchronous server
state change updates were left behind and resulted in some useless code
duplication, and making the whole thing harder to maintain.

Two observations were made:

- by tracking down srv_set_{running, stopped, stopping} usage,
  we can see that the <reason> argument is always a fixed statically
  allocated string.
- check-related state change context (duration, status, code...) is
  not used anymore since srv_append_status() directly extracts the
  values from the server->check. This is pure legacy from when
  the state changes were applied asynchronously.

To prevent code duplication, useless string copies and make the reason/cause
more exportable, we store it as an enum now, and we provide
srv_op_st_chg_cause() function to fetch the related description string.
HEALTH and AGENT causes (check related) are now explicitly identified to
make consumers like srv_append_op_chg_cause() able to fetch checks info
from the server itself if they need to.
include/haproxy/server-t.h
include/haproxy/server.h
src/check.c
src/hlua_fcn.c
src/server.c
src/server_state.c
src/stats.c