Skip to content
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

auth: added self weighted lua function #10692

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

n0tlu5
Copy link

@n0tlu5 n0tlu5 commented Sep 6, 2021

Short description

added a new Lua function that returns pickwhashed or pickrandom(if there is no available candidate) but the weight is fetched from candidates via URL. Modified some functions to be able to provide weight as a state.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • documented the code
  • added or modified regression test(s)
  • included documentation (including possible behaviour changes)
  • added or modified unit test(s)
  • checked that this code was merged to master

@Habbie Habbie added this to the auth-4.6.0 milestone Sep 6, 2021
@Habbie Habbie self-requested a review September 6, 2021 07:10
@Habbie Habbie modified the milestones: auth-4.6.0, auth-4.6.0-alpha2 Sep 21, 2021
@Habbie Habbie modified the milestones: auth-4.6.0-alpha2, auth-5 Nov 18, 2021
@Habbie Habbie self-assigned this Feb 21, 2023
@coveralls
Copy link

coveralls commented May 6, 2024

Pull Request Test Coverage Report for Build 12544460123

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 45 (0.0%) changed or added relevant lines in 1 file are covered.
  • 11254 unchanged lines in 158 files lost coverage.
  • Overall coverage increased (+9.4%) to 73.952%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/lua-record.cc 0 45 0.0%
Files with Coverage Reduction New Missed Lines %
pdns/dnsdistdist/dnsdist-session-cache.cc 1 62.86%
pdns/dns.hh 1 75.0%
pdns/dnspacket.hh 1 94.44%
modules/gpgsqlbackend/gpgsqlbackend.cc 1 88.62%
pdns/dnsdistdist/test-dnsdistrules_cc.cc 1 95.15%
pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc 1 85.12%
pdns/recursordist/rec-main.hh 1 83.17%
pdns/backends/gsql/gsqlbackend.hh 1 97.71%
ext/lmdb-safe/lmdb-typed.cc 1 89.66%
pdns/dnsdistdist/dnsdist-lbpolicies.hh 1 64.29%
Totals Coverage Status
Change from base Build 9198989085: 9.4%
Covered Lines: 47587
Relevant Lines: 61249

💛 - Coveralls

@Habbie
Copy link
Member

Habbie commented May 16, 2024

lua-record.cc:229:20: error: use of undeclared identifier 'd_lock' - are you sure you compiled the version you PRed here?

given the age of this PR (sorry) it might have been from the merge, of course. Can you rebase and test? Thank you!

Copy link
Member

@Habbie Habbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense at a quick glance. It'll need a minor rework because we changed how locking works. Can you add docs?

I'm unsure about the name selfweighted but that's a small detail. Once you have docs it'll be easier to reason about what this is and thus what we should call it.

pdns/lua-record.cc Outdated Show resolved Hide resolved
@n0tlu5 n0tlu5 closed this May 22, 2024
@n0tlu5 n0tlu5 force-pushed the sulton/self-weighted branch from 8fda9ac to 08086d6 Compare May 22, 2024 17:47
@n0tlu5 n0tlu5 reopened this May 22, 2024
@n0tlu5 n0tlu5 force-pushed the sulton/self-weighted branch from 15d9311 to b348bb1 Compare May 22, 2024 18:09
@n0tlu5
Copy link
Author

n0tlu5 commented May 23, 2024

compiled 5f3a65f, i can provide the docker image if needed

pdns/lua-record.cc Outdated Show resolved Hide resolved
@n0tlu5 n0tlu5 requested a review from Habbie July 24, 2024 01:44
Copy link
Member

@Habbie Habbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks decent. Still needs documentation and a test.

pdns/lua-record.cc Outdated Show resolved Hide resolved
pdns/lua-record.cc Show resolved Hide resolved
pdns/lua-record.cc Show resolved Hide resolved
pdns/lua-record.cc Outdated Show resolved Hide resolved
@n0tlu5
Copy link
Author

n0tlu5 commented Dec 24, 2024

should i resolve those failing checks?
i do not understand the "CodeQL and clang-tidy" check

@miodvallat
Copy link
Contributor

should i resolve those failing checks? i do not understand the "CodeQL and clang-tidy" check

Yes, please. You need to add the new function name to the extra words list of the spell checker. The clang-tidy results are indeed not always easy to find. Here they are, for the lines changed by your PR:

Warning: pdns/lua-record.cc:90: parameter name 'cd' is too short, expected at least 3 characters (readability-identifier-length)
Warning: pdns/lua-record.cc:245: parameter name 'cd' is too short, expected at least 3 characters (readability-identifier-length)
Warning: pdns/lua-record.cc:275: parameter name 'cd' is too short, expected at least 3 characters (readability-identifier-length)
Warning: pdns/lua-record.cc:1196: statement should be inside braces (readability-braces-around-statements)
Warning: pdns/lua-record.cc:1200: converting integer literal to bool, use bool literal instead (modernize-use-bool-literals)
Warning: pdns/lua-record.cc:1200: implicit conversion 'int' -> bool (readability-implicit-bool-conversion)
Warning: pdns/lua-record.cc:1207: converting integer literal to bool, use bool literal instead (modernize-use-bool-literals)
Warning: pdns/lua-record.cc:1207: implicit conversion 'int' -> bool (readability-implicit-bool-conversion)

They should be easy to address, or you can add //NOLINT(readability-identifier-length) to the first three cases, to avoid having to touch too many lines of code. The other points (braces for single-statement if and explicit casts) need to be addressed, though.

@omoerbeek
Copy link
Member

should i resolve those failing checks? i do not understand the "CodeQL and clang-tidy" check

You can see the reported issues in context i the "Files changed" tab.

pdns/lua-record.cc Outdated Show resolved Hide resolved
@n0tlu5
Copy link
Author

n0tlu5 commented Dec 30, 2024

the statement inside braces check confuses me

@n0tlu5
Copy link
Author

n0tlu5 commented Jan 5, 2025

the check still fails

@miodvallat
Copy link
Contributor

Please use NOLINTNEXTLINE instead of NOLINT when the comment concerns the following line. That ought to appease clang-tidy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants