Skip to content

feat(hook): support for hook in nfs-provisioner#93

Merged
kmova merged 15 commits intoopenebs-archive:developfrom
mynktl:hook
Sep 30, 2021
Merged

feat(hook): support for hook in nfs-provisioner#93
kmova merged 15 commits intoopenebs-archive:developfrom
mynktl:hook

Conversation

@mynktl
Copy link
Copy Markdown
Contributor

@mynktl mynktl commented Aug 19, 2021

Why is this PR required? What issue does it fix?:
This PR implements hooks to configure nfs resources on provisioning and delete.

What this PR does?:
This PR adds support to execute hook on NFS resources during provisioning events.
To enable hook execution, nfs-provisioner needs to be configured with env var
OPENEBS_IO_NFS_HOOK_CONFIGMAP set to hook Configmap created in nfs-provisioner namespace.

Hook config data must be set under a field named config.

Sample Hook config is as below:

apiVersion: v1
kind: ConfigMap
metadata:
  name: hook-config
  namespace: openebs
data:
  config: |
    hooks:
      addOrUpdateEntriesOnCreateVolumeEvent:
        backendPV:
          annotations:
            example.io/track: "true"
            test.io/owner: teamA
            test.io/tracking-create-time: $current-time
          finalizers:
          - test.io/tracking-protection
        backendPVC:
          annotations:
            example.io/track: "true"
            test.io/owner: teamA
          finalizers:
          - test.io/tracking-protection
        name: createHook
        nfsDeployment:
          annotations:
            example.io/track: "true"
            test.io/owner: teamA
          finalizers:
          - test.io/tracking-protection
        nfsPV:
          annotations:
            example.io/track: "true"
            test.io/owner: teamA
          finalizers:
          - test.io/tracking-protection
        nfsService:
          annotations:
            example.io/track: "true"
            test.io/owner: teamA
          finalizers:
          - test.io/tracking-protection
      removeEntriesOnDeleteVolumeEvent:
        backendPV:
          finalizers:
          - test.io/tracking-protection
        backendPVC:
          finalizers:
          - test.io/tracking-protection
        name: deleteHook
        nfsDeployment:
          finalizers:
          - test.io/tracking-protection
        nfsPV:
          finalizers:
          - test.io/tracking-protection
        nfsService:
          finalizers:
          - test.io/tracking-protection
    version: 1.0.0

Ref:

Does this PR require any upgrade changes?:
No

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

Checklist:

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 19, 2021

Codecov Report

Merging #93 (f153dcc) into develop (75dc272) will increase coverage by 2.77%.
The diff coverage is 71.06%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #93      +/-   ##
===========================================
+ Coverage    47.11%   49.88%   +2.77%     
===========================================
  Files           29       38       +9     
  Lines         2390     2700     +310     
===========================================
+ Hits          1126     1347     +221     
- Misses        1185     1250      +65     
- Partials        79      103      +24     
Impacted Files Coverage Δ
provisioner/env.go 30.00% <0.00%> (-3.34%) ⬇️
provisioner/helper_kernel_nfs_server.go 71.42% <0.00%> (-8.29%) ⬇️
provisioner/provisioner.go 0.00% <0.00%> (ø)
provisioner/provisioner_kernel_nfs_server.go 0.00% <0.00%> (ø)
pkg/hook/execute.go 60.49% <60.49%> (ø)
pkg/helper/helper.go 100.00% <100.00%> (ø)
pkg/hook/action.go 100.00% <100.00%> (ø)
pkg/hook/deployment_action.go 100.00% <100.00%> (ø)
pkg/hook/helper.go 100.00% <100.00%> (ø)
pkg/hook/parser.go 100.00% <100.00%> (ø)
... and 12 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 75dc272...f153dcc. Read the comment docs.

mayank added 4 commits August 20, 2021 19:28
To enable hook execution, nfs-provisioner needs to be configured with env var
OPENEBS_IO_NFS_HOOK_CONFIGMAP set to hook Configmap created in nfs-provisioner namespace.

Hook config data must be set under field named "config".

Sample Hook config is as below:

apiVersion: v1
kind: ConfigMap
metadata:
name: hook-config
namespace: openebs
data:
config: |
hooks:
- NFSDeployment:
    annotations:
      example.io/track: "true"
      test.io/owner: teamA
    finalizers:
    - test.io/tracking-protection
  NFSService:
    annotations:
      example.io/track: "true"
      test.io/owner: teamA
    finalizers:
    - test.io/tracking-protection
  backendPV:
    annotations:
      example.io/track: "true"
      test.io/owner: teamA
    finalizers:
    - test.io/tracking-protection
  backendPVC:
    annotations:
      example.io/track: "true"
      test.io/owner: teamA
    finalizers:
    - test.io/tracking-protection
  hookAction: Add
  name: createHook
  NFSPV:
    annotations:
      example.io/track: "true"
      test.io/owner: teamA
    finalizers:
    - test.io/tracking-protection
  provisioningEvent: Create
- NFSDeployment:
    finalizers:
    - test.io/tracking-protection
  NFSService:
    finalizers:
    - test.io/tracking-protection
  backendPV:
    finalizers:
    - test.io/tracking-protection
  backendPVC:
    finalizers:
    - test.io/tracking-protection
  hookAction: Remove
  name: deleteHook
  NFSPV:
    finalizers:
    - test.io/tracking-protection
  provisioningEvent: Delete
version: 1.0.0

Signed-off-by: mayank <mayank.patel@mayadata.io>
Signed-off-by: mayank <mayank.patel@mayadata.io>
Signed-off-by: mayank <mayank.patel@mayadata.io>
Signed-off-by: mayank <mayank.patel@mayadata.io>
mayank added 2 commits August 23, 2021 11:54
@mynktl mynktl requested review from kmova and mittachaitu August 23, 2021 06:35
@mynktl mynktl added the enhancement New feature or request label Aug 23, 2021
Signed-off-by: mayank <mayank.patel@mayadata.io>
Copy link
Copy Markdown
Contributor

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

Provided few comments.. moreover it looks good

@mynktl mynktl added this to the 0.7.0 milestone Aug 24, 2021
mayank added 2 commits August 24, 2021 20:16
Signed-off-by: mayank <mayank.patel@mayadata.io>
…into hook

Signed-off-by: mayank <mayank.patel@mayadata.io>
@mynktl mynktl requested a review from mittachaitu August 24, 2021 14:49
Copy link
Copy Markdown
Contributor

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

changes are good

Signed-off-by: mayank <mayank.patel@mayadata.io>
…into hook

Signed-off-by: mayank <mayank.patel@mayadata.io>
@mynktl mynktl requested a review from mittachaitu September 7, 2021 05:28
Copy link
Copy Markdown
Contributor

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

can we update the example in the description (provisioingingEvent --> eventType, hookAction --> actionType and corresponding values)?

Copy link
Copy Markdown
Contributor

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

changes look good but there is a small comment about naming conventions

Signed-off-by: mayank <mayank.patel@mayadata.io>
Copy link
Copy Markdown
Contributor

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

changes are good

Copy link
Copy Markdown
Collaborator

@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.

Looks good for initial implementation and to follow up with integration tests that cover scenarios like handling provisioning cases that don't go till the point of successfully creating and adding hooks.

@kmova kmova merged commit 79e423a into openebs-archive:develop Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants