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

Remove dependency on Net::IP, and use Net::IP::XS everywhere #1119

Merged
merged 10 commits into from
Sep 16, 2022

Conversation

anandb-ripencc
Copy link
Contributor

@anandb-ripencc anandb-ripencc commented Aug 3, 2022

Purpose

This PR replaces Net::IP with Net::IP::XS. It doesn't get rid of old code that still checks for Net::IP. That can come in a later PR that does cleanup and also updates the installation documentation.

Context

This replaces #1113 and #1114 and #1108

Resolves #1107

Changes

...

How to test this PR

...

@matsduf matsduf added this to the v2022.2 milestone Aug 3, 2022
@matsduf matsduf requested a review from mattias-p August 3, 2022 14:30
@matsduf
Copy link
Contributor

matsduf commented Aug 3, 2022

lib/Zonemaster/Engine/Net/IP.pm must also be updated. And lib/Zonemaster/Engine/ASNLookup.pm has some reference in documentation.

@matsduf matsduf requested review from hannaeko and a user August 3, 2022 14:36
@anandb-ripencc
Copy link
Contributor Author

@matsduf lib/Zonemaster/Engine/Net/IP.pm doesn't use Net::IP if Net::IP::XS is present. Can't we handle updating it in a separate cleanup PR? There are several places from where Net::IP has to be removed, but this PR is only to switch from Net::IP to Net::IP::XS without also doing a cleanup.

matsduf
matsduf previously requested changes Aug 3, 2022
Dockerfile Show resolved Hide resolved
Makefile.PL Outdated Show resolved Hide resolved
@matsduf
Copy link
Contributor

matsduf commented Aug 3, 2022

@matsduf lib/Zonemaster/Engine/Net/IP.pm doesn't use Net::IP if Net::IP::XS is present. Can't we handle updating it in a separate cleanup PR? There are several places from where Net::IP has to be removed, but this PR is only to switch from Net::IP to Net::IP::XS without also doing a cleanup.

If this is to be the switch, all places should be handled. I have created a pull request against your develop branch for the file, to be included in this PR.

In lib/Zonemaster/Engine/ASNLookup.pm it is documentation only to be updated.

Are there more places? I do not think so, but I can be wrong.

Removes Net::IP as dependency, use Net::IP::XS only.
Replace references to Net::IP with references to Net::IP::XS
@anandb-ripencc
Copy link
Contributor Author

Hi @matsduf I believe all the code changes are done now. There is only one unresolved discussion, about the Dockerfile. I do not believe it is necessary to explicitly install Net::IP::XS, because it will be pulled in as a dependency of the engine. If you disagree, I would like to understand why.

@matsduf
Copy link
Contributor

matsduf commented Aug 12, 2022

As you can see all direct dependencies are listed in Dockerfile, either as binary package or as CPAN package. In that way there is a complete list. If Net::IP::XS is not included, then it would be inconsistent since the other dependencies of CPAN are listed there.

@matsduf
Copy link
Contributor

matsduf commented Aug 12, 2022

I made a mistake in my pull request to your pull request. I have added another commit to fix that. I think you have to accept to make it to be included.

}

1;

=head1 NAME

Zonemaster::Engine::Net::IP - Net::IP/Net::IP::XS Wrapper (STILL EXPERIMENTAL)
Zonemaster::Engine::Net::IP - Net::IP::XS Wrapper
Copy link
Member

Choose a reason for hiding this comment

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

We should probably mark this module as deprecated in this release. In a future release we can drop it entirely and just use Net::IP::XS directly instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably mark this module as deprecated in this release. In a future release we can drop it entirely and just use Net::IP::XS directly instead.

If Net::IP is not dropped then #1108 should be merged to work-around the bug in Net::IP.

@matsduf
Copy link
Contributor

matsduf commented Aug 15, 2022

The changes in lib/Zonemaster/Engine/Net/IP.pm make the loading of some data files in the unit tests to crash, but not all of them. See #1121 for a test pull request where only those change are include plus a needed addition change in Makefile.PL. Loading e.g. t/Test-basic.data works well, but not e.g. t/Test-consistency05-A.data. The error message, when loading fails, is

Failed to build RR: Syntax error, could not parse the RR's rdata at Zonemaster/LDNS/RR.pm line 89.

  • Are the affected data files dependent on Net::IP, or
  • Is there a bug in the changed lib/Zonemaster/Engine/Net/IP.pm?

The issue has been resolved by commit 72d9b12.

@matsduf matsduf dismissed their stale review August 20, 2022 20:20

I see no more issues.

@matsduf
Copy link
Contributor

matsduf commented Aug 20, 2022

@mattias-p, @blacksponge and @PNAX, can you please review? The PR passes the unit tests now.

@matsduf matsduf requested a review from mattias-p August 20, 2022 20:22
Comment on lines 8 to 18
my $p_class = eval {
require Net::IP::XS;
return q{Net::IP::XS};
} || eval {
require Net::IP;
return q{Net::IP};
};

if ( $p_class ) {
$p_class->import;
}
else {
die "Both Net::IP and Net::IP::XS missing?\n";
die "Net::IP::XS is not loaded\n";
}
Copy link

Choose a reason for hiding this comment

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

2 questions here:

  1. why can't we just have use Net::IP::XS here? I've tested it and tests are failing, it seems we can't import the module at compile time, any idea why?
  2. can we get rid of the $p_class variable with something like:
    eval {
        require Net::IP::XS;
        Net::IP::XS->import;
    };
    if ( $@ ) {
        die "Net::IP::XS is not loaded\n";
    }
    
    Net::IP::XS->new( '192.0.2.1' );

Copy link
Member

Choose a reason for hiding this comment

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

  1. I very much believe we could.
  2. A simple use Net::IP::XS would replace all of this code too.

The reason we had all this complexity in the first place was to make things work smoothly even if either one of Net::IP::XS or Net::IP was unavailable. Since we're dropping the dependency on Net::IP and promoting Net::IP::XS to a hard requirement we can just use that the normal way we don't need to do anything fancy at all.

Copy link
Member

Choose a reason for hiding this comment

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

On the other hand I'm not sure it's right to demand of @anandb-ripencc to do all the clean up. In my view we shouldn't be so hard on external contributors. I think fine if we the team clean things up to our own standards after merging an externally contributed PR that's functionally correct.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, and the clean up should probably be to remove the entire Zonemaster::Engine::Net::IP module, and replace all its uses with direct calls into Net::IP::XS.

Copy link
Contributor

Choose a reason for hiding this comment

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

In my first iteration I had

use Net::IP::XS;
my $p_class = q{Net::IP::XS};

but then many unit tests failed (see #1121).

$p_class is used in other places in the code.

The update in this PR is the minimal change to make it work with Net::IP::XS without Net::IP. If this PR is OK, then a clean-up could be done later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, and the clean up should probably be to remove the entire Zonemaster::Engine::Net::IP module, and replace all its uses with direct calls into Net::IP::XS.

I suggest that we take things in steps. Such a changes also affects Zonemaster-CLI and Zonemaster-Backend.

@matsduf
Copy link
Contributor

matsduf commented Aug 22, 2022

@mattias-p and @PNAX, are you fine with the PR as-is? If so, please approve. The change in Zonemaster::Engine::Net::IP is the minimal change to make it work.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

On the other hand I'm not sure it's right to demand of @anandb-ripencc to do all the clean up. In my view we shouldn't be so hard on external contributors. I think fine if we the team clean things up to our own standards after merging an externally contributed PR that's functionally correct.

You have a very good point. Thanks @anandb-ripencc for providing this PR!

@matsduf matsduf self-assigned this Sep 13, 2022
@matsduf
Copy link
Contributor

matsduf commented Sep 13, 2022

@mattias-p and @blacksponge, can you review too? Since I have worked on this PR I want another approval before I merge.

Copy link
Member

@mattias-p mattias-p left a comment

Choose a reason for hiding this comment

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

Looks good to me!
I created #1129 as a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V-Patch Versioning: The change gives an update of patch in version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants