fix: bypass GetAccounts API call when CF_ACCOUNTS is set#1
Merged
aymanbagabas merged 1 commit intomainfrom Mar 24, 2026
Merged
Conversation
When CF_ACCOUNTS is explicitly configured, the exporter hung indefinitely on startup because ListAutoPaging requires Account:Read permissions that zone-scoped tokens don't have. When CF_ACCOUNTS is provided, skip the API call entirely and construct the account list directly from the configured IDs. The API is only called when CF_ACCOUNTS is not set, preserving existing behavior for unrestricted tokens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
CF_ACCOUNTSis configured, the exporter hangs indefinitely on startup. TherefreshAccountsfunction always callsclient.GetAccounts()which usesListAutoPagingunder the hood — this requiresAccount:Readpermission that zone-scoped API tokens don't have. The call blocks until the 30s context timeout, then setscloudflare_exporter_up=0and retries everyACCOUNT_CACHE_TTL(default 10m), never making progress.The
/healthendpoint passes because it uses a different API call, masking the issue.Fix
When
CF_ACCOUNTSis explicitly set, skip theGetAccountsAPI call entirely and build the account list directly from the configured IDs. The API call is only made whenCF_ACCOUNTSis not set, preserving existing behavior for tokens with full account permissions.Test
Before: exporter hangs at
fetching accounts,cloudflare_exporter_up=0After: exporter starts immediately, discovers zones and collects metrics