Skip to content

[Misc] subscription: maxSubscriptions amended - #572

Open
Pavan-SAP wants to merge 1 commit into
mainfrom
maxSubs
Open

Pavan-SAP wants to merge 1 commit into
mainfrom
maxSubs

Conversation

@Pavan-SAP

Copy link
Copy Markdown
Member

Use mutex locks to ensure maxSubscriptions is properly managed: appLocks sync.Map to SubscriptionHandler and a lockApp(appIdHash) helper that lazily creates and acquires a per-application mutex (different apps never block each other).

Note:
Cross-replica caveat & follow-up (not implemented here). The mutex coordinates requests within one pod only. subscriptionServer.replicas is configurable (default 1); with >1 replica, pods can still interleave List/Create and overshoot the limit. Strict cross-replica enforcement would use a per-app distributed lock via a coordination.k8s.io/v1 Lease (capop-sublimit-): acquire by Get→Create-if-absent / take-if-expired-or-ours via Update with resourceVersion (409-retry), holderIdentity from a POD_NAME env var, leaseDurationSeconds tuned above a single Create but short enough to bound stall on holder crash, release by Update/Delete. This needs leases RBAC added to the subscription-server Role in the cap-operator-lifecycle Helm chart (cross-repo). client-go leaderelection is a poor fit (long-lived leader election, not short per-request locks). Recommended interim guidance: run the subscription server with a single replica for strict enforcement.

Use mutex locks to ensure maxSubscriptions is properly managed:
appLocks sync.Map to SubscriptionHandler and a lockApp(appIdHash) helper that lazily creates and acquires a per-application mutex (different apps never block each other).

*Note:*
Cross-replica caveat & follow-up (not implemented here). The mutex coordinates requests within one pod only. subscriptionServer.replicas is configurable (default 1); with >1 replica, pods can still interleave List/Create and overshoot the limit. Strict cross-replica enforcement would use a per-app distributed lock via a coordination.k8s.io/v1 Lease (capop-sublimit-<appIdHash>): acquire by Get→Create-if-absent / take-if-expired-or-ours via Update with resourceVersion (409-retry), holderIdentity from a POD_NAME env var, leaseDurationSeconds tuned above a single Create but short enough to bound stall on holder crash, release by Update/Delete. This needs leases RBAC added to the subscription-server Role in the cap-operator-lifecycle Helm chart (cross-repo). client-go leaderelection is a poor fit (long-lived leader election, not short per-request locks). Recommended interim guidance: run the subscription server with a single replica for strict enforcement.
@sonarqubecloud

Copy link
Copy Markdown

This branch was successfully deployed

1 active deployment
build — 15502177 Deployed Nov 11, 2026 by Pavan-SAP via Analyze with Sonar Cloud #1804
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.

1 participant