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

agent: enhance DeadEndState logic #724

Open
lucab opened this issue Jan 26, 2022 · 0 comments
Open

agent: enhance DeadEndState logic #724

lucab opened this issue Jan 26, 2022 · 0 comments

Comments

@lucab
Copy link
Contributor

lucab commented Jan 26, 2022

Right now the agent keeps track at runtime of the deadend state (including the starting "unknown" case):

impl DeadEndState {
const FALSE: u8 = 0;
const TRUE: u8 = 1;
const UNKNOWN: u8 = 2;
/// Return whether this is in a known dead-end state.
pub fn is_deadend(&self) -> bool {
self.0.load(Ordering::SeqCst) == Self::TRUE
}
/// Return whether this is in a known NOT dead-end state.
pub fn is_no_deadend(&self) -> bool {
self.0.load(Ordering::SeqCst) == Self::FALSE
}

The no-deadend case (the most common one) can be further optimized by relying on the filesystem and avoid going through pkexec even once: if we determine that our fragment under /run/motd.d/ does not exist, there is no need to go through the "unset" logic.

On the other hand, the "is-a-deadend" case should be improved to account for the fact that the "reason" string could be updated between different graph scrapes. Thus the agent should internally cache the current deadend reason too, and refresh the MOTD fragment if the reason changed (even if the dead-end state stayed the same).

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

No branches or pull requests

1 participant