gnmic icon indicating copy to clipboard operation
gnmic copied to clipboard

/home/runner/work/gnmic/gnmic/pkg/loaders/file_loader/file_loader.go:201: [file_loader] failed to read targets file

Open pree04 opened this issue 2 years ago • 14 comments

Hi , I am using gnmi file loader to load remote file and i get the error /home/runner/work/gnmic/gnmic/pkg/loaders/file_loader/file_loader.go:201: [file_loader] failed to read targets file: Get "https://l/raw?private_token=generated token value": context deadline exceeded

hwever i am able to get the content of the file using curl @karimra Please help.

pree04 avatar Nov 23 '23 08:11 pree04

That error means the request timed out. There could be many reasons for that.

  • Check that the http server is reachable from gnmic server/container/pod.
  • Check if the http server you run has tls enabled or not and configure the loader accordingly.

karimra avatar Nov 23 '23 18:11 karimra

@karimra

  1. Check that the http server is reachable from gnmic server/container/pod. ->for this i added http_proxy in gnmi env variable,

but how will i check from the gnmic server/container/pod ? curl is not available and even i am unable to do apk add curl there 2. Check if the http server you run has tls enabled or not and configure the loader accordingly. -> since from test pods i am able to curl and i get the file content without passing tls and without using -k . I feel the way I am passing the token is not correct. Internally gnmi is doing url.Parse(path) . When i do the parse seperately i get the error panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]: main.main() /tmp/sandbox2191370610/prog.go:31 +0x4a5

It seems we can not pass ?token=token value in the url

pree04 avatar Nov 23 '23 19:11 pree04

If your http server does not have TLS enabled try with a url with scheme http:// not https://

karimra avatar Nov 23 '23 19:11 karimra

No , we need to use https only, but i already set the skip-verify: true @karimra how to troubleshoot this? when i try to install curl in pod(using apk add curl) to test the connecitivity to the file i get ERROR: Unable to lock database: Permission denied ERROR: Failed to open apk database: Permission denied

pree04 avatar Nov 23 '23 19:11 pree04

can you share your loader config here, so we are on the same page?

karimra avatar Nov 23 '23 19:11 karimra

insecure: true    
loader:
  type: file
  path: https://<gitlab.com>/api/v4/projects/222/repository/files/test%2ftargets.yaml/raw?private_token=23122432424
  interval: 30s

pree04 avatar Nov 23 '23 19:11 pree04

maybe replace that %2f with /, the url parsing will do that for you.

karimra avatar Nov 23 '23 20:11 karimra

@karimra url parsing works fine for the url https://<gitlab.com>/api/v4/projects/222/repository/files/test%2ftargets.yaml/raw?private_token=23122432424 but how can i test from gnmi this url is accessible?

pree04 avatar Nov 24 '23 02:11 pree04

That depends on your setup, that's out of scope of gnmic.

karimra avatar Nov 24 '23 03:11 karimra

@karimra I am able to do the curl from the test pod and as well as from kubernetes nodes . it seems gnmic pods dont allow to install curl to test it from there.

pree04 avatar Nov 24 '23 03:11 pree04

On the node that you are running your gnmic pod you can run curl on the node but in network namespace of the gnmic pod which should tell you if you have some type of issue due to name resolution and/or pod network policy etc.

https://www.redhat.com/sysadmin/container-namespaces-nsenter

Also if the URL works with gnmic outside the pod then the issue is not with gnmic but with your environment ...

peejaychilds avatar Nov 24 '23 03:11 peejaychilds

@peejaychilds @karimra Can gnmi file loader is able to fetch the file from gilab?

pree04 avatar Nov 24 '23 08:11 pree04

From the node where gnmi pods are runing, able to curl and get the result from the same gnmi namespace i created a test pod and tried curl that is also working

pree04 avatar Nov 28 '23 10:11 pree04