Public dry run dryrun-7143846e2cca
This commit is contained in:
parent
13d4d524c4
commit
c8526c39ef
6 changed files with 335 additions and 39 deletions
|
|
@ -357,10 +357,10 @@ struct ProcessCancelArgs {
|
|||
scope: CliScopeArgs,
|
||||
#[arg(long, default_value = "vp-current")]
|
||||
process: String,
|
||||
#[arg(long, default_value = "node-local")]
|
||||
node: String,
|
||||
#[arg(long, default_value = "compile-linux")]
|
||||
task: String,
|
||||
#[arg(long)]
|
||||
node: Option<String>,
|
||||
#[arg(long)]
|
||||
task: Option<String>,
|
||||
#[arg(long)]
|
||||
yes: bool,
|
||||
}
|
||||
|
|
@ -1150,12 +1150,11 @@ fn process_cancel_report(args: ProcessCancelArgs) -> Result<Value> {
|
|||
if let Some(coordinator) = &args.scope.coordinator {
|
||||
let mut session = JsonLineSession::connect(coordinator)?;
|
||||
let response = session.request(json!({
|
||||
"type": "cancel_task",
|
||||
"type": "cancel_process",
|
||||
"tenant": args.scope.tenant,
|
||||
"project": args.scope.project,
|
||||
"actor_user": args.scope.user,
|
||||
"process": args.process,
|
||||
"node": args.node,
|
||||
"task": args.task,
|
||||
}))?;
|
||||
let cancel_request = process_cancel_request_summary(&response, !args.yes);
|
||||
return Ok(json!({
|
||||
|
|
@ -1179,8 +1178,8 @@ fn process_cancel_report(args: ProcessCancelArgs) -> Result<Value> {
|
|||
"task": args.task,
|
||||
"cancel_request": {
|
||||
"status": "requires_coordinator",
|
||||
"operation": "task_scoped_cancel",
|
||||
"whole_process_cancel_available": false,
|
||||
"operation": "cancel_virtual_process",
|
||||
"whole_process_cancel_available": true,
|
||||
"explicit_user_action": true,
|
||||
},
|
||||
}))
|
||||
|
|
@ -2393,30 +2392,37 @@ fn process_restart_request_summary(response: &Value, requires_confirmation: bool
|
|||
}
|
||||
|
||||
fn process_cancel_request_summary(response: &Value, requires_confirmation: bool) -> Value {
|
||||
if response.get("type").and_then(Value::as_str) != Some("task_cancellation_requested") {
|
||||
if response.get("type").and_then(Value::as_str) != Some("process_cancellation_requested") {
|
||||
return json!({
|
||||
"status": response.get("type").and_then(Value::as_str).unwrap_or("coordinator_response"),
|
||||
"operation": "task_scoped_cancel",
|
||||
"operation": "cancel_virtual_process",
|
||||
"accepted": false,
|
||||
"requires_confirmation": requires_confirmation,
|
||||
"explicit_user_action": true,
|
||||
"whole_process_cancel_available": false,
|
||||
"whole_process_cancel_available": true,
|
||||
"error": response.get("message").cloned().unwrap_or(Value::Null),
|
||||
});
|
||||
}
|
||||
|
||||
let cancelled_tasks = response
|
||||
.get("cancelled_tasks")
|
||||
.and_then(Value::as_array)
|
||||
.map(Vec::len)
|
||||
.unwrap_or(0);
|
||||
json!({
|
||||
"status": "task_cancellation_requested",
|
||||
"operation": "task_scoped_cancel",
|
||||
"status": "process_cancellation_requested",
|
||||
"operation": "cancel_virtual_process",
|
||||
"accepted": true,
|
||||
"process": response.get("process").cloned().unwrap_or(Value::Null),
|
||||
"task": response.get("task").cloned().unwrap_or(Value::Null),
|
||||
"node": response.get("node").cloned().unwrap_or(Value::Null),
|
||||
"cancelled_task_count": cancelled_tasks,
|
||||
"cancelled_tasks": response.get("cancelled_tasks").cloned().unwrap_or_else(|| json!([])),
|
||||
"affected_nodes": response.get("affected_nodes").cloned().unwrap_or_else(|| json!([])),
|
||||
"requires_confirmation": requires_confirmation,
|
||||
"explicit_user_action": true,
|
||||
"website_required": false,
|
||||
"whole_process_cancel_available": false,
|
||||
"whole_process_cancel_available": true,
|
||||
"node_must_poll_task_control": true,
|
||||
"new_task_launches_blocked": true,
|
||||
"surviving_state_visibility": "task and artifact state remains visible after terminal task events are reported",
|
||||
})
|
||||
}
|
||||
|
|
@ -4505,8 +4511,8 @@ mod tests {
|
|||
let addr = listener.local_addr().unwrap().to_string();
|
||||
let server = std::thread::spawn(move || {
|
||||
let restart_response = r#"{"type":"process_started","process":"vp","epoch":42}"#;
|
||||
let cancel_response = r#"{"type":"task_cancellation_requested","process":"vp","task":"compile-linux","node":"node-a"}"#;
|
||||
for expected in ["start_process", "cancel_task"] {
|
||||
let cancel_response = r#"{"type":"process_cancellation_requested","process":"vp","cancelled_tasks":[{"process":"vp","task":"compile-linux","node":"node-a"},{"process":"vp","task":"link-linux","node":"node-b"}],"affected_nodes":["node-a","node-b"]}"#;
|
||||
for expected in ["start_process", "cancel_process"] {
|
||||
let (mut stream, _) = listener.accept().unwrap();
|
||||
let mut reader = BufReader::new(stream.try_clone().unwrap());
|
||||
let mut line = String::new();
|
||||
|
|
@ -4518,8 +4524,7 @@ mod tests {
|
|||
if expected == "start_process" {
|
||||
stream.write_all(restart_response.as_bytes()).unwrap();
|
||||
} else {
|
||||
assert!(line.contains(r#""node":"node-a""#));
|
||||
assert!(line.contains(r#""task":"compile-linux""#));
|
||||
assert!(line.contains(r#""actor_user":"user""#));
|
||||
stream.write_all(cancel_response.as_bytes()).unwrap();
|
||||
}
|
||||
stream.write_all(b"\n").unwrap();
|
||||
|
|
@ -4542,8 +4547,8 @@ mod tests {
|
|||
let cancel = process_cancel_report(ProcessCancelArgs {
|
||||
scope,
|
||||
process: "vp".to_owned(),
|
||||
node: "node-a".to_owned(),
|
||||
task: "compile-linux".to_owned(),
|
||||
node: None,
|
||||
task: None,
|
||||
yes: false,
|
||||
})
|
||||
.unwrap();
|
||||
|
|
@ -4562,23 +4567,31 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
cancel["cancel_request"]["status"],
|
||||
"task_cancellation_requested"
|
||||
"process_cancellation_requested"
|
||||
);
|
||||
assert_eq!(
|
||||
cancel["cancel_request"]["operation"],
|
||||
"cancel_virtual_process"
|
||||
);
|
||||
assert_eq!(cancel["cancel_request"]["operation"], "task_scoped_cancel");
|
||||
assert_eq!(cancel["cancel_request"]["accepted"], true);
|
||||
assert_eq!(cancel["cancel_request"]["process"], "vp");
|
||||
assert_eq!(cancel["cancel_request"]["task"], "compile-linux");
|
||||
assert_eq!(cancel["cancel_request"]["node"], "node-a");
|
||||
assert_eq!(cancel["cancel_request"]["cancelled_task_count"], 2);
|
||||
assert_eq!(
|
||||
cancel["cancel_request"]["cancelled_tasks"][0]["task"],
|
||||
"compile-linux"
|
||||
);
|
||||
assert_eq!(cancel["cancel_request"]["affected_nodes"][1], "node-b");
|
||||
assert_eq!(cancel["cancel_request"]["requires_confirmation"], true);
|
||||
assert_eq!(cancel["cancel_request"]["website_required"], false);
|
||||
assert_eq!(
|
||||
cancel["cancel_request"]["whole_process_cancel_available"],
|
||||
false
|
||||
true
|
||||
);
|
||||
assert_eq!(
|
||||
cancel["cancel_request"]["node_must_poll_task_control"],
|
||||
true
|
||||
);
|
||||
assert_eq!(cancel["cancel_request"]["new_task_launches_blocked"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -4628,8 +4641,8 @@ mod tests {
|
|||
let cancel = process_cancel_report(ProcessCancelArgs {
|
||||
scope,
|
||||
process: "vp".to_owned(),
|
||||
node: "node".to_owned(),
|
||||
task: "compile-linux".to_owned(),
|
||||
node: None,
|
||||
task: None,
|
||||
yes: false,
|
||||
})
|
||||
.unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue