Watch
0
0
Fork
You've already forked hyperhive
0

swarm-nats-auth: let the controller list the bash task statuses

This commit is contained in:
damocles 2026-11-16 01:18:22 +01:00 • committed by mara
commit 802151820c
2 changed files with 23 additions and 0 deletions

View file

@ -844,6 +844,14 @@ impl Policy {
"$JS.API.CONSUMER.CREATE.{}", "$JS.API.CONSUMER.CREATE.{}",
swarm_wire::agent_permissions::STREAM swarm_wire::agent_permissions::STREAM
)); ));
// The bash task statuses, listed the same way: the task list calls
// `keys()` for an agent's tasks. Without this subject the create
// request is refused and reaches the client as a timeout, so the list
// timed out every time.
subjects.push(format!(
"$JS.API.CONSUMER.CREATE.{}",
swarm_wire::bash_task::STREAM
));
subjects subjects
} }
} }
@ -917,6 +925,18 @@ mod tests {
); );
} }
#[test]
fn the_reader_can_list_the_bash_task_statuses_and_no_other_stream() {
let subjects = policy().reader_subjects();
let s = swarm_wire::bash_task::STREAM;
// The bare form is what `keys()` needs: its ephemeral consumer has
// no name.
assert!(subjects.contains(&format!("$JS.API.CONSUMER.CREATE.{s}")));
assert!(!subjects.contains(&format!("$JS.API.CONSUMER.CREATE.{s}.>")));
assert!(!subjects.contains(&"$JS.API.CONSUMER.CREATE.*".to_owned()));
assert_eq!(s, format!("KV_{}", swarm_wire::bash_task::BUCKET));
}
#[test] #[test]
fn no_hive_may_write_another_role_s_agent_status() { fn no_hive_may_write_another_role_s_agent_status() {
// A hive publishes its *own* agents' status under // A hive publishes its *own* agents' status under

View file

@ -26,6 +26,9 @@ use crate::TERM_SUBJECT_PREFIX;
/// The KV bucket the task statuses are published into. /// The KV bucket the task statuses are published into.
pub const BUCKET: &str = "bash-task-status"; pub const BUCKET: &str = "bash-task-status";
/// The stream backing [`BUCKET`]. `create_key_value` prefixes `KV_`.
pub const STREAM: &str = "KV_bash-task-status";
/// How often the writer republishes a `running` status while the task's /// How often the writer republishes a `running` status while the task's
/// process lives, so a writer that died shows up as stale. /// process lives, so a writer that died shows up as stale.
pub const HEARTBEAT_S: i64 = 60; pub const HEARTBEAT_S: i64 = 60;