[OpenNMS/opennms] 2fb49e: NMS-19980: translate iplike match expressions to n...
Marshall Massengill via opennms-cvs <[email protected]>
| Newsgroups | gmane.network.opennms.cvs |
|---|---|
| Message-ID | <OpenNMS/opennms/push/refs/heads/mm/NMS-19980-smoke/[email protected]> |
Branch: refs/heads/mm/NMS-19980-smoke
Home: https://github.com/OpenNMS/opennms
Commit: 2fb49e6aa722d7bd0494b295a64c648610b3d851
https://github.com/OpenNMS/opennms/commit/2fb49e6aa722d7bd0494b295a64c648610b3d851
Author: Marshall Massengill <[email protected]>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
A core/lib/src/main/java/org/opennms/core/utils/IplikeSqlTranslator.java
A core/lib/src/test/java/org/opennms/core/utils/IplikeSqlTranslatorTest.java
A core/lib/src/test/resources/org/opennms/core/utils/iplike-tests.dat
Log Message:
-----------
NMS-19980: translate iplike match expressions to native-inet SQL predicates
IplikeSqlTranslator renders an iplike pattern's union of contiguous
address ranges as opennms_safe_inet(col) range comparisons that
PostgreSQL can answer through an expression index, instead of calling
the iplike() stored procedure per row. Untranslatable patterns (IPv6
zone ids, >1024-range expansions, malformed input) return null and
callers keep emitting iplike(col, ?) exactly as before.
Semantics, verified against the iplike reference corpus (tests.dat,
also covered DB-side by IPLikeCoverageIT):
* predicates carry an opennms_safe_inet(col) IS NOT NULL conjunct so
values the cast cannot parse evaluate to false, not NULL — negated
filters keep the same rows NOT iplike() keeps, and the planner folds
the conjunct into the index condition
* inet literals are rendered by hand: InetAddress.getByAddress()
collapses IPv4-mapped IPv6 (::ffff:0:0/96) to Inet4Address, which
would emit a family-4 literal that never compares equal to the
family-6 value opennms_safe_inet() yields
* both match-all forms translate to col IS NOT NULL, matching the
shipped PL/pgSQL fast path
* the system property org.opennms.iplike.native=false disables
translation globally
Commit: 98b8c480c9f1cdf8da8edd8419a1e17dab071611
https://github.com/OpenNMS/opennms/commit/98b8c480c9f1cdf8da8edd8419a1e17dab071611
Author: Marshall Massengill <[email protected]>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
M core/schema/src/main/java/org/opennms/core/schema/Migrator.java
M core/schema/src/main/liquibase/36.0.3/changelog.xml
M core/schema/src/main/resources/org/opennms/core/schema/iplike.sql
M core/test-api/db/src/test/java/org/opennms/core/test/db/IPLikeCoverageIT.java
Log Message:
-----------
NMS-19980: opennms_safe_inet cast, expression indexes, faster PL/pgSQL iplike
Schema-side support for the native-inet translation:
* opennms_safe_inet(text): garbage-tolerant IMMUTABLE cast to inet.
Strict dotted-quad or 8-group IPv6 only; the zone id is stripped for
IPv6 values only (zone ids are IPv6-only, and iplike() rejects IPv4
values carrying one); everything else casts to NULL.
* expression indexes over the cast: plain on ipinterface, partial
(WHERE ipaddr IS NOT NULL) on events, keeping per-insert maintenance
low on the high-churn table. The existing events_ipaddr_idx stays:
the v1 exact-interface filter, ORDER BY ipaddr, and the REST v2
ipinterface join still compare the text column. Indexes are built
CONCURRENTLY (runInTransaction=false); the leading DROP INDEX makes
an interrupted build converge on re-run.
* PL/pgSQL iplike revision 2: profiling-driven rework with semantics
unchanged against the reference corpus — value classification via
family(::inet) instead of regexes, ::integer casts instead of
to_number(), strpos() instead of regex operators, and parsing wrapped
in an EXCEPTION block for garbage tolerance with the null check and
match-all fast paths outside it.
* Migrator: a working but older PL/pgSQL revision is replaced in place
(the revision tag lives in the function comment); a working
non-PL/pgSQL implementation — the optional compiled extension — is
never touched. The dead installCIpLike("foo") path is removed.
IPLikeCoverageIT now checks the translated predicates against iplike()
for the whole corpus in both polarities, covers unrepresentable values
(garbage, compressed IPv6, zoned IPv4, whitespace), and exercises both
Migrator upgrade paths.
Commit: ab6e06a27910a26068bb617fa91500e0c3d9b6c2
https://github.com/OpenNMS/opennms/commit/ab6e06a27910a26068bb617fa91500e0c3d9b6c2
Author: Marshall Massengill <[email protected]>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
M opennms-config/src/main/java/org/opennms/netmgt/filter/JdbcFilterDao.java
A opennms-config/src/test/java/org/opennms/netmgt/filter/JdbcFilterDaoNativeInetTest.java
M opennms-config/src/test/java/org/opennms/netmgt/filter/JdbcFilterDaoParenthesizationTest.java
M opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/HibernateCriteriaConverter.java
M opennms-dao/src/test/java/org/opennms/netmgt/dao/hibernate/HibernateCriteriaConverterIT.java
M opennms-dao/src/test/java/org/opennms/netmgt/dao/support/JdbcFilterDaoIT.java
M opennms-model/src/main/java/org/opennms/netmgt/model/OnmsRestrictions.java
A opennms-model/src/test/java/org/opennms/netmgt/model/OnmsRestrictionsTest.java
M opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/NodeRestService.java
M opennms-webapp/src/main/java/org/opennms/web/filter/IPLikeFilter.java
M opennms-webapp/src/main/java/org/opennms/web/filter/NegativeIPLikeFilter.java
M opennms-webapp/src/test/java/org/opennms/web/event/filter/WebEventRepositoryFilterIT.java
Log Message:
-----------
NMS-19980: emit native-inet predicates from the IPLIKE call sites
Where the match expression translates, the SQL emitters inline the
native predicate instead of calling iplike():
* JdbcFilterDao (filter rules): the predicate is stashed as an
extracted string so the keyword/column passes leave its contents
untouched, and the column reference is schema-qualified up front.
Also fixes the pre-existing quoted-rule fallback: the quoted-argument
check tested regex.group(), which always starts with the column name,
so quoted rules — zone-id patterns, exactly the documented iplike()
fallback — merged back double-quoted as IPLIKE(col, ''fe80...''),
a syntax error at execution time.
* HibernateCriteriaConverter (core criteria iplike restriction)
* OnmsRestrictions.ipLike (Hibernate criterion helper)
* IPLikeFilter / NegativeIPLikeFilter (event/alarm/outage/notification
web filters); the raw-JDBC getSQLTemplate() path stays on iplike()
because that template contract binds exactly one JDBC parameter
* NodeRestService v2 iplike node search, EQUALS and NOT_EQUALS
Tests: JdbcFilterDaoNativeInetTest (translation, quoting, negation,
match-all, escape hatch), OnmsRestrictionsTest,
HibernateCriteriaConverterIT (both polarities; the populator's zoned
fe80:...%5 interface through the native path and through the zone-rule
fallback), updated JdbcFilterDaoIT/JdbcFilterDaoParenthesizationTest
match-all expectations, and a WebEventRepositoryFilterIT case proving
negated filters keep rows whose ipaddr no engine can parse.
Commit: fc84f5cc80b31c0d38e93222037127d5189c68c7
https://github.com/OpenNMS/opennms/commit/fc84f5cc80b31c0d38e93222037127d5189c68c7
Author: Marshall Massengill <[email protected]>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
M docs/modules/reference/pages/configuration/filters/filters.adoc
M docs/modules/releasenotes/pages/whatsnew.adoc
Log Message:
-----------
NMS-19980: document native-inet IPLIKE filtering
Filters reference: IPLIKE now translates to indexed native inet
comparisons where possible, plus a hedged tuning note for broad
patterns over very large events tables (extended statistics on the
opennms_safe_inet expression and an SSD-appropriate random_page_cost;
both standard PostgreSQL mechanisms, measure before and after).
Release notes: feature summary and upgrade behavior. Installs that use
the optional compiled iplike extension keep it, but translated
expressions follow the bundled PL/pgSQL semantics — visibly, the
match-all patterns now match every non-null address regardless of
family, as they always have under PL/pgSQL (the C implementation has
no match-all fast path).
Compare: https://github.com/OpenNMS/opennms/compare/d0c4ef1b6ed3...fc84f5cc80b3
To unsubscribe from these emails, change your notification settings at https://github.com/OpenNMS/opennms/settings/notifications
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/wiki/index.php?page=MailingListFaq
opennms-cvs mailing list
To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-cvs