Skip to content

Conversation

@deepakkinni
Copy link
Collaborator

@deepakkinni deepakkinni commented Jan 6, 2026

What this PR does / why we need it:
This PR optimizes the Kubernetes client creation in the WCP CSI controller by initializing it once during controller startup instead of creating a new client on every snapshot operation. This reduces performance overhead, memory allocations, and API server load.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Testing done:
Precheckins(WCP) PASS: https://jenkins-vcf-csifvt.devops.broadcom.net/job/wcp-instapp-e2e-pre-checkin/846/
Precheckins(VKS) PASS: https://jenkins-vcf-csifvt.devops.broadcom.net/job/vks-instapp-e2e-pre-checkin/786/

All existing unit tests pass (TestGetSnapshotLimitForNamespace and TestGetPodVMUUID)

No linter errors

Verified that the k8s client is initialized once during controller Init() and reused across all getSnapshotLimitForNamespace calls


Running Snapshot Limit Enforcement Tests
========================================

Category: Basic Limit Enforcement
-----------------------------------
  ✓ Test #1: Create Within Limit (5/10) - PASSED (12s)
  ✓ Test #2: Exceed Limit (11/10) - PASSED (8s)
  ✓ Test #7: Absolute Max Enforcement (33/32) - PASSED (10s)
  ✓ Test #14: Zero Limit Config - PASSED (2s)

Category: ConfigMap Configuration
---------------------------------
  ✓ Test #3: No ConfigMap Present - PASSED (5s)
  ✓ Test #4: Invalid ConfigMap Value - PASSED (3s)
  ✓ Test #5: Per-Class Limits - PASSED (15s)
  ✓ Test #6: Missing Snapshot Class Key - PASSED (8s)
  ✓ Test #10: Empty ConfigMap - PASSED (2s)

Category: Snapshot Counting
---------------------------
  ✓ Test #8: Cross-PVC Counting (2 PVCs) - PASSED (18s)
  ✓ Test #9: Deleted Snapshots Don't Count - PASSED (20s)
  ✓ Test #11: Multiple Classes (2 classes) - PASSED (22s)
  ✓ Test #12: Failed Snapshots Count - PASSED (12s)
  ✓ Test #13: Pending Snapshots Count - PASSED (10s)

Category: Cleanup & Resource Management
---------------------------------------
  ✓ Test (implicit): Resource cleanup - PASSED
  ✓ Test (implicit): PVC deletion order - PASSED
  ✓ Test (implicit): Namespace isolation - PASSED

========================================
Test Results: 14/14 PASSED

Test Link: https://gist.github.com/deepakkinni/faa1c69b3f21ffeb3843011b60fad7ee

Special notes for your reviewer:

Release note:

Optimize Kubernetes client creation in WCP CSI controller by initializing once at startup instead of per-snapshot operation

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 6, 2026
@deepakkinni deepakkinni force-pushed the topic/dk016388/snap_limit_csi_v2 branch from 36bcbdd to c110ae6 Compare January 6, 2026 07:44
Signed-off-by: Deepak Kinni <deepak.kinni@broadcom.com>
@deepakkinni deepakkinni force-pushed the topic/dk016388/snap_limit_csi_v2 branch from c110ae6 to c1e36ea Compare January 6, 2026 07:50
@deepakkinni
Copy link
Collaborator Author

FAILED --- Jenkins Build #842

@deepakkinni
Copy link
Collaborator Author

Triggering CSI-TKG Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #784

@deepakkinni
Copy link
Collaborator Author

Triggering CSI-TKG Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #785

@deepakkinni
Copy link
Collaborator Author

Triggering CSI-TKG Pre-checkin Pipeline for this PR... Job takes approximately an hour to complete
Jenkins Build #786

@deepakkinni
Copy link
Collaborator Author

SUCCESS --- Jenkins Build #846

@xing-yang
Copy link
Contributor

Can you add your pre-check pipeline link to the PR description?

@xing-yang
Copy link
Contributor

/approve

Copy link
Member

@divyenpatel divyenpatel left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 9, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepakkinni, divyenpatel, xing-yang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [deepakkinni,divyenpatel,xing-yang]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit f91c090 into kubernetes-sigs:master Jan 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants