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

reread auth file #22

Open
ppbrown opened this issue Apr 6, 2023 · 11 comments
Open

reread auth file #22

ppbrown opened this issue Apr 6, 2023 · 11 comments

Comments

@ppbrown
Copy link

ppbrown commented Apr 6, 2023

2023-04-06 19:53:20 +0000 [warn]: #0 failed to flush the buffer. retry_times=10 next_retry_time=2023-04-06 20:10:35 +0000 chunk="5f8b00246b400a668bd3d83a9bb6ea8b" error_class=Aws::TimestreamWrite::Errors::ExpiredTokenException error="The security token included in the request is expired"

It would be nice if the plugin attempted to re-read the credentials.
In this case, the old cred had been updated... but the plugin just kept to the old ones and failed writes, even though a usable one was sitting in the appropriate location.

@valerauko
Copy link

So you want to be able to change the credentials at runtime without restarting the process?

@ppbrown
Copy link
Author

ppbrown commented Apr 7, 2023 via email

@mtakeda15
Copy link

If the aws sdk which this plugin uses can re-read the credentials, we may be able to support it.
However, I don't think aws sdk supports such a feature. I read some documents, but I could not find it.

@ppbrown
Copy link
Author

ppbrown commented Apr 11, 2023 via email

@mtakeda15
Copy link

Would a workaround like this work for you? It'd be helpful if you could try it out.

lib/fluent/plugin/out_timestream.rb

      def write_records(records)
        return if records.empty?
+       options = credential_options
+       options[:region] = @region if @region
+       options[:endpoint] = @endpoint if @endpoint
+       options[:ssl_verify_peer] = @ssl_verify_peer
+       @client = Aws::TimestreamWrite::Client.new(options)
        @client.write_records(
          database_name: @database,
          table_name: @table,
          records: records
        )

@ppbrown
Copy link
Author

ppbrown commented Apr 21, 2023 via email

@mtakeda15
Copy link

Creating a timestream client every time when plugin send data to Timestream.
When client is recreated, new credential could be re-read.

By the way, how do you have your credential?
At least, if you specify the credentials by fluent.conf, this code does not work. (I guessed you don't do it)

@ppbrown
Copy link
Author

ppbrown commented Apr 24, 2023 via email

@mtakeda15
Copy link

Environment vars are read only when a process starts up, so I don't think this code works.
I expected that you have credential by ~/.aws/credentials or ~/.aws/config.

In this readme, they explain:

Shared configuration is loaded only a single time, and credentials are provided statically at client creation time. Shared credentials do not refresh.

So I expected if you have credentials by these files and update periodically, this code could be helpful.

@ppbrown
Copy link
Author

ppbrown commented Apr 26, 2023 via email

@mtakeda15
Copy link

@ppbrown
I wanted to know if the experimental code works in your environment or not.
If it works, I will consider how recreate client.

Could you confirm that code work or not in your environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants