Qualify tenant-scoped bootstrap rotation and fresh Windows scripting
This commit is contained in:
@@ -52,6 +52,8 @@ struct Endpoint {
|
||||
ca_file: PathBuf,
|
||||
#[serde(default)]
|
||||
enable_jobs: bool,
|
||||
#[serde(default)]
|
||||
localservice_time_policy: Option<PathBuf>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct Health {
|
||||
@@ -349,16 +351,36 @@ async fn stage(device: &Device, release: &Published, active: &Installed) -> Resu
|
||||
result
|
||||
}
|
||||
|
||||
fn exclusive_job_gate() -> Result<Option<fs::File>> {
|
||||
use std::os::windows::fs::OpenOptionsExt;
|
||||
let path = data("release-job.lock");
|
||||
job_binding::check_admin_readonly(&path)?;
|
||||
match fs::OpenOptions::new().read(true).share_mode(0).open(path) {
|
||||
Ok(file) => Ok(Some(file)),
|
||||
Err(error) if error.raw_os_error() == Some(32) => Ok(None),
|
||||
Err(error) => Err(error.into()),
|
||||
}
|
||||
}
|
||||
|
||||
async fn cycle() -> Result<()> {
|
||||
let active: Installed = read_record(ACTIVE)?;
|
||||
let config: Endpoint = serde_json::from_slice(&protected(&data("config.json"), 32768)?)?;
|
||||
// Installed passive pairs only. A separately provisioned SYSTEM helper and
|
||||
// privileged time/profile pins need the existing coordinated handoff.
|
||||
// Additional SYSTEM helper pins need their separately coordinated handoff.
|
||||
ensure!(
|
||||
!config.enable_jobs,
|
||||
!config.enable_jobs
|
||||
|| config.localservice_time_policy.as_ref() == Some(&data("job-time.json")),
|
||||
"job-enabled pair requires coordinated helper handoff"
|
||||
);
|
||||
if data(INTENT).try_exists()? {
|
||||
let _job_gate = if config.enable_jobs {
|
||||
let Some(file) = exclusive_job_gate()? else {
|
||||
return Ok(());
|
||||
};
|
||||
Some(file)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let t: Transition = read_record(INTENT)?;
|
||||
if active.release_id == t.new.release_id {
|
||||
fs::remove_file(data(INTENT))?;
|
||||
@@ -414,6 +436,14 @@ async fn cycle() -> Result<()> {
|
||||
"current agent version not confirmed"
|
||||
);
|
||||
let new = stage(&device, &release, &active).await?;
|
||||
let _job_gate = if config.enable_jobs {
|
||||
let Some(file) = exclusive_job_gate()? else {
|
||||
return Ok(());
|
||||
};
|
||||
Some(file)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let t = Transition { old: active, new };
|
||||
write_record(INTENT, &t)?;
|
||||
let start = chrono::Utc::now();
|
||||
|
||||
Reference in New Issue
Block a user