Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: action cancellation #339

Merged
merged 27 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6126b4e
feat: enable cancellations in downloader
Apr 4, 2024
3f795dd
feat: handle `cancel-action` in bridge
Apr 4, 2024
08d8cab
set `cancelled_by` even for actions in cancellable stages
Apr 4, 2024
41c574f
cancelled download must be updated to bridge
Apr 4, 2024
91a8b8c
Merge branch 'main' into cancellation
Apr 4, 2024
96dfbb0
Merge branch 'main' into cancellation
Apr 5, 2024
33a8706
chore: cleanup imports
Apr 24, 2024
2cf547a
refactor: action timeouts with cancel-action triggered by bridge
Apr 24, 2024
b6d480e
refactor: remove extra checks
May 15, 2024
f9666e9
fix: use cancellation to figure out route
May 15, 2024
c2116ce
fix: `cancel-action` ~> `cancel_action`
May 15, 2024
b867427
panic with message
May 15, 2024
623500d
Merge remote-tracking branch 'origin/main' into cancellation
May 15, 2024
ca2d835
chore: cargo fmt
May 16, 2024
0e71325
refactor: action existence check
May 16, 2024
b7a8104
ignore responses to timeout actions as they are internal only
May 16, 2024
b7075d3
fix: action might have been redirected
May 21, 2024
9d08d0b
cancellation `received` response
May 27, 2024
6f4df44
refactor: error only needs `action_id`
May 27, 2024
a52d1c3
refactor: store only `action_id` for cancellations
May 27, 2024
34ed571
refactor: don't copy action where only id is required
May 27, 2024
8a7d311
drop the `CurrentAction.id` field
May 27, 2024
5d7e4da
refactor: rm current action clone
May 27, 2024
15edaa4
`name` ~> `action_name`
May 27, 2024
e9fa4fe
ci: clippy suggestion
May 27, 2024
a8496e9
fix: cancel actions can be responded to when another action is in exe…
May 27, 2024
74aec45
refactor: shortcircuit forwards
May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ action_redirections = { "firmware_update" = "install_update", "send_file" = "loa

# Script runner allows users to trigger an action that will run an already downloaded
# file as described by the download_path field of the JSON payload of a download action.
script_runner = [{ name = "run_script" }]
script_runner = [{ name = "run_script", timeout = 10 }]

# Location on disk for persisted streams to write backlogs into, also used to write
persistence_path = "/tmp/uplink/"
Expand Down Expand Up @@ -141,7 +141,7 @@ priority = 255
# - actions: List of actions names that can trigger the downloader, with configurable timeouts
# - path: Location in fs where the files are downloaded into
[downloader]
actions = [{ name = "update_firmware" }, { name = "send_file" }, { name = "send_script" }]
actions = [{ name = "update_firmware" }, { name = "send_file", timeout = 10 }, { name = "send_script" }]
path = "/var/tmp/ota-file"

# Configurations associated with the system stats module of uplink, if enabled
Expand Down
11 changes: 7 additions & 4 deletions uplink/src/base/actions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use serde::{Deserialize, Serialize};
use tokio::time::Instant;

use crate::{Payload, Point};

Expand All @@ -17,9 +16,6 @@ pub struct Action {
pub name: String,
// action payload. json. can be args/payload. depends on the invoked command
pub payload: String,
// Instant at which action must be timedout
#[serde(skip)]
pub deadline: Option<Instant>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -114,3 +110,10 @@ impl Point for ActionResponse {
self.timestamp
}
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Cancellation {
pub action_id: String,
#[serde(rename = "name")]
pub action_name: String,
}
Loading
Loading