#Concurrent API call bug

9 messages · Page 1 of 1 (latest)

wooden storm
#

Okay, I have a code pattern that essentially gets a list of folders then for each folder's UID I need to call another API to get the permissions. This seemed like a great place to add concurrency. Here's my attempt below. This works flawlessly as a serial call, what am I doing wrong here?

https://gist.github.com/safaci2000/686662417357b17ff7a4eba13b560b70

Output is partially working and the rest gives me:

ERRO[0000] Unable to get folder permissions for folderUID: MI9wf527z  error="[GET /folders/{folder_uid}/permissions][500] getFolderPermissionListInternalServerError  &{Error: Message:0xc000e0a770 Status:}" message="invalid API key"
ERRO[0000] Unable to get folder permissions for folderUID: OTNUyTwVz  error="[GET /folders/{folder_uid}/permissions][500] getFolderPermissionListInternalServerError  &{Error: Message:0xc00018aa50 Status:}" message="invalid API key"
...etc

This is going against grafana which should be able to handle multiple API calls at the same time, I'd hope.

Gist

concurrency.go. GitHub Gist: instantly share code, notes, and snippets.

dusk mirage
wooden storm
#

well, any valid grafana instance is fine, but in this use case it's a 3 running instances behind a LB with a postgres backend

dusk mirage
#

Here's your problem then.

#

If each instance keeps its own track of auth tokens, you have a 1/3 chance of getting the invalid API key error

#

If they share the db, then it should work fine

#

@wooden storm ^^

wooden storm
#

They share a database. Same data, same dashboard, users, tokens, etc

mortal plinth
#

The grafana docs don't even list a 500 response as a condition for /folder/id/permissions