Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-14085

Provisiond Fails to Start when wrong data is successfully POSTed via REST to hardwareInventory endpoint

    XMLWordPrintable

Details

    Description

      Hi team, while working on one of the customer tickets we noticed an issue with OpenNMS when using the "snmp-hardware-provisioning-adapter"

      Context:
      One of the customers using "opennms-plugin-provisioning-snmp-hardware-inventory" on H29.0.5 faced an issue where, post a service restart their OpenNMS was not starting up, upon checking logs and setting up DEBUG on Provisiond found out the below  exceptions in manager.log/provisiond.log.
      I think that during opennms startup when opennms tries to start/init Provisiond it fails because of the wrong values [mentioned below] for OID in the "hwentityattributetype" table [which got there from POST via Rest]

      2022-03-14 07:35:08,548 DEBUG [Main] o.o.n.p.SnmpHardwareInventoryProvisioningAdapter: Loading attribute type String[oid=,name=machineId,class=string] 2022-03-14 07:35:08,548 DEBUG [Main] o.o.n.p.SnmpHardwareInventoryProvisioningAdapter: Loading attribute type String[oid=jygjg,name=reyrty,class=string]
      
      

       

      Issue:
      1. Users when POSTing "hardwareInventory" data for a node via REST API, they are able to post any-value for OID and that POST succeeds but the following service restart fails
      Content Posted

      curl -X POST -H "Content-Type: application/xml" -d@hwent.xml 'http://opennms-test:8980/opennms/rest/nodes/5/hardwareInventory' -u admin -v  
      
      

      Content Posted:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <hwEntity entPhysicalIndex="0" nodeId="5" entityId="197"> 
      <children/>
      <entPhysicalClass>unknown</entPhysicalClass>
      <vendorAttributes>
      <hwEntityAttribute class="string" name="InitLoadParmSec" oid=".1.3.6.1.2.1.25.1.4" value="BOOT_IMAGE=/vmlinuz-3.10.0-1160.31.1.el7.x86_64 root=UUID=9707334d-8bf3-4fb0-a579-6a8bf375ab4e ro console=tty1 console=ttyS0,115"/>
      <hwEntityAttribute class="string" name="TotalMemSec" oid=".1.3.6.1.2.1.25.2.2" value="100"/>
      <hwEntityAttribute class="string" name="reyrty" oid="jygg" value="100"/>
      </vendorAttributes>
      </hwEntity>
      
      

       I feel its because "attriboid"  in "hwentityattributetype" table is a varchar

       

      Below are the values from the table as we can clearly see attriboid = jygg gets successfully added via REST but the following restart fails ..

       

       

      2. Also, while reproducing this found couple of other things as well.
      I have reproduced this on H29.0.5 and collecting below OIDs for Linux Host, added this to "snmp-hardware-inventory-adapter-configuration.xml"

      <hw-extension name="HRSystem-MIB" sysOidMask=".1.3.6.1.4.1.8072.">
      <mibObj oid=".1.3.6.1.2.1.25.1.4" type="string" alias="InitLoadParmSec" />
      <mibObj oid=".1.3.6.1.2.1.25.2.2" type="integer" alias="TotalMemSec" />
      </hw-extension>
      
      

       

      Earlier i dint know if i should have added the scalar instance "0" or not, but added them either ways 

      <hw-extension name="HRSystem-MIB" sysOidMask=".1.3.6.1.4.1.8072.">
      <mibObj oid=".1.3.6.1.2.1.25.1.4.0" type="string" alias="InitialLoadParms" />
      <mibObj oid=".1.3.6.1.2.1.25.2.2.0" type="string" alias="TotalMemory" />
      </hw-extension>
      

       

      Noticed, that dint work and then removed the .0 from the end and kept the same alias

      <hw-extension name="HRSystem-MIB" sysOidMask=".1.3.6.1.4.1.8072.">
      <mibObj oid=".1.3.6.1.2.1.25.1.4" type="string" alias="InitialLoadParms" />
      <mibObj oid=".1.3.6.1.2.1.25.2.2" type="string" alias="TotalMemory" />
      </hw-extension>
      

       

      But when i tried starting OpenNMS this time it errored out saying below and then i realized that there were some database constraints for "hwentityattributetype", which is understandable.

      Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "hwentityattributetype_unique_name_dx" Detail: Key (attribname)=(InitialLoadParms) already exists. 
      
      DB Constraints.. 
      Indexes: 
      "hwentityattributetype_pkey" PRIMARY KEY, btree (id) 
      "hwentityattributetype_unique_name_dx" UNIQUE, btree (attribname) 
      "hwentityattributetype_unique_oid_idx" UNIQUE, btree (attriboid)
      

       

      Question:
      Which got me thinking why dint the older values in this case the below values, get deleted from the DB when the XML file was changed/updated ??
      Wanted to understand the reasoning behind leaving the older/stale values still in DB, say if users end up having many OIDs to collect and then remove from XML file will they still be in DB and since they are in DB will OpenNMS still try to collect those OIDs on every restart/node-rescan.
      I noticed the same when I changed the "type" from "string" to "integer" for "TotalMemory" in the "snmp-hardware-inventory-adapter-configuration.xml file,  it dint update the new type in the database.

      <hw-extension name="HRSystem-MIB" sysOidMask=".1.3.6.1.4.1.8072.">
      <mibObj oid=".1.3.6.1.2.1.25.1.4.0" type="string" alias="InitialLoadParms" />
      <mibObj oid=".1.3.6.1.2.1.25.2.2.0" type="string" alias="TotalMemory" />
      </hw-extension>
      

       

      Attachments

        Issue Links

          Activity

            People

              psuthar Pushkar Suthar
              Sriraag Sridhar Sriraag Sridhar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.