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

fix: stop download on action timeout, don't drop action on resend #258

Merged
merged 4 commits into from
Jul 30, 2023

Conversation

de-sh
Copy link
Contributor

@de-sh de-sh commented Jul 25, 2023

Closes #

Changes

  1. Timeout downloads at expected timeout of action on bridge
  2. Don't clear action on unsuccessful re-send even if with same id

Why?

Downloader as of right now continues to run despite the action having timedout on bridge, leading to further action failures as download actions clog the channel into the downloader

Trials Performed

  1. Create http server accessible over toxiproxy.
echo '#!/bin.sh' > test.sh
echo 'echo "Hello, World!"' >> test.sh
python3 -m http.server 8000
curl --request POST \
  --url http://localhost:8474/proxies \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "script-server",
    "listen": "0.0.0.0:8001",
    "upstream": "localhost:8000",
    "enabled": true
}'
  1. Start uplink without auth.
# auth.json
{
  "project_id": "demo",
  "broker": "localhost",
  "port": 1883,
  "device_id":"1"
}
# config.toml
[downloader]
actions = [{ name = "send_script" }]
path = "/tmp/downloads"

  1. Send action to uplink that points to http sever.
mosquitto_pub -t /tenants/demo/devices/1/actions -m '{ "action_id":
 "1", "kind": "process", "name": "send_script", "payload": "{\"file_n
ame\":\"test.sh\",\"content-length\":31,\"id\":\"123\",\"url\":\"http
://0.0.0.0:8001/test.sh\"}" }'
  1. Ensure at normal speeds this doesn't trigger failure.
  2. Repeat step 3 with extremely slow speed access, see if this triggers failure and download continues to run despite action timeout in bridge.
  2023-07-25T16:18:02.531840Z ERROR uplink::collector::downloader: Last download has timedout

  2023-07-25T16:18:02.532611Z ERROR uplink::base::bridge: Timeout waiting for action response. Action ID = 1

@de-sh de-sh marked this pull request as ready for review July 25, 2023 16:20
@de-sh de-sh requested a review from tekjar July 25, 2023 16:20
@de-sh de-sh merged commit 24a1034 into main Jul 30, 2023
2 checks passed
@de-sh de-sh deleted the download-timeout branch July 30, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant