Skip to content

Fix duplicate SNMP connection handler entries in packaged config.ldif#659

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/snmp-duplicate
Open

Fix duplicate SNMP connection handler entries in packaged config.ldif#659
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/snmp-duplicate

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

Fix duplicate cn=SNMP Connection Handler entries that accumulate in the packaged server config.ldif, which makes setup fail with Entry Already Exists after repeated (incremental) builds.

Root cause

The snmp profile assembles the template config.ldif in two maven-antrun-plugin steps in opendj-server-legacy/pom.xml:

  • copy-config-ldif (generate-resources) copies the pristine resource/config/config.ldif to target/template/config/config.ldif.
  • generate-config-ldif (prepare-package) appends config.snmp.ldif with <concat ... append="true">.

The copy used Ant's default overwrite="false". On an incremental build (without clean) the already-generated target file is newer than the source, so the copy is skipped and the file is not reset — while the concat appends the SNMP fragment again on every build, without checking whether it is already present. After N lifecycle runs that reach prepare-package, the file ends up with N copies of:

dn: cn=SNMP Connection Handler,cn=Connection Handlers,cn=config

and setup aborts:

Entry Already Exists: Attempted to add the entry
'cn=SNMP Connection Handler,cn=Connection Handlers,cn=config' multiple times
Error Configuring Directory Server.

Fix

Force the base config.ldif copy to overwrite, so the SNMP fragment is always appended to a freshly copied file. Generation becomes idempotent regardless of incremental builds.

-                <copy todir="${project.build.directory}/template/config" file="${basedir}/resource/config/config.ldif" />
+                <copy todir="${project.build.directory}/template/config" file="${basedir}/resource/config/config.ldif" overwrite="true" />

Testing

  • Before: repeated mvn -pl opendj-server-legacy package (no clean) → 5× SNMP entry in target/package/opendj/template/config/config.ldif; setup fails with Entry Already Exists.
  • After: clean rebuild yields exactly 1 SNMP entry; repeated incremental package runs keep it at 1; setup ... --sampleData 5000 completes and the server starts normally.

Affected files

  • opendj-server-legacy/pom.xml (1 line)

The `snmp` profile assembles the server template config.ldif in two antrun
steps: `copy-config-ldif` copies the pristine resource/config/config.ldif into
target/template/config, and `generate-config-ldif` appends config.snmp.ldif to
it with `concat append="true"`.

The copy used Ant's default `overwrite="false"`, so on an incremental build
(without `clean`) the already-populated target file was newer than the source
and was not refreshed, while the concat appended the SNMP fragment again on
every build. Repeated builds therefore accumulated several
`cn=SNMP Connection Handler,cn=Connection Handlers,cn=config` entries, and
`setup` then failed with "Entry Already Exists ... multiple times".

Add `overwrite="true"` to the config.ldif copy so the SNMP fragment is always
appended to a freshly copied base file, making config.ldif generation
idempotent regardless of incremental builds.
@vharseko vharseko requested a review from maximthomas June 25, 2026 17:50
@vharseko vharseko added the build label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants