-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rlm_redis_ippool: break out lua scripts as defacto schema #2626
Conversation
I effectively reverted 3d07585 in my PR, so we probably should get that resolved properly. |
@@ -0,0 +1,229 @@ | |||
-- must match redis_ippool.h | |||
local ippool_rcode_success = 0 |
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.
maybe:
local ippol_rcode = {
not_found = -1,
device_mismatch = -3
..........
}
then can call using: ippol_rcode.notfound
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.
As all the logic is in a single small file I do not think there is no gain to readability and indirect table access requires an additional load (not checked the JIT output but guessing it turns directs variables into immediates) via the call to GETTABLE
.
I think this boils down to coding style, so happy to change it.
$ cat example-direct.lua
local rcode_one = 1
local rcode_two = 2
local rcode_three = 3
print(rcode_one)
$ luac -l example-direct.lua
main <example-direct.lua:0,0> (7 instructions, 28 bytes at 0x558023218550)
0+ params, 5 slots, 0 upvalues, 3 locals, 4 constants, 0 functions
1 [1] LOADK 0 -1 ; 1
2 [2] LOADK 1 -2 ; 2
3 [3] LOADK 2 -3 ; 3
4 [5] GETGLOBAL 3 -4 ; print
5 [5] MOVE 4 0
6 [5] CALL 3 2 1
7 [5] RETURN 0 1
$ cat example-table.lua
local rcode = {
one = 1,
two = 2,
three = 3
}
print(rcode.one)
$ luac -l example-table.lua
main <example-table.lua:0,0> (8 instructions, 32 bytes at 0x556389880550)
0+ params, 3 slots, 0 upvalues, 1 local, 7 constants, 0 functions
1 [1] NEWTABLE 0 0 3
2 [2] SETTABLE 0 -1 -2 ; "one" 1
3 [3] SETTABLE 0 -3 -4 ; "two" 2
4 [4] SETTABLE 0 -5 -6 ; "three" 3
5 [7] GETGLOBAL 1 -7 ; print
6 [7] GETTABLE 2 0 -1 ; "one"
7 [7] CALL 1 2 1
8 [7] RETURN 0 1
} | ||
len = fread(pos, sizeof(char), finfo.st_size, f); | ||
if (len != finfo.st_size) { | ||
ERROR("Error reading Redis Lua file (%s): %s", script->file, fr_syserror(errno)); |
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.
if failed, it should continue or go to some of those err
labels?
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.
Good catch, fixed in jimdigriz@7a6e966
The gateway ID and counter fields should not be stripped. They're used in customer deployments. Can you add that code back in, and I'll add some additional code to dump them into the current FR request to make them available for general consumption. |
Can you break out your changes to the content of the lua scripts into a separate commit. Because they've been moved bodily to external files, it's hard to see what actually changed. |
Summary of changes:
I could not see any active use of the |
Yes I read the comment and changed the query to a request :) They're both used, but not queried directly through rlm_redis_ippool in existing deployments. It shouldn't be hard to fix that though and dump them into the request list when the ippool module is called. |
Not sure what you mean by this? As originally most of the Lua was in a large Maybe if you describe what you want to see, maybe with an example, it will be clearer to me? |
Are you thinking as just a generic KV store? Something that would just extend the |
In addition to changing the location of the lua code, you changed the functionality of the lua code. It would have been nice to see the changes in content first, before you moved it over to external files. The alternative would be to have a commit moving the lua code out to separate files and changing the return codes, then another commit changing the functionality, which I suspect would be easier. |
Not currently, I was just going to dump the values into attributes, but yeah eventually it might be nice to offer that functionality. |
ffcd452
to
a00a300
Compare
Compile tested only, good enough to see the affect, shows conceptually how extracting the Lua code looks: master...jimdigriz:rlm_redis_ippool_lua_stepped I am continuing to add the remains of master...jimdigriz:rlm_redis_ippool_lua as more digestible parts. |
a00a300
to
47e10f9
Compare
47e10f9
to
5825ee3
Compare
8f32510
to
0669cae
Compare
This work cycle is now complete, tests have also been fixed up. TravisCI/clang seems to be upset about HTML entities in a C header file, not really sure how I could have caused this: https://travis-ci.org/FreeRADIUS/freeradius-server/jobs/539870493#L3706 Can someone look over my PR and let me know what the next steps for me are. |
0669cae
to
c212d03
Compare
@jimdigriz Try to:
|
Done 06bac70, thanks!
Not sure what you mean by this. |
I mean, update the documentation in src/modules/rlm_redis_ippool/redis_ippool.h replacing the cluster.h by redis_ippool.h |
Can you squash the fixes that address errors in new code? I'll push something for the copyright notices. |
Rebase and doxygen should no longer cause issues |
0dd6a3b
to
ad89f49
Compare
Changes made, tests are now passing. Can someone look over my PR and let me know what the next steps for me are. |
Can you add the "modify" tests back in, and update the list of changes in the description to reflect the changes you've done recently, and the changes that are included in this PR. As we talked about offline, the utility behaviour must not change as it's already in use at multiple sites. I really don't like the use of cjson to encode responses to the stats request, as it adds a dependency that wasn't there before. What was the reason for doing this? The Redis protocol already supports returning the contents of hashes. |
Other Changes: - 'modify' removed as it's functionality subsets 'add' - pipelining removed from rlm_redis_ippool_tool (hard to retain, and this is going to be punted redis side in a later patch)
we also take the opportunity to make sticky IPs work (device key expires 10x later)
ad89f49
to
9df5ccc
Compare
I will do this.
I brought this up as a possible problem over six weeks ago. I cannot work on a cycle of "make all these changes" and then something that I flagged up before those changes is not a problem that concerns you. Thank you for wasting time and efforts. |
Where was this raised as an issue? |
Throughout this project there have been communication issues. Ones that I've tried to go out of my way to address, by outlining an effective way of working jointly on this design. Despite this multiple intermediary design decisions were made without requesting my feedback, which as the person who's actually wrote the code originally and who has deployed it at multiple customer sites, It should have been. If nothing else, to ensure that we don't break existing deployments with changes in behaviour here. The original PR you created had some major red flags, which is why I didn't give it serious consideration. Those were:
Passing tests, and clean, broken out commits are the basic requirements to get good feedback. If those aren't there it just screams "Don't give a shit" and "You should be honoured to review my work!" - don't be surprised if reviews get repeatedly deferred. |
Anyway, just forget the review, I'll pull your changes across manually. I don't think continuing to work on this together is going to be constructive or productive. |
Summary of changes:
rlm_redis_ippool.c:ippool_script
tocluster.c:fr_redis_script
so to remove code duplicationpreamble.lua:iptool_module
xargs
/...)device
keys live for 10x lease time)Talking points:
${READFILE} /path/to/file.lua
(suggested by @arr2036)