openconfig / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.openconfig.net
Apache License 2.0
176 stars 55 forks source link

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

Open pree04 opened 11 months ago

pree04 commented 11 months ago

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.

karimra commented 11 months ago

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

pree04 commented 11 months ago

@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

  1. 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

karimra commented 11 months ago

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

pree04 commented 11 months ago

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

karimra commented 11 months ago

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

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

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

pree04 commented 11 months ago

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

karimra commented 11 months ago

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

pree04 commented 11 months ago

@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.

peejaychilds commented 11 months ago

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 ...

pree04 commented 11 months ago

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

pree04 commented 10 months ago

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