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(controller,filter): add blockdevice tag label while claiming #400

Merged
merged 5 commits into from
Apr 7, 2020

Conversation

akhilerm
Copy link
Contributor

@akhilerm akhilerm commented Apr 6, 2020

  • add support for new label openebs.io/block-device-tag
  • add a new filter while claiming block devices. If openebs.io/block-device-tag is present on a BlockDevice, only BDCs having a matching selector will be able to claim that block device
  • fix a bug where selector is accidentally updated on BDC while updating other fields.

Sample BDC Yaml which makes use of openebs.io/block-device-tag label

apiVersion: openebs.io/v1alpha1
kind: BlockDeviceClaim
metadata:
  finalizers:
  - openebs.io/bdc-protection
  name: bdc-ss35
  namespace: default
spec:
  blockDeviceName: blockdevice-91d422d8517f935431daae722f8fdfa0
  resources:
    requests:
      storage: 10M
  selector:
    matchLabels:
      openebs.io/block-device-tag: X
status:
  phase: Bound

BlockDevice that was claimed by the above BDC

kind: BlockDevice
metadata:
  labels:
    kubernetes.io/hostname: gke-akhil-ndm-pool-1-4349c998-vt36
    ndm.io/blockdevice-type: blockdevice
    ndm.io/managed: "true"
    openebs.io/block-device-tag: X
  name: blockdevice-91d422d8517f935431daae722f8fdfa0
  namespace: default
spec:
  capacity:
    storage: 53687091200
  claimRef:
    apiVersion: openebs.io/v1alpha1
    kind: BlockDeviceClaim
    name: bdc-ss35
    namespace: default
    resourceVersion: "72629912"
    uid: f6c7af75-783e-11ea-9bcf-42010a80015a
  details:
    compliance: SPC-4
    deviceType: disk
    driveType: HDD
    firmwareRevision: '1   '
    hardwareSectorSize: 512
    logicalBlockSize: 512
    model: PersistentDisk
    physicalBlockSize: 4096
    serial: akhil-disk-3
    vendor: Google
  devlinks:
  - kind: by-id
    links:
    - /dev/disk/by-id/scsi-0Google_PersistentDisk_akhil-disk-3
    - /dev/disk/by-id/google-akhil-disk-3
  - kind: by-path
    links:
    - /dev/disk/by-path/pci-0000:00:03.0-scsi-0:0:2:0
  nodeAttributes:
    nodeName: gke-akhil-ndm-pool-1-4349c998-vt36
  path: /dev/sdc
status:
  claimState: Claimed
  state: Active

- refactored the label constants. moved from filter to client
- added openebs.io/block-device-tag label

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
BDC controller used a pointer reference of the selector. This
has been changed to copy the selector and use it. This is done so that
an update on the BDC object does not cause the selector to get
updated with a different value other than the one which was applied by
user.

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
@akhilerm akhilerm added the pr/hold-review Needs rework. label Apr 6, 2020
@akhilerm akhilerm added this to In progress in NDM Apr 6, 2020
@akhilerm akhilerm added this to RC1 - Due: Apr 5 2020 in 1.9 Release Tracker - Due Apr 15th. Apr 6, 2020
@akhilerm akhilerm removed the pr/hold-review Needs rework. label Apr 6, 2020
@akhilerm akhilerm added the pr/hold-merge The PR should not be merged now label Apr 6, 2020
kmova
kmova previously approved these changes Apr 6, 2020
Copy link
Contributor

@kmova kmova left a comment

Choose a reason for hiding this comment

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

minor comment on the naming. the changes look good!

@codecov-io
Copy link

Codecov Report

Merging #400 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #400   +/-   ##
=======================================
  Coverage   49.28%   49.28%           
=======================================
  Files          55       55           
  Lines        2439     2439           
=======================================
  Hits         1202     1202           
  Misses       1141     1141           
  Partials       96       96           
Impacted Files Coverage Δ
db/kubernetes/client.go 10.52% <ø> (ø)
db/kubernetes/filter.go 100.00% <ø> (ø)
...er/blockdeviceclaim/blockdeviceclaim_controller.go 40.96% <100.00%> (ø)

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 f954106...31c650f. Read the comment docs.

kmova
kmova previously approved these changes Apr 6, 2020
add a new filter to to filter out block devices
based on the block-device-tag label. The filter has also been
added to the list of filters which are applied while auto selecting
a block device.

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
@akhilerm akhilerm removed the pr/hold-merge The PR should not be merged now label Apr 6, 2020
@akhilerm akhilerm moved this from In progress to In Review in NDM Apr 6, 2020
@kmova kmova merged commit f1da18a into openebs-archive:master Apr 7, 2020
NDM automation moved this from In Review to Done Apr 7, 2020
1.9 Release Tracker - Due Apr 15th. automation moved this from RC1 - Due: Apr 5 2020 to Done Apr 7, 2020
akhilerm added a commit to akhilerm/node-disk-manager that referenced this pull request Apr 7, 2020
…enebs-archive#400)

- add support for new label `openebs.io/block-device-tag`

- add a new filter while claiming block devices. If `openebs.io/block-device-tag` is present on a BlockDevice, only BDCs having a matching selector will be able to claim that block device

- Fix a bug where selector is accidentally updated on BDC while updating other fields.
  BDC controller used a pointer reference of the selector. This
  has been changed to copy the selector and use it. This is done so that
  an update on the BDC object does not cause the selector to get
  updated with a different value other than the one which was applied by
  user.

- Add unit tests for new filter

Sample BDC Yaml which makes use of `openebs.io/block-device-tag` label

```yaml
apiVersion: openebs.io/v1alpha1
kind: BlockDeviceClaim
metadata:
  finalizers:
  - openebs.io/bdc-protection
  name: bdc-ss35
  namespace: default
spec:
  blockDeviceName: blockdevice-91d422d8517f935431daae722f8fdfa0
  resources:
    requests:
      storage: 10M
  selector:
    matchLabels:
      openebs.io/block-device-tag: X
status:
  phase: Bound
```

BlockDevice that was claimed by the above BDC
```yaml
kind: BlockDevice
metadata:
  labels:
    kubernetes.io/hostname: gke-akhil-ndm-pool-1-4349c998-vt36
    ndm.io/blockdevice-type: blockdevice
    ndm.io/managed: "true"
    openebs.io/block-device-tag: X
  name: blockdevice-91d422d8517f935431daae722f8fdfa0
  namespace: default
spec:
  capacity:
    storage: 53687091200
  claimRef:
    apiVersion: openebs.io/v1alpha1
    kind: BlockDeviceClaim
    name: bdc-ss35
    namespace: default
    resourceVersion: "72629912"
    uid: f6c7af75-783e-11ea-9bcf-42010a80015a
  details:
    compliance: SPC-4
    deviceType: disk
    driveType: HDD
    firmwareRevision: '1   '
    hardwareSectorSize: 512
    logicalBlockSize: 512
    model: PersistentDisk
    physicalBlockSize: 4096
    serial: akhil-disk-3
    vendor: Google
  devlinks:
  - kind: by-id
    links:
    - /dev/disk/by-id/scsi-0Google_PersistentDisk_akhil-disk-3
    - /dev/disk/by-id/google-akhil-disk-3
  - kind: by-path
    links:
    - /dev/disk/by-path/pci-0000:00:03.0-scsi-0:0:2:0
  nodeAttributes:
    nodeName: gke-akhil-ndm-pool-1-4349c998-vt36
  path: /dev/sdc
status:
  claimState: Claimed
  state: Active
```

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
kmova pushed a commit that referenced this pull request Apr 7, 2020
- add support for new label `openebs.io/block-device-tag`

- add a new filter while claiming block devices. If `openebs.io/block-device-tag` is present on a BlockDevice, only BDCs having a matching selector will be able to claim that block device

- Fix a bug where selector is accidentally updated on BDC while updating other fields.
  BDC controller used a pointer reference of the selector. This
  has been changed to copy the selector and use it. This is done so that
  an update on the BDC object does not cause the selector to get
  updated with a different value other than the one which was applied by
  user.

- Add unit tests for new filter

Sample BDC Yaml which makes use of `openebs.io/block-device-tag` label

```yaml
apiVersion: openebs.io/v1alpha1
kind: BlockDeviceClaim
metadata:
  finalizers:
  - openebs.io/bdc-protection
  name: bdc-ss35
  namespace: default
spec:
  blockDeviceName: blockdevice-91d422d8517f935431daae722f8fdfa0
  resources:
    requests:
      storage: 10M
  selector:
    matchLabels:
      openebs.io/block-device-tag: X
status:
  phase: Bound
```

BlockDevice that was claimed by the above BDC
```yaml
kind: BlockDevice
metadata:
  labels:
    kubernetes.io/hostname: gke-akhil-ndm-pool-1-4349c998-vt36
    ndm.io/blockdevice-type: blockdevice
    ndm.io/managed: "true"
    openebs.io/block-device-tag: X
  name: blockdevice-91d422d8517f935431daae722f8fdfa0
  namespace: default
spec:
  capacity:
    storage: 53687091200
  claimRef:
    apiVersion: openebs.io/v1alpha1
    kind: BlockDeviceClaim
    name: bdc-ss35
    namespace: default
    resourceVersion: "72629912"
    uid: f6c7af75-783e-11ea-9bcf-42010a80015a
  details:
    compliance: SPC-4
    deviceType: disk
    driveType: HDD
    firmwareRevision: '1   '
    hardwareSectorSize: 512
    logicalBlockSize: 512
    model: PersistentDisk
    physicalBlockSize: 4096
    serial: akhil-disk-3
    vendor: Google
  devlinks:
  - kind: by-id
    links:
    - /dev/disk/by-id/scsi-0Google_PersistentDisk_akhil-disk-3
    - /dev/disk/by-id/google-akhil-disk-3
  - kind: by-path
    links:
    - /dev/disk/by-path/pci-0000:00:03.0-scsi-0:0:2:0
  nodeAttributes:
    nodeName: gke-akhil-ndm-pool-1-4349c998-vt36
  path: /dev/sdc
status:
  claimState: Claimed
  state: Active
```

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
@akhilerm akhilerm deleted the bdc-strict-label-checking branch April 8, 2020 19:32
@Abhinandan-Purkait Abhinandan-Purkait removed this from Done in NDM Apr 29, 2024
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.

None yet

4 participants