-
Notifications
You must be signed in to change notification settings - Fork 490
S3 Destination #4624
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
S3 Destination #4624
Conversation
Build FAILURE |
Build FAILURE |
Build FAILURE |
Build FAILURE |
Build FAILURE |
Build FAILURE |
This is now ready for review, we still need the reloc and metric labeling support in python, but the business logic is done. |
Build FAILURE |
bee6759
to
747691f
Compare
Build FAILURE |
c5d4478
to
e147ec5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some minor remarks only, the overall picture is very great, thanks!
We also discussed the compress/compresslevel
vs compresslevel
only part, and we had agreed on keeping it the current way for easier configuration.
def __init__( | ||
self, | ||
path: Path, | ||
compress: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it seems that the compress
field serves as a guard for compresslevel
only. However as compresslevel
is Optional[int]
, compress
seems redundant because setting compression can be done by passing some level or just omitting it if no compression is required. How about removing it?
|
||
|
||
class S3Destination(LogDestination): | ||
S3_OBJECT_TIMEOUT_INTERVAL = 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpicking]
I think S3_OBJECT_TIMEOUT_INTERVAL_SECONDS
might be a bit more suitable name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
|
||
signal(SIGINT, SIG_IGN) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stood out to me for a while, is it there to propagate the signal to syslog-ng?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed as we are running python in isolated mode, which means it should not install signal handles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still having a problem if I remove that line:
^C[2023-09-19T14:02:51.779809] syslog-ng shutting down; version='4.3.1.174.g93ca97d.dirty'
[2023-09-19T14:02:51.975195] Exception while calling a Python function; caller='d_s3#0', class='syslogng.modules.s3.S3Destination', function='deinit', exception='KeyboardInterrupt: '
Traceback (most recent call last):
File "/home/alltilla/repos/syslog-ng/build/install/lib/syslog-ng/python/syslogng/modules/s3/s3_destination.py", line 148, in deinit
def deinit(self) -> None:
KeyboardInterrupt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens, when I Ctrl+C a running syslog-ng.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked it with bare python
and python -I
, both of them catch SIGINT :/
$ sudo ps -o pid,caught,cmd -p 143434
PID CAUGHT CMD
143434 0000000008000002 python3
$ sudo ps -o pid,caught,cmd -p 214536
PID CAUGHT CMD
214536 0000000000000002 python3 -I
$ python -I
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> ^C
KeyboardInterrupt
self.object_key_timestamp: Optional[LogTemplate] = options["object_key_timestamp"] | ||
self.message_template: LogTemplate = options["template"] | ||
self.compression = bool(options["compression"]) | ||
self.compresslevel = int(options["compresslevel"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be Optional[int]
, shouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, setting the defaults for each option is the responsibility of the SCL. If the user uses this class as a python dest, and they mess this up, they will see an error.
except KeyError:
assert False, (
f"S3: {str(exc_info()[1])[1:-1]}() option is missing. "
"If you are using this driver via the python() destination, please use the s3() driver directly. "
"The option validation and propagation should be done by the s3.conf SCL."
)
block destination s3(
url("")
bucket()
access_key()
secret_key()
object_key()
object_key_timestamp("")
template("${MESSAGE}\n")
compression(no)
compresslevel(9)
return False | ||
|
||
if retries == 0: | ||
self.logger.error("Upload queue full, waiting for available space") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.logger.error("Upload queue full, waiting for available space") | |
self.logger.error("Upload queue is full, waiting for available space") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
|
||
|
||
class S3Object: | ||
MIN_CHUNK_SIZE = 5 * 1024 * 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIN_CHUNK_SIZE = 5 * 1024 * 1024 | |
MIN_CHUNK_SIZE_BYTES = 5 * 1024 * 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
compression(no) | ||
compresslevel(9) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about removing the compression
option and using compresslevel(0)
as a way to disable compression?
self.object_key_timestamp: Optional[LogTemplate] = options["object_key_timestamp"] | ||
self.message_template: LogTemplate = options["template"] | ||
self.compression = bool(options["compression"]) | ||
self.compresslevel = int(options["compresslevel"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also please also add some sanity checks regarding its value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
bbdf4b7
to
5ec14e8
Compare
@OverOrion Thanks for the comments. As we discussed IRL, I have kept |
modules/python-modules/syslogng/modules/s3/compressable_file_buffer.py
Outdated
Show resolved
Hide resolved
It is needed for SCLs, where the 2 double-quotes get resolved to nothing. We want to have na empty template in that case. Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 👍🏻
(please squash the fixups)
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Python 3.6 does not support fres boto3 and botocore versions, also compiling type hinted code (which is done for some reason during setup.py) does not seem to work. We tackle these 2 in the following ways: In requirements.txt we allow installing older boto3 and botocore versions. We should not install them at all, but filtering based on the python version would be complex. We skip adding the s3 module to the packages in setup.py for <= 3.6. The only platform we support and has 3.6 is centos-7. We can remove these workarounds when the centos-7 support is dropped (June 2024). Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
No description provided.