isc-projects / kea-anterius

This is an archive but is no longer maintained and we do NOT recommend you use this in production. There are known security vulnerabilities. This was a Google Summer of Code 2018 project to create a GUI dashboard for Kea. It is publicly available open source, but ISC is *not* supporting it. The original author is unable to provide much support either, so it should be considered experimental.
Mozilla Public License 2.0
65 stars 16 forks source link

(node:27) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'leases' of undefined #14

Open hijak opened 6 years ago

hijak commented 6 years ago

Hi

I have most things working for a docker image..

based on https://github.com/sn00p/docker-kea i have bolted anterius in

https://git.d4.re/jack/docker-dhcpd

im using these config files

anterius_config.json

{
  "server_addr": "localhost",
  "server_port": "8181",
  "stat_refresh_interval": "5",
  "admin_user": "keaadmin",
  "admin_password": "keaadmin",
  "current_server": "dhcp4",
  "current_host_index": 0,
  "server_host_list": [
    {
      "hostname": "srv0.exnet.lan",
      "svr_addr": "localhost",
      "svr_port": "8181"
    }
  ],
  "leases_file": "/etc/kea/kea-leases4.csv",
  "log_file": "/var/log/kea-dhcp4.log",
  "config_file": "/etc/kea/kea-dhcp4.conf",
  "shared_network_critical_threshold": "95",
  "shared_network_warning_threshold": "0",
  "leases_per_minute_threshold": "50",
  "email_alert_to": "",
  "sms_alert_to": "",
  "slack_webhook_url": "",
  "slack_alert_channel": ""
}

kea-dhcp4.conf

{
   "Dhcp4":{
      "interfaces-config":{
         "interfaces":[
            "enp2s0f0"
         ]
      },
      "control-socket":{
         "socket-type":"unix",
         "socket-name":"/tmp/kea-dhcp4-ctrl.sock"
      },
      "lease-database":{
         "type":"memfile",
         "lfc-interval":3600
      },
      "expired-leases-processing":{
         "reclaim-timer-wait-time":10,
         "flush-reclaimed-timer-wait-time":25,
         "hold-reclaimed-time":3600,
         "max-reclaim-leases":100,
         "max-reclaim-time":250,
         "unwarned-reclaim-cycles":5
      },
      "renew-timer":900,
      "rebind-timer":1800,
      "valid-lifetime":3600,
      "option-data":[
         {
            "name":"domain-name-servers",
            "data":"10.13.37.20"
         },
         {
            "code":15,
            "data":"exnet.lan"
         },
         {
            "name":"domain-search",
            "data":"home.exnet.lan, stage.exnet.lan, prod.exnet.lan"
         },
         {
            "name":"default-ip-ttl",
            "data":"0xf0"
         }
      ],
      "hooks-libraries":[

      ],
      "subnet4":[
         {
            "subnet":"10.13.37.0/24",
            "pools":[
               {
                  "pool":"10.13.37.100 - 10.13.37.254"
               }
            ],
            "option-data":[
               {
                  "name":"routers",
                  "data":"10.13.37.1"
               }
            ]
         }
      ]
   },
   "Logging":{
      "loggers":[
         {
            "name":"kea-dhcp4",
            "output_options":[
               {
                  "output":"/var/log/kea-dhcp4.log"
               }
            ],
            "severity":"INFO",
            "debuglevel":0
         }
      ]
   }
}

but i get this warning when trying to view leases

[WS] Incoming Subscription 'dhcp_statistics'
(node:27) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'leases' of undefined
    at /srv/anterius/routes/nw_detail_info.js:191:42
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:27) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

not sure whats going wrong here?

Anthrino commented 6 years ago

Thanks for pointing this out @hijak. I presume this error is being caused due to the incorrect usage of Promises in API calls. Not sure how to reproduce the exact condition but similar errors have been raised at different API call points. Will fix the common source code and commit asap.

kamcio2603 commented 6 years ago

Any progress?

youyi1314 commented 5 years ago

If you facing the problem above. please check this : https://github.com/isc-projects/kea-anterius#setup-hooks-library-for-leases-commands