feat: snapshot Linux-first RMM MVP and pause handover
Rust development slice / linux (push) Failing after 1m10s
Rust development slice / linux (push) Failing after 1m10s
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
use prost::Message;
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct SyncRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub request_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub journal_id: String,
|
||||
#[prost(uint64, tag = "3")]
|
||||
pub checkpoint: u64,
|
||||
#[prost(string, tag = "4")]
|
||||
pub previous_decision_id: String,
|
||||
#[prost(uint64, tag = "5")]
|
||||
pub assignment_version: u64,
|
||||
#[prost(message, repeated, tag = "6")]
|
||||
pub attempts: Vec<SyncAttempt>,
|
||||
#[prost(string, repeated, tag = "7")]
|
||||
pub durable_message_ids: Vec<String>,
|
||||
#[prost(bool, tag = "8")]
|
||||
pub journal_complete: bool,
|
||||
#[prost(string, tag = "9")]
|
||||
pub helper_journal_id: String,
|
||||
#[prost(uint64, tag = "10")]
|
||||
pub helper_checkpoint: u64,
|
||||
#[prost(string, tag = "11")]
|
||||
pub helper_previous_decision_id: String,
|
||||
#[prost(string, tag = "12")]
|
||||
pub previous_request_id: String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct SyncAttempt {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub job_payload_hash: String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub grant_id: String,
|
||||
/// unconsumed | consumed | uncertain. No claim may reset a server reservation.
|
||||
#[prost(string, tag = "5")]
|
||||
pub consumption: String,
|
||||
#[prost(string, tag = "6")]
|
||||
pub state: String,
|
||||
#[prost(uint64, tag = "7")]
|
||||
pub revision: u64,
|
||||
#[prost(string, tag = "8")]
|
||||
pub original_boot_id: String,
|
||||
#[prost(message, optional, tag = "9")]
|
||||
pub result: Option<JobResult>,
|
||||
#[prost(string, tag = "10")]
|
||||
pub result_message_id: String,
|
||||
#[prost(string, tag = "11")]
|
||||
pub outcome_sha256: String,
|
||||
#[prost(bytes = "vec", tag = "12")]
|
||||
pub outcome_bytes: Vec<u8>,
|
||||
#[prost(message, optional, tag = "13")]
|
||||
pub result_envelope: Option<crate::Envelope>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct SyncResponse {
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub decision_bytes: Vec<u8>,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub signature: Vec<u8>,
|
||||
}
|
||||
/// payload_bytes is rmm_domain::jobs::JobPayload codec v1, hash exact bytes.
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct JobOffer {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub authorization_id: String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub plan_hash: String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub job_payload_hash: String,
|
||||
#[prost(bytes = "vec", tag = "6")]
|
||||
pub payload_bytes: Vec<u8>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct JobAccepted {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub job_payload_hash: String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub journal_proof: String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct ExecutionPermitRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub job_payload_hash: String,
|
||||
#[prost(uint64, tag = "4")]
|
||||
pub assignment_version: u64,
|
||||
}
|
||||
/// Fixed Ed25519; verify exact payload_bytes using separately provisioned key.
|
||||
/// Never trust a key conveyed by the gateway as its own trust anchor.
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct ExecutionPermit {
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub payload_bytes: Vec<u8>,
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub signature: Vec<u8>,
|
||||
#[prost(string, tag = "3")]
|
||||
pub denial_code: String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct JobStateChanged {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(uint64, tag = "3")]
|
||||
pub revision: u64,
|
||||
#[prost(string, tag = "4")]
|
||||
pub state: String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub grant_id: String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct JobResult {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(uint64, tag = "3")]
|
||||
pub revision: u64,
|
||||
#[prost(string, tag = "4")]
|
||||
pub state: String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub grant_id: String,
|
||||
#[prost(bytes = "vec", tag = "6")]
|
||||
pub stdout: Vec<u8>,
|
||||
#[prost(bytes = "vec", tag = "7")]
|
||||
pub stderr: Vec<u8>,
|
||||
#[prost(bool, tag = "8")]
|
||||
pub output_truncated: bool,
|
||||
#[prost(bool, tag = "9")]
|
||||
pub reboot_required: bool,
|
||||
#[prost(int32, optional, tag = "10")]
|
||||
pub exit_code: Option<i32>,
|
||||
#[prost(string, tag = "11")]
|
||||
pub evidence_json: String,
|
||||
#[prost(string, tag = "12")]
|
||||
pub error_code: String,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Message)]
|
||||
pub struct CancelRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub job_id: String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub attempt_id: String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub reason: String,
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn additive_job_offer_wire() {
|
||||
let offer = JobOffer {
|
||||
job_id: "j".into(),
|
||||
attempt_id: "a".into(),
|
||||
authorization_id: "h".into(),
|
||||
plan_hash: "p".into(),
|
||||
job_payload_hash: "b".into(),
|
||||
payload_bytes: vec![123, 125],
|
||||
};
|
||||
assert_eq!(
|
||||
offer.encode_to_vec(),
|
||||
vec![
|
||||
10, 1, 106, 18, 1, 97, 26, 1, 104, 34, 1, 112, 42, 1, 98, 50, 2, 123, 125
|
||||
]
|
||||
);
|
||||
let e = crate::Envelope {
|
||||
protocol_major: 1,
|
||||
payload: Some(crate::Payload::JobOffer(offer)),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(
|
||||
crate::Envelope::decode(e.encode_to_vec().as_slice()).unwrap(),
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user