polish shard director logging

SLT_Notice requires messages to be prefixed by the vmod name. Using this
format for notices only would appear inconsistent, so we change all
shard log messages to that format.
parent 6f7a1d56
......@@ -199,75 +199,75 @@ logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 0 0 VCL_Log {^-- invalid replicas$}
expect 0 0 Error {^shard vd: .reconfigure.. invalid replicas argument 0}
expect 0 0 Error {^vmod_directors shard vd: .reconfigure.. invalid replicas argument 0}
expect 0 0 VCL_Log {^reconfigure failed}
expect 0 0 VCL_Log {^-- no changes - no debug output$}
expect 0 0 VCL_Log {^-- no backends$}
expect 0 0 Error {^shard vd: .reconfigure.. no backends}
expect 0 0 Error {^vmod_directors shard vd: .reconfigure.. no backends}
expect 0 0 VCL_Log {^reconfigure failed}
expect 0 0 VCL_Log {^-- one backend$}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 VCL_Log {^-- no change - no output$}
expect 0 0 VCL_Log {^-- change, clear, no backends$}
expect 0 0 Error {^shard vd: .reconfigure.. no backends}
expect 0 0 Error {^vmod_directors shard vd: .reconfigure.. no backends}
expect 0 0 VCL_Log {^reconfigure failed}
expect 0 0 VCL_Log {^-- duplicate add$}
expect 0 0 Notice {^shard vd: backend s1 already exists - skipping$}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 1}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Notice {^vmod_directors shard vd: backend s1 already exists - skipping$}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 VCL_Log {^-- duplicate add with idents$}
expect 0 0 Notice {^shard vd: backend s1 already exists - skipping}
expect 0 0 Notice {^shard vd: backend s1/s1_1 already exists - skipping}
expect 0 0 Notice {^shard vd: backend s1/s1_2 already exists - skipping}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 3}
expect 0 0 Debug {^shard:.*point = 732c7bbe, host = 2}
expect 0 0 Debug {^shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Notice {^vmod_directors shard vd: backend s1 already exists - skipping}
expect 0 0 Notice {^vmod_directors shard vd: backend s1/s1_1 already exists - skipping}
expect 0 0 Notice {^vmod_directors shard vd: backend s1/s1_2 already exists - skipping}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = 732c7bbe, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 VCL_Log {^-- remove s1_2 specifically$}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 2}
expect 0 0 Debug {^shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 VCL_Log {^-- remove all instances of s1$}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 0}
expect 0 0 VCL_Log {^-- re-add some - no 2nd director$}
expect 0 0 Debug {^shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^shard:.*point = 6337e62c, host = 8}
expect 0 0 Debug {^shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^shard:.*point = fc1a5162, host = 7}
expect 0 0 Debug {^vmod_directors shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^vmod_directors shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = 6337e62c, host = 8}
expect 0 0 Debug {^vmod_directors shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^vmod_directors shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^vmod_directors shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = fc1a5162, host = 7}
expect 0 0 VCL_Log {^-- remove second-last$}
expect 0 0 Debug {^shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^shard:.*point = 6337e62c, host = 7}
expect 0 0 Debug {^shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^vmod_directors shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = 6337e62c, host = 7}
expect 0 0 Debug {^vmod_directors shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^vmod_directors shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^vmod_directors shard:.*point = f493ce58, host = 2}
expect 0 0 VCL_Log {^-- remove last$}
expect 0 0 Debug {^shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^vmod_directors shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^vmod_directors shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^vmod_directors shard:.*point = f493ce58, host = 2}
expect 0 0 VCL_Log {^-- END$}
} -start
......
......@@ -158,13 +158,13 @@ varnish v1 -vcl+backend {
logexpect l1 -v v1 -g raw -d 1 {
expect * 1001 VCL_Log {^-- invalid replicas$}
expect 0 1001 Error {^shard vd: .reconfigure.. invalid replicas argument 0}
expect 0 1001 Error {^vmod_directors shard vd: .reconfigure.. invalid replicas argument 0}
expect 0 1001 VCL_Log {^reconfigure failed}
expect 0 1001 VCL_Log {^-- no changes - no debug output$}
expect 0 1001 VCL_Log {^-- no backends$}
expect 0 1001 Error {^shard vd: .reconfigure.. no backends}
expect 0 1001 Error {^vmod_directors shard vd: .reconfigure.. no backends}
expect 0 1001 VCL_Log {^reconfigure failed}
expect 0 1001 VCL_Log {^-- one backend$}
......@@ -172,15 +172,15 @@ logexpect l1 -v v1 -g raw -d 1 {
expect 0 1001 VCL_Log {^-- no change - no output$}
expect 0 1001 VCL_Log {^-- change, clear, no backends$}
expect 0 1001 Error {^shard vd: .reconfigure.. no backends}
expect 0 1001 Error {^vmod_directors shard vd: .reconfigure.. no backends}
expect 0 1001 VCL_Log {^reconfigure failed}
expect 0 1001 VCL_Log {^-- duplicate add$}
expect 0 1001 Notice {^shard vd: backend s1 already exists - skipping$}
expect 0 1001 Notice {^vmod_directors shard vd: backend s1 already exists - skipping$}
expect 0 1001 VCL_Log {^-- duplicate add with idents$}
expect 0 1001 Notice {^shard vd: backend s1 already exists - skipping}
expect 0 1001 Notice {^shard vd: backend s1/s1_1 already exists - skipping}
expect 0 1001 Notice {^shard vd: backend s1/s1_2 already exists - skipping}
expect 0 1001 Notice {^vmod_directors shard vd: backend s1 already exists - skipping}
expect 0 1001 Notice {^vmod_directors shard vd: backend s1/s1_1 already exists - skipping}
expect 0 1001 Notice {^vmod_directors shard vd: backend s1/s1_2 already exists - skipping}
expect 0 1001 VCL_Log {^-- remove s1_2 specifically$}
expect 0 1001 VCL_Log {^-- remove all instances of s1$}
expect 0 1001 VCL_Log {^-- re-add some - no 2nd director$}
......@@ -190,41 +190,41 @@ logexpect l1 -v v1 -g raw -d 1 {
}
logexpect l2 -v v1 -g raw -d 1 {
expect * 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 1}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 3}
expect 0 0 Debug {^shard:.*point = 732c7bbe, host = 2}
expect 0 0 Debug {^shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 2}
expect 0 0 Debug {^shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^shard:.*point = 6e040182, host = 0}
expect 0 0 Debug {^shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^shard:.*point = 6337e62c, host = 8}
expect 0 0 Debug {^shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^shard:.*point = fc1a5162, host = 7}
expect 0 0 Debug {^shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^shard:.*point = 6337e62c, host = 7}
expect 0 0 Debug {^shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^shard:.*point = f493ce58, host = 2}
expect * 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = 732c7bbe, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = bae80b0b, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = f08ad325, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 6e040182, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^vmod_directors shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = 6337e62c, host = 8}
expect 0 0 Debug {^vmod_directors shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^vmod_directors shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^vmod_directors shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = fc1a5162, host = 7}
expect 0 0 Debug {^vmod_directors shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^vmod_directors shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = 6337e62c, host = 7}
expect 0 0 Debug {^vmod_directors shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^vmod_directors shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^vmod_directors shard:.*point = f493ce58, host = 2}
expect 0 0 Debug {^vmod_directors shard:.*point = 3d1fe97, host = 3}
expect 0 0 Debug {^vmod_directors shard:.*point = a25a43b, host = 6}
expect 0 0 Debug {^vmod_directors shard:.*point = 2b20d9a2, host = 1}
expect 0 0 Debug {^vmod_directors shard:.*point = c9803f17, host = 5}
expect 0 0 Debug {^vmod_directors shard:.*point = d51dafe6, host = 0}
expect 0 0 Debug {^vmod_directors shard:.*point = eb74a7d5, host = 4}
expect 0 0 Debug {^vmod_directors shard:.*point = f493ce58, host = 2}
}
logexpect l1 -start
......
This diff is collapsed.
......@@ -24,14 +24,14 @@ varnish v1 -vcl {
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 0 0 Error {by=BLOB but no or empty key_blob - using key 0}
expect 0 0 Error {vmod_directors shard p: shard_param.set.. by=BLOB but no or empty key_blob - using key 0}
} -start -wait
logexpect l2 -v v1 -g raw {
expect * 1001 VCL_Error {shard .backend param invalid}
expect * 1001 VCL_Error {vmod_directors shard shard: .backend.key_blob. param invalid}
} -start
logexpect l3 -v v1 -g raw {
expect * 1003 VCL_Error {shard_param.set.. may only be used in vcl_init and in backend/pipe context}
expect * 1003 VCL_Error {vmod_directors shard p: shard_param.set.. may only be used in vcl_init and in backend/pipe context}
} -start
client c1 {
......@@ -159,7 +159,7 @@ varnish v1 -errvcl {invalid warmup argument 1.1} {
}
}
varnish v1 -errvcl {resolve=LAZY with other parameters can only be used in backend/pipe context} {
varnish v1 -errvcl {vmod_directors shard shard: .backend(resolve=LAZY) with other parameters can only be used in backend/pipe context} {
import directors;
import blob;
......@@ -172,7 +172,7 @@ varnish v1 -errvcl {resolve=LAZY with other parameters can only be used in backe
}
}
varnish v1 -errvcl {resolve=NOW can not be used in vcl_init} {
varnish v1 -errvcl {vmod_directors shard shard: .backend(resolve=NOW) can not be used in vcl_init{}/vcl_fini{}} {
import directors;
import blob;
......
This diff is collapsed.
......@@ -48,6 +48,9 @@ Varnish Cache Next (2021-03-15)
* Shard director ``Error`` log messages with ``(notice)`` have been
turned into ``Notice`` log messages.
* All shard ``Error`` and ``Notice`` messages now use the unified
prefix ``vmod_directors shard %s``.
================================
Varnish Cache 6.5.1 (2020-09-25)
================================
......
......@@ -119,7 +119,7 @@ shard_change_get(VRT_CTX, struct sharddir * const shardd)
change = WS_Alloc(ctx->ws, sizeof(*change));
if (change == NULL) {
VRT_fail(ctx, "could not get workspace");
shard_fail(ctx, shardd->name, "%s", "could not get workspace");
return (NULL);
}
......@@ -151,7 +151,8 @@ shard_change_task_add(VRT_CTX, struct shard_change *change,
task = WS_Alloc(ctx->ws, sizeof(*task));
if (task == NULL) {
VRT_fail(ctx, "could not get workspace for task");
shard_fail(ctx, change->shardd->name, "%s",
"could not get workspace for task");
return (NULL);
}
INIT_OBJ(task, SHARD_CHANGE_TASK_MAGIC);
......@@ -179,7 +180,8 @@ shard_change_task_backend(VRT_CTX, struct sharddir *shardd,
b = WS_Alloc(ctx->ws, sizeof(*b));
if (b == NULL) {
VRT_fail(ctx, "could not get workspace for change");
shard_fail(ctx, change->shardd->name, "%s",
"could not get workspace for task");
return (NULL);
}
......@@ -598,8 +600,8 @@ shardcfg_apply_change(struct vsl_log *vsl, struct sharddir *shardd,
const char * const ident = b->ident;
sharddir_err(vsl, SLT_Notice, "shard %s: backend %s%s%s "
"already exists - skipping", shardd->name,
shard_notice(vsl, shardd->name,
"backend %s%s%s already exists - skipping",
VRT_BACKEND_string(b->backend),
ident ? "/" : "",
ident ? ident : "");
......@@ -642,8 +644,8 @@ change_reconfigure(struct shard_change *change, VCL_INT replicas)
shardd->hashcircle = NULL;
if (shardd->n_backend == 0) {
sharddir_err(change->vsl, SLT_Error, "shard %s: .reconfigure() "
"no backends", shardd->name);
shard_err0(change->vsl, shardd->name,
".reconfigure() no backends");
sharddir_unlock(shardd);
return (0);
}
......@@ -660,9 +662,8 @@ shardcfg_reconfigure(VRT_CTX, struct sharddir *shardd, VCL_INT replicas)
CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC);
if (replicas <= 0) {
sharddir_err(ctx->vsl, SLT_Error,
"shard %s: .reconfigure() invalid replicas argument %ld",
shardd->name, replicas);
shard_err(ctx->vsl, shardd->name,
".reconfigure() invalid replicas argument %ld", replicas);
return (0);
}
......
......@@ -78,7 +78,7 @@ sharddir_debug(struct sharddir *shardd, const uint32_t flags)
}
void
sharddir_err(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...)
sharddir_log(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...)
{
va_list ap;
......@@ -242,11 +242,11 @@ validate_alt(VRT_CTX, const struct sharddir *shardd, VCL_INT *alt)
const VCL_INT alt_max = shardd->n_backend - 1;
if (*alt < 0) {
shard_err(ctx, shardd,
shard_err(ctx->vsl, shardd->name,
"invalid negative parameter alt=%ld, set to 0", *alt);
*alt = 0;
} else if (*alt > alt_max) {
shard_err(ctx, shardd,
shard_err(ctx->vsl, shardd->name,
"parameter alt=%ld limited to %ld", *alt, alt_max);
*alt = alt_max;
}
......@@ -408,7 +408,7 @@ sharddir_pick_be(VRT_CTX, struct sharddir *shardd, uint32_t key, VCL_INT alt,
sharddir_rdlock(shardd);
if (shardd->n_backend == 0) {
shard_err0(ctx, shardd, "no backends");
shard_err0(ctx->vsl, shardd->name, "no backends");
sharddir_unlock(shardd);
return (NULL);
}
......
......@@ -89,23 +89,25 @@ sharddir_backend(const struct sharddir *shardd, unsigned id)
#define SHDBG(flag, shardd, ...) \
do { \
if ((shardd)->debug_flags & (flag)) \
VSL(SLT_Debug, 0, "shard: " __VA_ARGS__); \
VSL(SLT_Debug, 0, "vmod_directors shard: " \
__VA_ARGS__); \
} while (0)
#define shard_err(ctx, shardd, fmt, ...) \
do { \
sharddir_err((ctx)->vsl, SLT_Error, "shard %s: " fmt, \
(shardd)->name, __VA_ARGS__); \
} while (0)
#define shard_log(vsl, tag, name, fmt, ...) \
sharddir_log(vsl, tag, "vmod_directors shard %s: " fmt, \
name, __VA_ARGS__)
#define shard_err0(ctx, shardd, msg) \
do { \
sharddir_err((ctx)->vsl, SLT_Error, "shard %s: %s", \
(shardd)->name, (msg)); \
} while (0)
#define shard_fail(ctx, name, fmt, ...) \
VRT_fail(ctx, "vmod_directors shard %s: " fmt, name, __VA_ARGS__)
#define shard_err(vsl, name, fmt, ...) \
shard_log(vsl, SLT_Error, name, fmt, __VA_ARGS__)
#define shard_err0(vsl, name, msg) \
shard_log(vsl, SLT_Error, name, "%s", msg)
#define shard_notice(vsl, name, fmt, ...) \
shard_log(vsl, SLT_Notice, name, fmt, __VA_ARGS__)
void sharddir_debug(struct sharddir *shardd, const uint32_t flags);
void sharddir_err(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...);
void sharddir_log(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...);
void sharddir_new(struct sharddir **sharddp, const char *vcl_name,
const struct vmod_directors_shard_param *param);
void sharddir_set_param(struct sharddir *shardd,
......
......@@ -344,12 +344,12 @@ Error Reporting
Failing methods should report errors to VSL with the Error tag, so
when configuring the shard director, you are advised to check::
varnishlog -I Error:^shard
varnishlog -I Error:^vmod_directors.shard
Additional information may be provided as Notices, which can be
checked using
varnishlog -I Notice:^shard
varnishlog -I Notice:^vmod_directors.shard
$Method VOID .set_warmup(REAL probability=0.0)
......
......@@ -266,7 +266,7 @@ vmod_shard_set_warmup(VRT_CTX, struct vmod_directors_shard *vshard,
{
CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC);
if (probability < 0 || probability >= 1) {
shard_err(ctx, vshard->shardd,
shard_notice(ctx->vsl, vshard->shardd->name,
".set_warmup(%f) ignored", probability);
return;
}
......@@ -297,7 +297,8 @@ vmod_shard_associate(VRT_CTX,
ppt = shard_param_blob(b);
if (ppt == NULL) {
VRT_fail(ctx, "shard .associate param invalid");
shard_fail(ctx, vshard->shardd->name, "%s",
"shard .associate param invalid");
return;
}
......@@ -313,8 +314,8 @@ vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard,
CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC);
if (args->backend == NULL) {
VRT_fail(ctx, "%s: NULL backend cannot be added",
vshard->shardd->name);
shard_fail(ctx, vshard->shardd->name, "%s",
"NULL backend cannot be added");
return (0);
}
......@@ -322,7 +323,7 @@ vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard,
if (args->weight >= 1)
weight = args->weight;
else
shard_err(ctx, vshard->shardd,
shard_notice(ctx->vsl, vshard->shardd->name,
".add_backend(weight=%f) ignored", args->weight);
}
......@@ -342,9 +343,8 @@ vmod_shard_remove_backend(VRT_CTX, struct vmod_directors_shard *vshard,
CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC);
if (be == NULL && ident == NULL) {
VRT_fail(ctx, "%s.backend_remove(): "
"either backend or ident are required",
vshard->shardd->name);
shard_fail(ctx, vshard->shardd->name, "%s",
".backend_remove(): either backend or ident are required");
return (0);
}
......@@ -499,7 +499,7 @@ shard_param_set_mask(const struct VARGS(shard_param_set) * const a)
*/
static struct vmod_directors_shard_param *
shard_param_args(VRT_CTX,
struct vmod_directors_shard_param *p, const char *who,
struct vmod_directors_shard_param *p, const char *func,
uint32_t args, VCL_ENUM by_s, VCL_INT key_int, VCL_BLOB key_blob,
VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, VCL_ENUM healthy_s)
{
......@@ -516,16 +516,15 @@ shard_param_args(VRT_CTX,
/* by_s / key_int / key_blob */
if (by_s == VENUM(KEY)) {
if ((args & arg_key) == 0) {
VRT_fail(ctx, "%s %s: "
"missing key argument with by=%s",
who, p->vcl_name, by_s);
shard_fail(ctx, p->vcl_name,
"%s missing key argument with by=%s",
func, by_s);
return (NULL);
}
if (key_int < 0 || key_int > UINT32_MAX) {
VRT_fail(ctx, "%s %s: "
"invalid key argument %jd with by=%s",
who, p->vcl_name,
(intmax_t)key_int, by_s);
shard_fail(ctx, p->vcl_name,
"%s invalid key argument %jd with by=%s",
func, (intmax_t)key_int, by_s);
return (NULL);
}
assert(key_int >= 0);
......@@ -533,26 +532,24 @@ shard_param_args(VRT_CTX,
p->key = (uint32_t)key_int;
} else if (by_s == VENUM(BLOB)) {
if ((args & arg_key_blob) == 0) {
VRT_fail(ctx, "%s %s: "
"missing key_blob argument with by=%s",
who, p->vcl_name, by_s);
shard_fail(ctx, p->vcl_name,
"%s missing key_blob argument with by=%s",
func, by_s);
return (NULL);
}
if (key_blob == NULL || key_blob->len == 0 ||
key_blob->blob == NULL) {
sharddir_err(ctx->vsl, SLT_Error, "%s %s: "
"by=BLOB but no or empty key_blob "
"- using key 0",
who, p->vcl_name);
shard_err(ctx->vsl, p->vcl_name,
"%s by=BLOB but no or empty key_blob - using key 0",
func);
p->key = 0;
} else
p->key = shard_blob_key(key_blob);
} else if (by_s == VENUM(HASH) || by_s == VENUM(URL)) {
if (args & (arg_key|arg_key_blob)) {
VRT_fail(ctx, "%s %s: "
"key and key_blob arguments are "
"invalid with by=%s",
who, p->vcl_name, by_s);
shard_fail(ctx, p->vcl_name,
"%s key and key_blob arguments are "
"invalid with by=%s", func, by_s);
return (NULL);
}
} else {
......@@ -562,9 +559,9 @@ shard_param_args(VRT_CTX,
if (args & arg_alt) {
if (alt < 0) {
VRT_fail(ctx, "%s %s: "
"invalid alt argument %jd",
who, p->vcl_name, (intmax_t)alt);
shard_fail(ctx, p->vcl_name,
"%s invalid alt argument %jd",
func, (intmax_t)alt);
return (NULL);
}
p->alt = alt;
......@@ -572,9 +569,9 @@ shard_param_args(VRT_CTX,
if (args & arg_warmup) {
if ((warmup < 0 && warmup != -1) || warmup > 1) {
VRT_fail(ctx, "%s %s: "
"invalid warmup argument %f",
who, p->vcl_name, warmup);
shard_fail(ctx, p->vcl_name,
"%s invalid warmup argument %f",
func, warmup);
return (NULL);
}
p->warmup = warmup;
......@@ -618,9 +615,10 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
}
if ((ctx->method & SHARD_VCL_TASK_BEREQ) == 0) {
VRT_fail(ctx, "shard .backend resolve=LAZY with other "
"parameters can only be used in backend/pipe "
"context");
shard_fail(ctx, vshard->shardd->name, "%s",
".backend(resolve=LAZY) with other "
"parameters can only be used in backend/pipe "
"context");
return (NULL);
}
......@@ -633,9 +631,9 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
pp->vcl_name = vshard->shardd->name;
} else if (resolve == VENUM(NOW)) {
if (ctx->method & VCL_MET_TASK_H) {
VRT_fail(ctx,
"shard .backend resolve=NOW can not be "
"used in vcl_init{}/vcl_fini{}");
shard_fail(ctx, vshard->shardd->name, "%s",
".backend(resolve=NOW) can not be "
"used in vcl_init{}/vcl_fini{}");
return (NULL);
}
pp = shard_param_stack(&pstk, vshard->shardd->param,
......@@ -648,7 +646,8 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
if (args & arg_param) {
ppt = shard_param_blob(a->param);
if (ppt == NULL) {
VRT_fail(ctx, "shard .backend param invalid");
shard_fail(ctx, vshard->shardd->name, "%s",
".backend(key_blob) param invalid");
return (NULL);
}
pp->defaults = ppt;
......@@ -885,7 +884,7 @@ shard_param_task(VRT_CTX, const void *id,
task = VRT_priv_task(ctx, task_id);
if (task == NULL) {
VRT_fail(ctx, "no priv_task");
shard_fail(ctx, pa->vcl_name, "%s", "no priv_task");
return (NULL);
}
......@@ -897,7 +896,7 @@ shard_param_task(VRT_CTX, const void *id,
p = WS_Alloc(ctx->ws, sizeof *p);
if (p == NULL) {
VRT_fail(ctx, "shard_param_task WS_Alloc failed");
shard_fail(ctx, pa->vcl_name, "%s", "WS_Alloc failed");
return (NULL);
}
task->priv = p;
......@@ -921,8 +920,8 @@ shard_param_prep(VRT_CTX, struct vmod_directors_shard_param *p,
CHECK_OBJ_NOTNULL(p, VMOD_SHARD_SHARD_PARAM_MAGIC);
if (ctx->method & SHARD_VCL_TASK_REQ) {
VRT_fail(ctx, "%s may only be used "
"in vcl_init and in backend/pipe context", who);
shard_fail(ctx, p->vcl_name, "%s may only be used "
"in vcl_init and in backend/pipe context", who);
return (NULL);
} else if (ctx->method & SHARD_VCL_TASK_BEREQ)
p = shard_param_task(ctx, p, p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment