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

Suspected deadlock in Loki integration #646

Closed
bsod90 opened this issue Sep 25, 2023 · 4 comments
Closed

Suspected deadlock in Loki integration #646

bsod90 opened this issue Sep 25, 2023 · 4 comments
Labels
kind/bug Something isn't working
Milestone

Comments

@bsod90
Copy link
Contributor

bsod90 commented Sep 25, 2023

Describe the bug

I'm trying to configure Falco <> Loki integration, but it doesn't seem to work. DEBUG logs indicate that Loki client has been configured, but then it seems to be just hanging when attempting to send Loki payload.
I have to specify tenant to connect to my Loki instance, and I suspect that there's a mistake in the code that adds the X-Org-ID handler here:

defer c.httpClientLock.Unlock()

I'm not a Go expert, but won't this cause a deadlock because of the other lock acquisition a few lines below?

Also, the custom headers block doesn't seem to be locking the client at all.
I wish I could just test it locally and contribute a fix, but I don't see a quick way to go through all the steps of building the binary, then docker, then Helm to finally get it onto our infra.

I'd be super grateful if someone with an already configured dev-environment could help. Thank you!

How to reproduce it

Configure falcosidekick (via Helm chart) like this:

falcosidekick:
  enabled: true
  webui:
    enabled: false
  config:
    debug: true
    slack:
      minimumpriority: "notice"
      webhookurl: https://hooks.slack.com/services/*********
    loki:
      hostport: "https://loki.monitoring.****"
      user: loki
      apikey: ******
      endpoint: /loki/api/v1/push
      tenant: falco
      minimumpriority: info

Expected behaviour

Receive Falco alerts both in Slack and Loki

Actual behaviour

Only Slack alerts are being delivered

Screenshots
Screenshot 2023-09-25 at 10 55 40 AM

Environment

Falcosidekick 2.28.0 installed via Helm on GKE

@bsod90 bsod90 added the kind/bug Something isn't working label Sep 25, 2023
@Issif Issif added this to the 2.29.0 milestone Sep 25, 2023
@Issif
Copy link
Member

Issif commented Sep 25, 2023

Thank for your issue, I'll take a look at the root cause and your fix.

For the test env, no need a k8s cluster, go can easily run the binary locally and use a container aside for Loki.

@bsod90
Copy link
Contributor Author

bsod90 commented Sep 25, 2023

Yeah, but I don't even have Falco running locally to generate alerts :)
Anyway, I was trying to prove my theory by manually supplying X-Scope-OrgID via customHeaders instead of the tenant (custom headers part just doesn't lock the client for the second time). However, it seems like that part doesn't work either. I suspect it's because Loki.CustomHeaders has to be mentioned here

v.GetStringMapString("Webhook.CustomHeaders")
, but I'm too unfamiliar with the codebase and could easily be wrong.

Thanks again for helping with this, @Issif ! 🤗

@Issif
Copy link
Member

Issif commented Sep 25, 2023

I will check. For generating test events, you can call falcosidekick, see itself https://github.com/falcosecurity/falcosidekick#quicktest

@bsod90
Copy link
Contributor Author

bsod90 commented Sep 26, 2023

Ok, I was able to verify that the fix indeed works

Screenshot 2023-09-26 at 2 04 58 PM

@bsod90 bsod90 closed this as completed Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants