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
feat(journald source): Add checkpointing support #816
Conversation
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Nice work. I appreciate that you split out the file |
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 LGTM mostly just have some questions that I left inline.
# | ||
# * optional | ||
# * no default | ||
data_dir = "/var/lib/vector" |
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 sounds like something we should add to the file source too since it has check pointing as well?
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 got this from the file
source. I'm not sure what it is we should add to it then.
lib/journald/src/lib.rs
Outdated
Ok(into_string(cursor).unwrap()) | ||
} | ||
|
||
pub fn seek_cursor(&self, cursor: &str) -> IOResult<()> { |
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.
seems odd that we are passing around a str for a cursor is there any more type level stuff we could add to this?
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.
The cursor from libsystemd is a string. Do you mean to wrap it in a dummy struct?
@@ -124,21 +137,54 @@ fn create_event(record: Record) -> Event { | |||
log.into() | |||
} | |||
|
|||
trait JournalCursor { |
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.
looks like below you bound this with Iterator<Item = Result<Record, Error>>
would it make sense to bound this trait by that so that they are coupled?
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'm not sure it adds much, and neither trait is used by the other directly so they aren't strictly tied. If you think it makes sense I'll defer to your judgment.
@@ -177,6 +236,89 @@ where | |||
} | |||
} | |||
|
|||
const CHECKPOINT_FILENAME: &'static str = "checkpoint.txt"; |
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.
would it make sense to name this something related to journald?
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.
Sure. Any suggestions? journald-checkpoint.txt
?
} | ||
let readonly = std::fs::metadata(&data_dir) | ||
.map(|meta| meta.permissions().readonly()) | ||
.unwrap_or(true); |
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 doesn't make much sense if the metadata call fails we can still readonly, wouldn't this indicate that maybe the file/dir doesn't exist?
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.
That was moved from the file
source as-is. The check for the directory existing happens immediately above this, so this can only fail if stat
fails on an existing directory, which is almost certainly also a permissions error (or kernel bug). I can add an additional error case if you think it makes sense.
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
@LucioFranco do you still approve this or would you like to review it again since I pushed some additional changes? |
This implements checkpointing support for the journald source, which allows us to restart importing journald logs from after the most recently handled entry.
Ref #327