Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caching for GitHub App tokens #202

Merged
merged 1 commit into from
Mar 6, 2025
Merged

Conversation

matheuscscp
Copy link
Member

@matheuscscp matheuscscp commented Mar 1, 2025

This PR introduces a token cache in the operator. At the moment, we use it for GitHub App tokens in the ResourceSetInputProvider API.

This token cache will report the following metrics:

  • Counter flux_token_cache_events_total
    • Help: Total number of cache retrieval events for a Gitops Toolkit resource reconciliation.
    • Labels: event_type, kind, name, exported_namespace. The values of event_type can be cache_miss or cache_hit.
  • Counter flux_token_cache_requests_total
    • Help: Total number of cache requests partioned by success or failure.
    • Labels: status. The values of status can be success or failure.
  • Counter flux_token_cache_evictions_total
    • Help: Total number of cache evictions.
    • No labels.
  • Gauge flux_token_cached_items
    • Help: Total number of items in the cache.
    • No labels.

@matheuscscp matheuscscp force-pushed the github-app-token-cache branch 4 times, most recently from 67c6a90 to 950be4e Compare March 1, 2025 16:08
@matheuscscp matheuscscp force-pushed the github-app-token-cache branch from 950be4e to ac9c2ef Compare March 4, 2025 14:50
@matheuscscp matheuscscp force-pushed the github-app-token-cache branch from ac9c2ef to a04dba7 Compare March 4, 2025 15:02
@stefanprodan
Copy link
Member

All metrics exported by Flux Operator use exported_namespace to avoid collision with Prometheus Operator collector where the namespace is set to the pod/service namespace. Can we change that label?

@matheuscscp
Copy link
Member Author

All metrics exported by Flux Operator use exported_namespace to avoid collision with Prometheus Operator collector where the namespace is set to the pod/service namespace. Can we change that label?

Sure, we need a change in the cache lib

@matheuscscp matheuscscp force-pushed the github-app-token-cache branch from a04dba7 to 407e841 Compare March 5, 2025 17:05
Signed-off-by: Matheus Pimenta <[email protected]>
@matheuscscp matheuscscp force-pushed the github-app-token-cache branch from 407e841 to b805987 Compare March 5, 2025 20:45
@matheuscscp
Copy link
Member Author

All metrics exported by Flux Operator use exported_namespace to avoid collision with Prometheus Operator collector where the namespace is set to the pod/service namespace. Can we change that label?

Fixed, thanks!

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @matheuscscp 🏅

@stefanprodan stefanprodan added the area/resourceset ResourceSet related issues and PRs label Mar 6, 2025
@matheuscscp matheuscscp merged commit 7d8ec2e into main Mar 6, 2025
1 check passed
@matheuscscp matheuscscp deleted the github-app-token-cache branch March 6, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resourceset ResourceSet related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants