shard: add error message for invalid weight

This was brought up by Dridi in an email response to
b90b60d0:

Initially, I also thought that we should VRT_fail() for an invalid
parameter, but on second thought I realized that, as the shard director
supports request-time reconfiguration, graceful error handling should be
possible, so VRT_fail() is too hard.

I think that even returning false for .add_backend() is too harsh, as an
invalid weight is probably not too much of an issue to abort the
reconfiguration in the case of caller error handling.

That said, this might all be over the top. But I really do not want to
run into the (still unfixed) case I saw recently trying to base64 decode
an invalid input, which is not possible to handle gracefully.
parent daf48542
......@@ -315,8 +315,13 @@ vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard,
return (0);
}
if (args->valid_weight && args->weight > 1)
weight = args->weight;
if (args->valid_weight) {
if (args->weight >= 1)
weight = args->weight;
else
shard_err(ctx, vshard->shardd,
".add_backend(weight=%f) ignored", args->weight);
}
return shardcfg_add_backend(ctx, args->arg1,
vshard->shardd, args->backend,
......
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