project-akri / akri

A Kubernetes Resource Interface for the Edge
https://docs.akri.sh/
Apache License 2.0
1.1k stars 142 forks source link

Remove duplicates after discovering ONVIF cameras. #365

Closed kate-goldenring closed 2 years ago

kate-goldenring commented 3 years ago

Describe the bug Akri discovers cameras by doing a multicast for a configurable amount of seconds. Then, it filters all the responses by scopes and then calls GetSystemDateAndTime on the remaining cameras. This call should only be made once per camera; however, it appears that cameras are being discovered multiple times in the multicast and then being pinged for aliveness multiple times: 2021-08-25T13:29:25Z TRACE akri_onvif::discovery_impl::util] simple_onvif_discover - uris after filtering by scopes ["http://10.111.222.251/onvif/device_service", "http://10.234.123.456:80/wsd/mex", "http://10.234.123.456:80/wsd/mex"] The vector of multicast responses should be deduped before proceeding with the next steps.

Flow Installation command:

helm install akri akri-helm-charts/akri \
    --set onvif.discovery.enabled=true \
    --set onvif.configuration.enabled=true

ONVIF Discovery Handler log snippet:

2021-08-25T13:29:25Z TRACE akri_onvif::discovery_impl::util] simple_onvif_discover - uris after filtering by scopes ["http://10.111.222.251/onvif/device_service", "http://10.234.123.456:80/wsd/mex", "http://10.234.123.456:80/wsd/mex"]
[2021-08-25T13:29:25Z TRACE akri_onvif::discovery_utils] post - url:http://10.111.222.251/onvif/device_service, mime_action:action="http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime", msg:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://www.onvif.org/ver10/device/wsdl">
        <soap:Header/>
            <soap:Body>
                <wsdl:GetSystemDateAndTime/>
            </soap:Body>
        </soap:Envelope>
[2021-08-25T13:29:25Z TRACE akri_onvif::discovery_utils] post - url:http://10.234.123.456:80/wsd/mex, mime_action:action="http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime", msg:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://www.onvif.org/ver10/device/wsdl">
        <soap:Header/>
            <soap:Body>
                <wsdl:GetSystemDateAndTime/>
            </soap:Body>
        </soap:Envelope>
[2021-08-25T13:29:25Z TRACE akri_onvif::discovery_utils] post - url:http://10.234.123.456:80/wsd/mex, mime_action:action="http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime", msg:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://www.onvif.org/ver10/device/wsdl">
        <soap:Header/>
            <soap:Body>
                <wsdl:GetSystemDateAndTime/>
            </soap:Body>
        </soap:Envelope>

Proposed fix Remove duplicates from filtered_uris before passing them into get_responsive_uris here

kate-goldenring commented 2 years ago

382 might just be mitigating a symptom of a larger issue of how we handle multicast responses. This issue should be re-opened if other similar bugs occur.