diff options
| author | tv <tv@krebsco.de> | 2026-11-20 01:26:11 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-20 01:26:11 +0000 |
| commit | f02b09eae7e806f2fe9caa26b4975b94351d7e27 (patch) | |
| tree | c043f6443dac2cfb73446bba993cb9ac3b58c300 /pkgs/populate/src/populate.rs | |
| parent | 61840ec59bc13b9b2ae6d29fff7276c849684941 (diff) | |
populate: fail when losing the lock, keepalives for the ssh connection
The command holding the lock can end while populate runs: killed on the
target, e.g. by the OOM killer, or with the shared ssh connection, e.g.
when its master gets killed, after which populate's next command would
start a new one, and go on without the lock. When that command ends, so
does what populate runs it with, ssh or sh, which populate's child is.
So Context::shell, which every command on the target goes through,
before what it changes, and before the record, checks that the child is
still running, failing otherwise. A run that wasn't locked throughout
doesn't get recorded, and its journal stays, so the next record tells
what it changed. Context keeps the lock, which clean_up releases.
The keepalives end the shared connection, and with it the command
holding the lock on the target, about a minute after the target stops
answering, e.g. when the network fails, instead of when TCP gives up,
which may take hours.
lock-lost kills the command holding the lock from a pipe source.
Diffstat (limited to 'pkgs/populate/src/populate.rs')
| -rw-r--r-- | pkgs/populate/src/populate.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pkgs/populate/src/populate.rs b/pkgs/populate/src/populate.rs index d0189b7..617d39f 100644 --- a/pkgs/populate/src/populate.rs +++ b/pkgs/populate/src/populate.rs @@ -25,7 +25,7 @@ pub fn populate(context: &Context, spec: &Spec) -> Result<()> { &[&sentinel, &context.name(&sentinel), dir, force], )?; let started = record::now(); - let (lock, previous) = context.lock(&sentinel, json!({ "run": started }))?; + let previous = context.lock(&sentinel, json!({ "run": started }))?; if spec.backup { context.run(&sh::backup(), &[dir])?; } @@ -73,7 +73,7 @@ pub fn populate(context: &Context, spec: &Spec) -> Result<()> { } let record = record::record(spec, &started, &previous, &context.entries()); context.run(sh::RECORD, &[&sentinel, &record.to_string()])?; - drop(lock); + context.unlock(); Ok(()) } @@ -292,7 +292,7 @@ impl Kind for Git { ]; args.extend(excludes); // With standard input, which Git may ask for credentials on. - let mut command = d.context.shell(&sh::git(), &args); + let mut command = d.context.shell(&sh::git(), &args)?; command.stdin(Stdio::inherit()); let output = run::output(&mut command)?; let mut outcome = Outcome::default(); |
