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

feat(journald source): Add checkpointing support #816

Merged
merged 9 commits into from Sep 9, 2019

Conversation

bruceg
Copy link
Member

@bruceg bruceg commented Aug 31, 2019

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

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>
@binarylogic
Copy link
Contributor

Nice work. I appreciate that you split out the file data_dir code.

Copy link
Contributor

@LucioFranco LucioFranco left a 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"
Copy link
Contributor

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?

Copy link
Member Author

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 Show resolved Hide resolved
Ok(into_string(cursor).unwrap())
}

pub fn seek_cursor(&self, cursor: &str) -> IOResult<()> {
Copy link
Contributor

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?

Copy link
Member Author

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?

src/sources/journald.rs Outdated Show resolved Hide resolved
@@ -124,21 +137,54 @@ fn create_event(record: Record) -> Event {
log.into()
}

trait JournalCursor {
Copy link
Contributor

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?

Copy link
Member Author

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.

src/sources/journald.rs Show resolved Hide resolved
src/sources/journald.rs Show resolved Hide resolved
@@ -177,6 +236,89 @@ where
}
}

const CHECKPOINT_FILENAME: &'static str = "checkpoint.txt";
Copy link
Contributor

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?

Copy link
Member Author

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);
Copy link
Contributor

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?

Copy link
Member Author

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.

@bruceg
Copy link
Member Author

bruceg commented Sep 9, 2019

@LucioFranco do you still approve this or would you like to review it again since I pushed some additional changes?

@bruceg bruceg merged commit 94cadda into master Sep 9, 2019
@binarylogic binarylogic deleted the journald-checkpointing branch October 3, 2019 15:10
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

Successfully merging this pull request may close these issues.

None yet

3 participants