Skip to content

csi: Cache CA certificate pool in CSI TLS verification - #1344

Merged
Michelle Au (msau42) merged 1 commit into
agent-substrate:mainfrom
hajiler:csi-tls-cache
Sep 15, 2026
Merged

Michelle Au (msau42) merged 1 commit into
agent-substrate:mainfrom
hajiler:csi-tls-cache

Conversation

@hajiler

@hajiler hajiler commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1182

Description

In resolveTLSConfig, TLS verification was configured to dynamically read and parse the CA trust bundle on every handshake to support zero-downtime CA rotation. However, reading and parsing PEM certificates from disk on every connection causes unnecessary disk I/O and CPU overhead.

This PR introduces an in-memory caching mechanism for the CA certificate pool:

  • Adds a thread-safe caPoolCache that caches the parsed *x509.CertPool in memory.

  • Uses stat-matching (os.SameFile, modtime, size) to determine when a reload is needed.

  • [X ] Tests pass

  • Appropriate changes to documentation are included in the PR

@hajiler
hajiler force-pushed the csi-tls-cache branch 2 times, most recently from c090911 to 90c28d8 Compare September 8, 2026 22:08
@hajiler hajiler changed the title volume/csi: Cache CA certificate pool in CSI TLS verification csi: Cache CA certificate pool in CSI TLS verification Sep 8, 2026
@hajiler
hajiler marked this pull request as ready for review September 8, 2026 22:16
Comment thread internal/volume/csi/plugin.go Resolved
Comment thread internal/volume/csi/plugin.go Resolved
Comment thread internal/volume/csi/plugin.go Resolved
Comment thread internal/volume/csi/plugin.go Resolved
This change introduces a thread-safe caPoolCache that caches the parsed
cert pool in memory and checks file metadata (stat matching) and certificate
expiration (earliest NotAfter) to avoid redundant disk reads while preserving
automatic CA rotation pickup.
@msau42
Michelle Au (msau42) merged commit 26c3861 into agent-substrate:main Sep 15, 2026
9 checks passed
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.

CSI TLS verification lacks caching, causing performance degradation

4 participants