New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add std.ban()
for vcl access to ban errors
#3486
Conversation
d60607d
to
e7c2329
Compare
+1 on this feature, but I have a comment about:
Since VCL doesn't have a For that they'd have to check whether the return value is Maybe just an addition to the documentation is enough:
But the true/false sense in So I wonder if VMOD std could use a convenience function that issues a ban and just returns BOOL true on success, false on failure. Or maybe Another consideration would be to add a |
Thank you for your suggestions @slimhazard . I'd like to gather some more feedback from others and have thus suggested the ticket for bugwash in 2021. |
Note: the second option is "make That gets us into using task scope to save the error message. VMOD std has avoided that kind of thing for the most part. I guess return NULL as the error message if the last ban was successful, or if there hasn't been a ban during the task? Seems to be getting a bit complicated, for something meant to be fairly simple. The third option is at risk of POLA, since IMO the truthiness of VCL strings makes the usage in BOOL context unintuitive. So I voted for the first option (return "SUCCESS" when the ban succeeded). |
re @slimhazard I see no problem with saving the last ban error in a priv_task |
bugwash decision:
roadmap:
|
0c9c7a3
to
7f6ead7
Compare
changed accordingly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have little changes to consider for this pull request.
In addition, I would like to point other potential changes in the ban code.
We have two static ban_error()
functions, I suggest we rename one to vrt_ban_error()
.
The BAN_Abandon()
function should take a struct ban_proto **
and wipe it.
Conversely, BAN_Commit()
should do the same thing since it calls the former.
Circling back to this pull request, the changes suggested above could later help simplify the code touched by this diff. I'm not suggesting this to be fixed now, only as a followup cleanup task.
For the requested changes to this pull request, see below.
b31e6d6
to
475b202
Compare
@Dridi I have changed the documentation wording. May I ask for your OK? I am with you on the implementation changes, and I work on them. |
The ban() vcl action adds bans like the ban CLI command, but has no facility for in-band error reporting. Errors are only reported to VSL. We add std.ban() as a replacement for ban() with identical semantics, but returning if the ban was successfully added. std.ban_error() is added to report the error, if any. We add v00009.vtc mirroring v00011.vtc, but with std.ban() replacing ban(). The test number was chosen to fill a gap close to v00011.vtc. Implementation: We change VRT_ban_string() to return any error or NULL for success. Where the error is not a constant string, we need to format it on the workspace. For workspace overflows, we need to fall back to canned constant error strings to ensure that the error case never appears as success.
54474e7
to
6eee007
Compare
from #3486 (review) as that ticket is closed now
Ref #3486 (comment) roadmap: v/ add std.ban*(), add implicit import std vcc aliases ban() to std.ban() (some concerns raised) v/ deprecated ban() without std. remove ban() without std.
The
ban()
vcl action adds bans like theban
CLI command, but has no facility for in-band error reporting. Errors are only reported to VSL.We add
std.ban()
as a replacement forban()
with identical semantics, but error reporting added.We add
v00009.vtc
mirroringv00011.vtc
, but withstd.ban()
replacingban()
. The test number was chosen to fill a gap close tov00011.vtc
.Implementation:
We change
VRT_ban_string()
to return any error. Where the error is not a constant string, we need to format it on the workspace. For workspace overflows, we need to fall back to canned constant error strings to ensure that the error case never appears as success.