mirror of
https://github.com/haproxy/haproxy.git
synced 2026-07-05 23:39:16 -04:00
MINOR: server: distinguish name references with new SRV_F_NAME_REFD flag
Until now, every form of "this server is referenced by something in the
running config" was collapsed onto a single flag, SRV_F_NON_PURGEABLE,
which prevents the server from being removed via 'del server'. This
catches everything but conflates two distinct properties:
- the server object itself is pinned by another runtime structure
(e.g. DNS resolution attached to it), versus
- the server's *name* is referenced statically (use-server rules,
track chains, sample-fetch arguments of type ARGT_SRV)
These differ for any operation that touches the name but not the
object identity, e.g. the runtime rename feature added next. Removing
a name-referenced server is still forbidden (the rule text would
dangle), but renaming such a server should also be forbidden for the
same reason - while renaming a resolver-pinned server is fine, since
the resolver holds the object pointer and doesn't care about the name.
Introduce SRV_F_NAME_REFD for the name-reference case and move the
three name-based setters (sample.c ARGT_SRV resolution, proxy.c
use-server resolution, server.c track chain setup) from
SRV_F_NON_PURGEABLE to SRV_F_NAME_REFD. The resolvers.c call site
keeps SRV_F_NON_PURGEABLE since it is the object-pinned case.
Adjust 'del server' to check both flags so the set of servers it
refuses to remove is unchanged: same observable behavior, just a
richer internal taxonomy.
A subsequent patch introducing 'set server name' will gate on
SRV_F_NAME_REFD only.
This commit is contained in:
parent
9475e69920
commit
47b20a72e2
4 changed files with 5 additions and 4 deletions
|
|
@ -174,6 +174,7 @@ enum srv_init_state {
|
|||
#define SRV_F_STRICT_MAXCONN 0x10000 /* maxconn is to be strictly enforced, as a limit of outbound connections */
|
||||
#define SRV_F_CHK_NO_AUTO_SNI 0x20000 /* disable automatic SNI selection for healthcheck */
|
||||
#define SRV_F_UDP_GSO_NOTSUPP 0x40000 /* UDP GSO is disabled due to a previous error encountered */
|
||||
#define SRV_F_NAME_REFD 0x80000 /* this server's name is statically referenced (use-server, track, sample arg) */
|
||||
|
||||
/* configured server options for send-proxy (server->pp_opts) */
|
||||
#define SRV_PP_V1 0x0001 /* proxy protocol version 1 */
|
||||
|
|
|
|||
|
|
@ -2119,7 +2119,7 @@ int proxy_finalize(struct proxy *px, int *err_code)
|
|||
}
|
||||
ha_free(&srule->srv.name);
|
||||
srule->srv.ptr = target;
|
||||
target->flags |= SRV_F_NON_PURGEABLE;
|
||||
target->flags |= SRV_F_NAME_REFD;
|
||||
}
|
||||
|
||||
/* find the target table for 'stick' rules */
|
||||
|
|
|
|||
|
|
@ -1538,7 +1538,7 @@ int smp_resolve_args(struct proxy *p, char **err)
|
|||
}
|
||||
|
||||
/* TODO CLI set-var should not prevent server deletion as var value is instantly resolved. */
|
||||
srv->flags |= SRV_F_NON_PURGEABLE;
|
||||
srv->flags |= SRV_F_NAME_REFD;
|
||||
|
||||
chunk_destroy(&arg->data.str);
|
||||
arg->unresolved = 0;
|
||||
|
|
|
|||
|
|
@ -6532,7 +6532,7 @@ int srv_check_for_deletion(const char *bename, const char *svname, struct proxy
|
|||
goto leave;
|
||||
}
|
||||
|
||||
if (srv->flags & SRV_F_NON_PURGEABLE) {
|
||||
if (srv->flags & (SRV_F_NON_PURGEABLE | SRV_F_NAME_REFD)) {
|
||||
msg = "This server cannot be removed at runtime due to other configuration elements pointing to it.";
|
||||
goto leave;
|
||||
}
|
||||
|
|
@ -6783,7 +6783,7 @@ int srv_apply_track(struct server *srv, struct proxy *curproxy)
|
|||
srv->track = strack;
|
||||
srv->tracknext = strack->trackers;
|
||||
strack->trackers = srv;
|
||||
strack->flags |= SRV_F_NON_PURGEABLE;
|
||||
strack->flags |= SRV_F_NAME_REFD;
|
||||
|
||||
ha_free(&srv->trackit);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue