Skip to content
Snippets Groups Projects

Catch NoResponseError from Net::DNS in LoadBalancing::Resolver

Merged Jason Plum requested to merge dblb-split-ns-resolution into master
All threads resolved!

What does this MR do?

Catch NoResponseError from Net::DNS in LoadBalancing::Resolver

Catch the NoResponseError rendered from Net::DNS::Resolver when it detects no repsonse from the DNS server. We do this so that we can raise our own UnresolvableNameserverError stating that there was no response. This allows us to differentiate between getting no answers and getting no response from the system's DNS servers.

Related to #271575 (closed)

The GitLab::Database::LoadBalancing::Resolver class is written to expect the user to call .resolve. .resolve will either return the first address found, or raise UnresolvableNameserverError if address is empty after exhausting all methods. "Swallowing" NoResponseError in ip_address_from_dns makes sense within this context, and is the MVC to address lack of visibility found in #271575 (closed)

The flaw addressed here actually lies within ip_address_from_dns because it can never return if answer.empty? as Net::DNS::Resolver.query will raise NoResponseError if there was no response from the systems' DNS. As no class here handles that error, the caller of .resolve will have priority, which ends up being GitLab::Database::LoadBalancing.start. The problem there, is that that class can not differentiate between failure to resolve nameserver from local resolution and failure to resolve record with that nameserver.

Here we swallow NoResponseError and raise our own in .ip_address_from_dns. Thus, when ...::LoadBalancing.start catch the error, we'll actually know it was a failure to resolve nameserver, not a failure of Consul (most common nameserver) to give us response(s) for the record.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Jason Plum

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 1 Message
    :book: This merge request adds or changes files that require a review from the Database team.

    This merge request requires a database review. To make sure these changes are reviewed, take the following steps:

    1. Ensure the merge request has database and databasereview pending labels. If the merge request modifies database files, Danger will do this for you.
    2. Prepare your MR for database review according to the docs.
    3. Assign and mention the database reviewer suggested by Reviewer Roulette.

    The following files require a review from the Database team:

    • ee/lib/gitlab/database/load_balancing/resolver.rb

    Reviewer roulette

    Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.

    To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.

    To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.

    Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.

    Category Reviewer Maintainer
    backend Marc Shaw (@marc_shaw) (UTC+13, 17 hours ahead of @WarheadsSE) Nick Thomas (@nick.thomas) (UTC+0, 4 hours ahead of @WarheadsSE)
    database Alex Ives (@alexives) (UTC-5, 1 hour behind @WarheadsSE) Steve Abrams (@sabrams) (UTC-6, 2 hours behind @WarheadsSE)

    If needed, you can retry the danger-review job that generated this comment.

    Generated by :no_entry_sign: Danger

    Edited by 🤖 GitLab Bot 🤖
  • Jason Plum resolved all threads

    resolved all threads

  • Jason Plum added 1 commit

    added 1 commit

    • 5b44b088 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Jason Plum requested review from @stanhu

    requested review from @stanhu

  • Jason Plum changed the description

    changed the description

  • mentioned in issue #271575 (closed)

  • Stan Hu
  • Stan Hu requested review from @WarheadsSE and removed review request for @stanhu

    requested review from @WarheadsSE and removed review request for @stanhu

  • Stan Hu removed review request for @WarheadsSE

    removed review request for @WarheadsSE

  • assigned to @WarheadsSE

  • Jason Plum changed milestone to %13.11

    changed milestone to %13.11

  • Jason Plum added 1 commit

    added 1 commit

    Compare with previous version

  • Jason Plum added 1 commit

    added 1 commit

    • 569a9aee - Move changelog per bot complaint

    Compare with previous version

  • Jason Plum changed the description

    changed the description

  • Setting label groupdistribution based on @WarheadsSE's group.

  • Jason Plum added 1 commit

    added 1 commit

    • 6ea7f356 - Update tests for GL::DB::LB::Resolver

    Compare with previous version

  • Jason Plum requested review from @stanhu

    requested review from @stanhu

  • Author Developer

    Note: failure in https://gitlab.com/gitlab-org/gitlab/-/jobs/1125662919 has no impact on this MR. We know the cause of that.

  • Stan Hu
  • Jason Plum added 942 commits

    added 942 commits

    Compare with previous version

  • Jason Plum changed the description

    changed the description

  • Stan Hu approved this merge request

    approved this merge request

  • Stan Hu resolved all threads

    resolved all threads

  • Stan Hu enabled an automatic merge when the pipeline for 6bf4b23a succeeds

    enabled an automatic merge when the pipeline for 6bf4b23a succeeds

  • merged

  • Stan Hu mentioned in commit 97a3733f

    mentioned in commit 97a3733f

  • added workflowproduction label and removed workflowstaging label

  • mentioned in issue #364370 (closed)

  • Please register or sign in to reply
    Loading