Skip to content

Mount udev directory into udev Discovery Handler by default #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kate-goldenring opened this issue May 9, 2022 · 6 comments · Fixed by #487
Closed

Mount udev directory into udev Discovery Handler by default #476

kate-goldenring opened this issue May 9, 2022 · 6 comments · Fixed by #487
Labels
bug Something isn't working

Comments

@kate-goldenring
Copy link
Contributor

Describe the bug
Currently, the udev discovery handler does not properly evaluate certain udev rules. It can access simple udev information such as device names but cannot access devices properties. For example, the following installation will successfully discover USB cameras:

helm upgrade akri akri-helm-charts/akri-dev \
     --set udev.discovery.enabled=true \
     --set udev.configuration.enabled=true \
     --set udev.configuration.name=akri-udev-video \
     --set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video[0-9]*"' \
     --set udev.configuration.brokerPod.image.repository="ghcr.io/project-akri/akri/udev-video-broker" 

However, the following (with property ENV{ID_V4L_CAPABILITIES}==":capture: added) causes no cameras to be discovered (in a scenario where one camera does have the capture property):

helm upgrade akri akri-helm-charts/akri-dev \
     --set udev.discovery.enabled=true \
     --set udev.configuration.enabled=true \
     --set udev.configuration.name=akri-udev-video \
     --set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video[0-9]*"\, ENV{ID_V4L_CAPABILITIES}==":capture:"' \
     --set udev.configuration.brokerPod.image.repository="ghcr.io/project-akri/akri/udev-video-broker"

Solution
Mounting the /run/udev directory in the discovery handler resolves the issue. This can be done via helm by adding --set udev.discovery.host.udev=/run/udev:

 helm upgrade akri akri-helm-charts/akri-dev \
     --set udev.discovery.enabled=true \
     --set udev.configuration.enabled=true \
     --set udev.configuration.name=akri-udev-video \
     --set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video[0-9]*"\, ENV{ID_V4L_CAPABILITIES}==":capture:"' \
     --set udev.configuration.brokerPod.image.repository="ghcr.io/project-akri/akri/udev-video-broker" \
     --set udev.discovery.host.udev=/run/udev

This directory should be mounted by default as it was prior to the v0.6.5 release.

@kate-goldenring
Copy link
Contributor Author

Also, Akri's docs should add a note about this for when using udev and Akri versions v0.6.5 to v0.8.4

@animesh-mishra
Copy link

@kate-goldenring I still have this issue. Below is my akri setup:

 helm repo add akri-helm-charts https://project-akri.github.io/akri/
 helm install akri akri-helm-charts/akri \
    $AKRI_HELM_CRICTL_CONFIGURATION \
     --set udev.discovery.enabled=true \
     --set udev.configuration.enabled=true \
     --set udev.configuration.name=akri-udev-video \
     --set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video[0-9]*"\, ENV{ID_V4L_CAPABILITIES}==":capture:"' \
     --set udev.configuration.brokerPod.image.repository="ghcr.io/project-akri/akri/udev-video-broker" \
     --set udev.discovery.host.udev=/run/udev 

This is the log file:

abmishra@abmishra-ubuntu:~/akri$ kubectl logs akri-udev-discovery-daemonset-75f8c
[2022-06-24T06:23:03Z TRACE akri_discovery_utils::discovery::discovery_handler] run_discovery_handler - registering with Agent with uds endpoint
[2022-06-24T06:23:03Z INFO  akri_discovery_utils::registration_client] register_discovery_handler - entered
[2022-06-24T06:23:03Z INFO  akri_discovery_utils::discovery::server] internal_run_discovery_server - entered
[2022-06-24T06:23:04Z INFO  akri_udev::discovery_handler] discover - called for udev protocol
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_handler] discover - for udev rules ["KERNEL==\"video[0-9]*\", ENV{ID_V4L_CAPABILITIES}==\":capture:\""]
[2022-06-24T06:23:04Z INFO  akri_udev::discovery_impl] parse_udev_rule - enter for udev rule string KERNEL=="video[0-9]*", ENV{ID_V4L_CAPABILITIES}==":capture:"
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] parse_udev_rule - parsing udev_rule "KERNEL==\"video[0-9]*\", ENV{ID_V4L_CAPABILITIES}==\":capture:\""
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] find_devices - enter with udev_filters [UdevFilter { field: Pair { rule: kernel, span: Span { str: "KERNEL", start: 0, end: 6 }, inner: [] }, operation: equality, value: "video[0-9]*" }, UdevFilter { field: Pair { rule: property, span: Span { str: "ENV{ID_V4L_CAPABILITIES}", start: 23, end: 47 }, inner: [Pair { rule: bounded_key, span: Span { str: "{ID_V4L_CAPABILITIES}", start: 26, end: 47 }, inner: [Pair { rule: key, span: Span { str: "ID_V4L_CAPABILITIES", start: 27, end: 46 }, inner: [] }] }] }, operation: equality, value: ":capture:" }]
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] enumerator_match_udev_filters - enter with udev_filters [UdevFilter { field: Pair { rule: kernel, span: Span { str: "KERNEL", start: 0, end: 6 }, inner: [] }, operation: equality, value: "video[0-9]*" }, UdevFilter { field: Pair { rule: property, span: Span { str: "ENV{ID_V4L_CAPABILITIES}", start: 23, end: 47 }, inner: [Pair { rule: bounded_key, span: Span { str: "{ID_V4L_CAPABILITIES}", start: 26, end: 47 }, inner: [Pair { rule: key, span: Span { str: "ID_V4L_CAPABILITIES", start: 27, end: 46 }, inner: [] }] }] }, operation: equality, value: ":capture:" }]
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] enumerator_nomatch_udev_filters - enter with udev_filters []
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] filter_by_remaining_udev_filters - enter with udev_filters []
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] do_parse_and_find - returning discovered devices with devpaths: []
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_handler] discover - mapping and returning devices at devpaths {}

My current work around is to use

--set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video0"'

This is happening on both minikube env and multi node cluster env.

@kate-goldenring
Copy link
Contributor Author

@kate-goldenring I still have this issue. Below is my akri setup:

 helm repo add akri-helm-charts https://project-akri.github.io/akri/
 helm install akri akri-helm-charts/akri \
    $AKRI_HELM_CRICTL_CONFIGURATION \
     --set udev.discovery.enabled=true \
     --set udev.configuration.enabled=true \
     --set udev.configuration.name=akri-udev-video \
     --set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video[0-9]*"\, ENV{ID_V4L_CAPABILITIES}==":capture:"' \
     --set udev.configuration.brokerPod.image.repository="ghcr.io/project-akri/akri/udev-video-broker" \
     --set udev.discovery.host.udev=/run/udev 

This is the log file:

abmishra@abmishra-ubuntu:~/akri$ kubectl logs akri-udev-discovery-daemonset-75f8c
[2022-06-24T06:23:03Z TRACE akri_discovery_utils::discovery::discovery_handler] run_discovery_handler - registering with Agent with uds endpoint
[2022-06-24T06:23:03Z INFO  akri_discovery_utils::registration_client] register_discovery_handler - entered
[2022-06-24T06:23:03Z INFO  akri_discovery_utils::discovery::server] internal_run_discovery_server - entered
[2022-06-24T06:23:04Z INFO  akri_udev::discovery_handler] discover - called for udev protocol
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_handler] discover - for udev rules ["KERNEL==\"video[0-9]*\", ENV{ID_V4L_CAPABILITIES}==\":capture:\""]
[2022-06-24T06:23:04Z INFO  akri_udev::discovery_impl] parse_udev_rule - enter for udev rule string KERNEL=="video[0-9]*", ENV{ID_V4L_CAPABILITIES}==":capture:"
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] parse_udev_rule - parsing udev_rule "KERNEL==\"video[0-9]*\", ENV{ID_V4L_CAPABILITIES}==\":capture:\""
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] find_devices - enter with udev_filters [UdevFilter { field: Pair { rule: kernel, span: Span { str: "KERNEL", start: 0, end: 6 }, inner: [] }, operation: equality, value: "video[0-9]*" }, UdevFilter { field: Pair { rule: property, span: Span { str: "ENV{ID_V4L_CAPABILITIES}", start: 23, end: 47 }, inner: [Pair { rule: bounded_key, span: Span { str: "{ID_V4L_CAPABILITIES}", start: 26, end: 47 }, inner: [Pair { rule: key, span: Span { str: "ID_V4L_CAPABILITIES", start: 27, end: 46 }, inner: [] }] }] }, operation: equality, value: ":capture:" }]
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] enumerator_match_udev_filters - enter with udev_filters [UdevFilter { field: Pair { rule: kernel, span: Span { str: "KERNEL", start: 0, end: 6 }, inner: [] }, operation: equality, value: "video[0-9]*" }, UdevFilter { field: Pair { rule: property, span: Span { str: "ENV{ID_V4L_CAPABILITIES}", start: 23, end: 47 }, inner: [Pair { rule: bounded_key, span: Span { str: "{ID_V4L_CAPABILITIES}", start: 26, end: 47 }, inner: [Pair { rule: key, span: Span { str: "ID_V4L_CAPABILITIES", start: 27, end: 46 }, inner: [] }] }] }, operation: equality, value: ":capture:" }]
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] enumerator_nomatch_udev_filters - enter with udev_filters []
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] filter_by_remaining_udev_filters - enter with udev_filters []
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_impl] do_parse_and_find - returning discovered devices with devpaths: []
[2022-06-24T06:23:04Z TRACE akri_udev::discovery_handler] discover - mapping and returning devices at devpaths {}

My current work around is to use

--set udev.configuration.discoveryDetails.udevRules[0]='KERNEL=="video0"'

This is happening on both minikube env and multi node cluster env.

Have you verified that your camera supports the capture property? I've heard some cameras have output instead. You can inspect your camera with udevadm info --attribute-walk --path=$(udevadm info /dev/video0)

@animesh-mishra
Copy link

@kate-goldenring - I couldn't run the command you gave me but I ran following command. This one has ID_V4L_CAPABILITIES=:capture: . capture property is missing for /dev/video1

abmishra@abmishra-ubuntu:~/akri$ udevadm info /dev/video0
P: /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/video4linux/video0
N: video0
L: 0
S: v4l/by-path/pci-0000:00:14.0-usb-0:2:1.0-video-index0
S: v4l/by-id/usb-046d_Logitech_Webcam_C930e_80C0D3BE-video-index0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/video4linux/video0
E: DEVNAME=/dev/video0
E: MAJOR=81
E: MINOR=0
E: SUBSYSTEM=video4linux
E: USEC_INITIALIZED=419328340
E: ID_V4L_VERSION=2
E: ID_V4L_PRODUCT=Logitech Webcam C930e
E: ID_V4L_CAPABILITIES=:capture:
E: ID_VENDOR=046d
E: ID_VENDOR_ENC=046d
E: ID_VENDOR_ID=046d
E: ID_MODEL=Logitech_Webcam_C930e
E: ID_MODEL_ENC=Logitech\x20Webcam\x20C930e
E: ID_MODEL_ID=0843
E: ID_REVISION=0013
E: ID_SERIAL=046d_Logitech_Webcam_C930e_80C0D3BE
E: ID_SERIAL_SHORT=80C0D3BE
E: ID_TYPE=video
E: ID_BUS=usb
E: ID_USB_INTERFACES=:0e0100:0e0200:010100:010200:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=uvcvideo
E: ID_PATH=pci-0000:00:14.0-usb-0:2:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_0
E: ID_FOR_SEAT=video4linux-pci-0000_00_14_0-usb-0_2_1_0
E: COLORD_DEVICE=1
E: COLORD_KIND=camera
E: DEVLINKS=/dev/v4l/by-path/pci-0000:00:14.0-usb-0:2:1.0-video-index0 /dev/v4l/by-id/usb-046d_Logitech_Webcam_C930e_80C0D3BE-video-index0
E: TAGS=:seat:akri_tags:snap_vlc_vlc:uaccess:snap_firefox_firefox:snap_firefox_geckodriver:
E: CURRENT_TAGS=:seat:snap_vlc_vlc:uaccess:snap_firefox_geckodriver:snap_firefox_firefox:

I also ran following command. I am attaching snippet below. This one doesn't have ID_V4L_CAPABILITIES=:capture:

abmishra@abmishra-ubuntu:~/akri$ udevadm info -a /dev/video0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/video4linux/video0':
    KERNEL=="video0"
    SUBSYSTEM=="video4linux"
    DRIVER==""
    ATTR{dev_debug}=="0"
    ATTR{index}=="0"
    ATTR{name}=="Logitech Webcam C930e"
    ATTR{power/async}=="disabled"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_kids}=="0"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_enabled}=="disabled"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{power/runtime_usage}=="0"

@kate-goldenring
Copy link
Contributor Author

@animesh-mishra so you had the issue resolved by adding /run/udev and now it isnt working again despite it have the :capture: property? This is quite strange. Are you using the same cluster? I'm curious if this is minikube and the nodes don't have access to the host.

@animesh-mishra
Copy link

@kate-goldenring - I forgot to update this issue yesterday. After changing my minikube configuration minikube start --driver=none, this started working too.

I already had --set udev.discovery.host.udev=/run/udev in my helm value override based on your suggestion in the post above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants