Skip to content

fix: (migrated PR 4094): fix socket.gethostbyaddr(ip) error when no reverse DNS available. #4095

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

Merged
merged 7 commits into from
Jul 14, 2025

Conversation

pyansys-ci-bot
Copy link
Contributor

@pyansys-ci-bot pyansys-ci-bot commented Jul 14, 2025

This PR is a mirror pull request created from Fix socket.gethostbyaddr(ip) error when no reverse DNS available. to allow the code to access PyMAPDL CICD secrets.

Check the original PR made by @yeguang-xue for more details.

Closes #4094

Original pull request

Fix socket.gethostbyaddr(ip) error when no reverse DNS available.

Description

For ip addresses without reverse DNS, socket.gethostbyaddr(ip) will fail. We can simply use ip address for hostname display.

Issue linked

Please mention the issue number or describe the problem this pull request addresses.

Checklist

Summary by Sourcery

Bug Fixes:

  • Fallback to using the raw IP for hostname instead of calling gethostbyaddr for non-DNS-resolvable addresses

yeguang-xue and others added 2 commits July 11, 2025 12:41
For ip addresses without reverse DNS, socket.gethostbyaddr(ip) will fail. We can simply use ip address for hostname display.
Copy link
Contributor

sourcery-ai bot commented Jul 14, 2025

Reviewer's Guide

Hostname resolution logic updated to use the raw IP for non-local addresses, removing the reverse DNS lookup call to prevent socket.gethostbyaddr failures.

Class diagram for updated hostname resolution logic

classDiagram
    class MapdlGrpc {
        - _hostname
        __init__(ip)
    }
    %% Before: _hostname set via socket.gethostbyaddr(ip) for non-local IPs
    %% After: _hostname set to ip directly for non-local IPs (no reverse DNS lookup)
Loading

File-Level Changes

Change Details Files
Avoid reverse DNS lookup failures by using IP as hostname fallback
  • Removed socket.gethostbyaddr call for non-local IPs
  • Retained explicit mapping of loopback addresses to “localhost”
  • Assigned raw IP string as hostname when no DNS available
src/ansys/mapdl/core/mapdl_grpc.py

Assessment against linked issues

Issue Objective Addressed Explanation

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ansys-reviewer-bot
Copy link
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@germa89 germa89 changed the title migrated (PR 4094): Fix socket.gethostbyaddr(ip) error when no reverse DNS available. fix: (migrated PR 4094): fix socket.gethostbyaddr(ip) error when no reverse DNS available. Jul 14, 2025
@github-actions github-actions bot added the bug Issue, problem or error in PyMAPDL label Jul 14, 2025
@germa89
Copy link
Collaborator

germa89 commented Jul 14, 2025

@yeguang-xue I took advantage of your PR to do a small refactoring. I hope you dont mind.

Good job!

Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.80%. Comparing base (a9d37dc) to head (f99fd82).
Report is 3 commits behind head on main.

❌ Your patch status has failed because the patch coverage (84.61%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4095      +/-   ##
==========================================
- Coverage   91.82%   91.80%   -0.03%     
==========================================
  Files         187      187              
  Lines       15033    15041       +8     
==========================================
+ Hits        13804    13808       +4     
- Misses       1229     1233       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@germa89
Copy link
Collaborator

germa89 commented Jul 14, 2025

I do not care about coverage for this case.

@pyansys-ci-bot LGTM.

@germa89 germa89 enabled auto-merge (squash) July 14, 2025 11:32
Copy link
Collaborator

@germa89 germa89 left a comment

Choose a reason for hiding this comment

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

LGTM.

@germa89 germa89 merged commit 754fdf1 into main Jul 14, 2025
46 of 47 checks passed
@germa89 germa89 deleted the migration/pr-4094 branch July 14, 2025 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue, problem or error in PyMAPDL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants