Skip to content

operatorCacheData check-then-act race allows concurrent requests to double-fetch from Kubernetes #7783

@aashu2006

Description

@aashu2006

User Request

Type: bug
Target: Console Application
Submitted by: @aashu2006
Console Request ID: c71399eb-f794-4608-aa43-f4c582556a32

Description

What happened:
In pkg/api/handlers/gitops.go:710-759, the cache check releases RLock at line 725 before the fetch at line 727. Two concurrent requests for the same cluster both see a cache miss, both call fetchOperatorsFromCluster, and both write the result. There is no singleflight or write-lock-then-recheck guard. With 18+ clusters queried in parallel this race fires regularly.

What I expected:
singleflight should coalesce concurrent cold-cache fetches, or the write lock should include a second cache check before writing.

Steps to reproduce:

  1. Send multiple concurrent requests for the same cluster
  2. Observe multiple Kubernetes API calls for the same cluster's operators

This issue was automatically created from the KubeStellar Console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-fix-requestedai-processingAI is currently processing this issuekind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions