Skip to content
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

feat(path-filter): Filter blockdevice using custom udev rules #670

Merged
merged 6 commits into from
Jun 30, 2022

Conversation

Ab-hishek
Copy link

@Ab-hishek Ab-hishek commented Apr 15, 2022

Signed-off-by: Abhishek Agarwal [email protected]

Why is this PR required? What issue does it fix?:
This PR fixes the issue - openebs/openebs#3491

What this PR does?:
This PR adds extra dev links(apart from by-id and by-path) info which we get from the udev` probe. This are useful to filter out bds when a disk is configured with some custom udev rules and uses those rules inside the path filter config of ndm.

Does this PR require any upgrade changes?:
No

If the changes in this PR are manually verified, list down the scenarios covered::

  1. Added custom udev rules for a disk: KERNEL=="sdb1",SYMLINK+="openebs_storage_02"
  2. Relead the udev db using the command: udevadm control --reload
  3. The new symlink is available in the udev output now:
P: /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/host3/target3:0:0/3:0:0:0/block/sdb/sdb1
N: sdb1
L: 0
S: disk/by-uuid/E48D-9C94
S: disk/by-path/pci-0000:00:14.0-usb-0:4:1.0-scsi-0:0:0:0-part1
S: disk/by-label/ABHISHEK
S: disk/by-id/usb-JetFlash_Transcend_8GB_OWXSZQ7L-0:0-part1
S: openebs_storage_02
S: disk/by-partuuid/02a28704-01
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/host3/target3:0:0/3:0:0:0/block/sdb/sdb1
E: DEVNAME=/dev/sdb1
E: DEVTYPE=partition
E: DEVLINKS=/dev/disk/by-uuid/E48D-9C94 /dev/disk/by-path/pci-0000:00:14.0-usb-0:4:1.0-scsi-0:0:0:0-part1 /dev/disk/by-label/ABHISHEK /dev/disk/by-id/usb-JetFlash_Transcend_8GB_OWXSZQ7L-0:0-part1 /dev/openebs_storage_02 /dev/disk/by-partuuid/02a28704-01
E: TAGS=:systemd:
  1. Install ndm operator
  2. Update the ndm config:
    a. Exclude the disk with symlink: /dev/openebs_storage_02 using exclude path filter:
    - key: path-filter
      name: path filter
      state: true
      include: ""
      exclude: "/dev/loop,/dev/openebs_storage_02,/dev/fd0,/dev/sr0,/dev/ram,/dev/md,/dev/dm-,/dev/rbd,/dev/zd"
    OUTPUT: Listing bds with kubectl get bd -n openebs doesn't list the above disk.
    b. Include the disk with symlink: /dev/openebs_storage_02 using include path filter:
    - key: path-filter
      name: path filter
      state: true
      include: "/dev/openebs_storage_02"
      exclude: "/dev/loop,/dev/fd0,/dev/sr0,/dev/ram,/dev/md,/dev/dm-,/dev/rbd,/dev/zd"
    OUTPUT: Listing bds with kubectl get bd -n openebs does list the above disk.
  3. The bds are listed is it should have been:
    abhishek@abhishek-Mayadata:~$ kubectl get bd -n openebs
    NAME                                           NODENAME            SIZE         CLAIMSTATE   STATUS   AGE
    blockdevice-0db0a0b21ddbc52266b551d2d1c53791   abhishek-mayadata   7812939776   Unclaimed    Active   4s
    blockdevice-14065e0e32469367655092a3333cfe99   abhishek-mayadata   1024         Unclaimed    Active   102s
    blockdevice-2345c8576f192616c18b8f9f19f2497e   abhishek-mayadata   536870912    Unclaimed    Active   102s
    blockdevice-0db0a0b21ddbc52266b551d2d1c53791 abhishek-mayadata 7812939776 Unclaimed Active 4s is the one having the custom udev rule

Any additional information for your reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

Signed-off-by: Abhishek Agarwal <[email protected]>
@Ab-hishek Ab-hishek self-assigned this Apr 15, 2022
@Ab-hishek Ab-hishek requested a review from akhilerm April 15, 2022 07:48
Abhishek Agarwal added 4 commits April 15, 2022 14:00
@codecov-commenter
Copy link

codecov-commenter commented Apr 15, 2022

Codecov Report

Merging #670 (305ef99) into develop (9f40337) will increase coverage by 0.50%.
The diff coverage is 71.42%.

@@             Coverage Diff             @@
##           develop     #670      +/-   ##
===========================================
+ Coverage    44.83%   45.33%   +0.50%     
===========================================
  Files           79       79              
  Lines         3970     3990      +20     
===========================================
+ Hits          1780     1809      +29     
+ Misses        2023     2012      -11     
- Partials       167      169       +2     
Impacted Files Coverage Δ
cmd/ndm_daemonset/filter/pathfilter.go 69.38% <50.00%> (-7.54%) ⬇️
cmd/ndm_daemonset/probe/udevprobe.go 50.00% <100.00%> (+3.35%) ⬆️
pkg/udev/common.go 88.05% <100.00%> (+0.75%) ⬆️
pkg/udev/mockdata.go 67.12% <100.00%> (+0.45%) ⬆️
pkg/udev/udev.go 90.00% <0.00%> (ø)
pkg/udev/device.go 100.00% <0.00%> (ø)
pkg/udev/monitor.go 80.00% <0.00%> (ø)
pkg/udev/enumerate.go 58.33% <0.00%> (ø)
pkg/udev/listentry.go 0.00% <0.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2936ea7...305ef99. Read the comment docs.

@Ab-hishek Ab-hishek requested a review from pawanpraka1 April 15, 2022 10:11
@pawanpraka1
Copy link
Contributor

@akhilerm could you review this PR?

Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ab-hishek I have one comment on the fetching from udev. Everything else looks good.

pkg/udev/common.go Outdated Show resolved Hide resolved
Signed-off-by: Abhishek Agarwal <[email protected]>
@Ab-hishek Ab-hishek requested a review from akhilerm June 29, 2022 12:58
Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Changes looks good. @Ab-hishek please add the necessary tests also with the new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants