logstash-plugins / logstash-output-google_cloud_storage

Apache License 2.0
9 stars 26 forks source link

Unable to connect to GCS (certificate verify failed) #20

Closed neuromantik33 closed 5 years ago

neuromantik33 commented 6 years ago

I'm unable to use with plugin within a docker container, using the 6.1.0 and 5.6.8 tags. I'm pretty sure it isn't the key since I've generated 3 different p12 keys for the same service account and they all fail, and the stacktrace fails beforehand.

Here is my configuration (I've changed all bucket names and project ids for obvious reasons) :

As I said it doesn't seem to be a p12 key issue (that line is never reached) but some other odd behviour. Is this plugin still supported with Google Cloud's current storage API, or even logstash 5.x or 6.x for that matter. Any help would be much appreciated (which may include alternatives for shipping filebeat logs to GCS)

Thanks in advance

colinsurprenant commented 6 years ago

Thanks for the report @neuromantik33.

Sorry if this is a stupid question: are you providing a proper key_password option?

neuromantik33 commented 6 years ago

I didn't originally since I'm using the default password supplied by google (notasecret) but I did add the key_password => "notasecret" to the pipeline.conf and the problem is the same. I noticed that that the google cloud api lib is horribly out of date but I'm not a ruby developer and wouldn't know how to upgrade and test with the new lib. Has anyone tested this plugin with the official logstash image?

colinsurprenant commented 6 years ago

This plugin was community contributed and is not officially supported by Elastic.

I looked at the lib and yeah, it has seen lots of changes and unfortunately it is not a trivial update because the lib APIs have changed too.

It is hard to say if the problem is related to the lib version but in any cases upgrading would probably not hurt and should be done at some point.

If you are ready to help, I could try and update it and give you instructions on how to test it? let me know if you are willing to help for that!

josephlewis42 commented 6 years ago

I created a PR to use a newer version of the (Java) GCP library to see if that helps. I built and tested the plugin on 6.2.3.

Travis is failing for Logstash 5.6 reporting a ruby-maven issue. @colinsurprenant would you be willing to take a look? I'm not that familiar with JRuby and I hope you might have seen this before.

josephlewis42 commented 6 years ago

As a temporary solution, dblommesteijn's solution might work: https://github.com/google/google-api-ruby-client/issues/235

neuromantik33 commented 6 years ago

Hi. Sorry for the lateness of my reply (French vacations :P).. Anyhow @colinsurprenant @josephlewis42 I would be happy to test out anything you have to give me. I have an environment ready to test and a build pipeline for the logstach docker image w/ gcs-out plugin.

josephlewis42 commented 6 years ago

@neuromantik33 enjoy vacation if you've got it!

I've published a gem of the proposed changes I've made in a personal repo: https://github.com/josephlewis42/personal_codebase/releases/tag/logstash-release

The caveat is rather than supplying a key_path, key_password and service_account you'll use json_key_file and a path to the service account's JSON key file. It's a breaking change, but hopefully a good one.

You should be able to install the plugin using /path/to/logstash-plugin install logstash-output-google_cloud_storage-4.0.0-java.gem manually.

neuromantik33 commented 6 years ago

@josephlewis42 So I've been testing out your gem and it seems to work great aside from a few annoyances.

Besides that thank you! Hope it gets merged soon! :+1:

josephlewis42 commented 6 years ago

@neuromantik33 sweet, I'm glad things are working well! Let's get this merged in and you can throw them in the backlog (unless either of them are regressions) so one of us can do a smaller PR against them, does that work?

@colinsurprenant do you have any hesitations about merging this (#21) and doing a release now that it's been verified? I know there's the outstanding Travis issue but I don't think it's a blocker because it's a known issue.

colinsurprenant commented 6 years ago

Sorry for the delay - @josephlewis42 I did not look into the specifics of the shutdown handling @neuromantik33 is reporting above but I would prefer we make sure that shutdown situations are correctly handled before merging. Let me know if you need help with that, it can be a bit tricky.

josephlewis42 commented 6 years ago

I can do that. I'd like to run the approach by you before coding it up if I can (@neuromantik33 I'd love your feedback too):

@colinsurprenant this plugin suffers from some of that same crazy upload queue/sleep logic the BigQuery one had, I can add an item to my backlog to move this over to a worker pool which should fix #2, #5, and #19

neuromantik33 commented 6 years ago

@josephlewis42 Sounds good to me, I agree that after browsing the code, an n-thread ExecutorService of some sort would be preferable (and easier to read) instead of interrupting/joining threads everywhere which is tricky and error prone. I'm not too familiar with the lifecycle states of a logstash pipeline so I can't offer any other suggestions, besides the fact that best-effort is what I'm looking for, and I'll be happy to test it out if needed (I can now build the pipeline so I can just checkout your javabackend branch if necessary)

josephlewis42 commented 6 years ago

Whoops, I'm confusing my input and my output plugins. The plugin already has a close which is called on shutdown. I'll modify that instead.

josephlewis42 commented 6 years ago

@neuromantik33 I got that patch in for testing if you'd like to try it out. I built another gem you can grab from here: https://github.com/josephlewis42/personal_codebase/releases/download/logstash-release/logstash-output-google_cloud_storage-4.0.0-java.gem

neuromantik33 commented 6 years ago

@josephlewis42 After extended testing the plugin works fine under moderate load which is great. A graceful shutdown indeed triggers a last effort upload and deletion, I've tried shutting down filebeat, resuming it, shutting down logstash, killing logstash, all work as expected.

The only thing that should be noted although for my use case it isn't a problem is that under docker-compose (my initial tests before Kubernetes), when stopping the logstash container using docker stop logstash -t 60, the current file is indeed uploaded and deleted. However when restarting the container using docker start logstash the file is recreated with the same name (as the IP doesn't change) and thus eventually overwrites the file previously uploaded.

Again this is a extremely small issue, as when stopping pods hostnames are not reused. Anyhow thanks again and hope this time it gets merged quickly.

josephlewis42 commented 6 years ago

@neuromantik33 awesome!

I just opened up #23 as a potential fix for the clobber, I'd love your input if you have time.