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

Add an option to pause webhooks #7223

Open
3 of 6 tasks
KrishnaIyer opened this issue Aug 6, 2024 · 5 comments
Open
3 of 6 tasks

Add an option to pause webhooks #7223

KrishnaIyer opened this issue Aug 6, 2024 · 5 comments
Assignees
Labels
c/application server This is related to the Application Server c/console This is related to the Console needs/ux This needs UX design / approval
Milestone

Comments

@KrishnaIyer
Copy link
Member

Summary

Add an option to pause webhooks.

Current Situation

Currently, the only way to stop a webhook is to delete it (or if it's unhealthy and we set a threshold to stop it).

Why do we need this? Who uses it, and when?

This can be very useful for testing where users can pause webhooks while the external server is being updated without needing to delete them.

Proposed Implementation

I'll get back here when we get this into a milestone.

Contributing

  • I can help by doing more research.
  • I can help by implementing the feature after the proposal above is approved.
  • I can help by testing the feature before it's released.

Validation

Code of Conduct

@KrishnaIyer KrishnaIyer added this to the Backlog milestone Aug 6, 2024
@github-actions github-actions bot added the needs/triage We still need to triage this label Aug 6, 2024
@KrishnaIyer KrishnaIyer removed the needs/triage We still need to triage this label Aug 8, 2024
@vlasebian vlasebian added the c/application server This is related to the Application Server label Aug 22, 2024
@KrishnaIyer KrishnaIyer modified the milestones: Backlog, v3.32.1 Aug 28, 2024
@KrishnaIyer KrishnaIyer added the in progress We're working on it label Aug 28, 2024
@KrishnaIyer KrishnaIyer added the needs/testing This needs to be tested on staging label Sep 5, 2024
@vlasebian
Copy link
Contributor

vlasebian commented Sep 12, 2024

Tested on staging1 as follows:

Prerequisites:

  • Create an app on staging1
  • Connect a generic node to the app
  • Login the CLI tool to the staging environment

Steps:

  • Create a webhook in the console, use a webhook site to see the requests (e.g webhook.site)
    • Enable uplinks for the webhook
    • Enable downlink acks for the webhook
      After the webhook is created, requests are going to be sent to the webhook site every time an uplink is sent.
  • Pause the webhook using the cli tool:
go run ./cmd/ttn-lw-cli --config .env/configs/staging1.yml app webhooks get vv-play wh1
WARN	No fields selected, will select everything
{
  "ids": {
    "application_ids": {
      "application_id": "vv-play"
    },
    "webhook_id": "wh1"
  },
  "created_at": "2024-09-12T08:09:47.311512669Z",
  "updated_at": "2024-09-12T08:11:35.323370856Z",
  "base_url": "https://webhook-test.com/87adc5fb8ac89205940ec603dbb218b9",
  "format": "json",
  "uplink_message": {},
  "health_status": {
    "healthy": {}
  },
  "field_mask": {
    "paths": []
  }
}

go run ./cmd/ttn-lw-cli --config .env/configs/staging1.yml app webhooks set vv-play wh1 --paused
{
  "ids": {
    "application_ids": {
      "application_id": "vv-play"
    },
    "webhook_id": "wh1"
  },
  "created_at": "2024-09-12T08:09:47.311512669Z",
  "updated_at": "2024-09-12T08:12:17.238958811Z",
  "base_url": "https://webhook-test.com/87adc5fb8ac89205940ec603dbb218b9",
  "format": "json",
  "paused": true
}
  • Requests to the webhook site are stopped
  • Enable the webhook again:
go run ./cmd/ttn-lw-cli --config .env/configs/staging1.yml app webhooks set vv-play wh1 --paused=false
{
  "ids": {
    "application_ids": {
      "application_id": "vv-play"
    },
    "webhook_id": "wh1"
  },
  "created_at": "2024-09-12T08:09:47.311512669Z",
  "updated_at": "2024-09-12T09:42:22.976790526Z",
  "base_url": "https://webhook-test.com/87adc5fb8ac89205940ec603dbb218b9",
  "format": "json"
}
  • Requests to the webhook site are resumed

I also checked the same steps, but with API calls instead of the CLI tool:

curl -X PUT "https://tti.staging1.cloud.thethings.industries/api/v3/as/webhooks/$APP/$WEBHOOK" \
  -H "Authorization: $TTN_STAGING_AUTH_TOKEN" \
  -d '{
  "webhook": {
    "ids":{ "webhook_id": "'"$WEBHOOK"'" },
    "paused": '"$PAUSED"',
    "field_mask":{"paths":[]},
    "format":"json"
  },
  "field_mask": {
    "paths": [
      "ids.webhook_id",
      "paused",
      "field_mask",
      "format"
      ]
    }
  }'

Response:

{"ids":{"application_ids":{"application_id":"vv-play"},"webhook_id":"wh1"},"created_at":"2024-09-12T08:09:47.311512669Z","updated_at":"2024-09-12T08:16:03.259567478Z","base_url":"https://webhook-test.com/87adc5fb8ac89205940ec603dbb218b9","format":"json","field_mask":{"paths":[]}}

EDIT: setting the paused flag from the CLI works too, I was just passing it wrong (I was doing --paused false instead of --paused=false).

@KrishnaIyer
Copy link
Member Author

Ok thanks. This is great. I'll add a note here for UX and console support.

@KrishnaIyer KrishnaIyer added c/console This is related to the Console needs/ux This needs UX design / approval and removed in progress We're working on it needs/testing This needs to be tested on staging labels Sep 12, 2024
@KrishnaIyer KrishnaIyer modified the milestones: v3.32.1, v3.32.2 Sep 12, 2024
@pierrephz pierrephz self-assigned this Oct 14, 2024
@pierrephz
Copy link
Contributor

Here are some wireframe and user flow to pause / run a webhook:

  1. On the webhook list: hover the webhook you want and you will see a Pause button
  2. A dialog will pop to ask you to confirm Pause (since this action can cause unwanted effects)
  3. A new Paused status is set in the Status column
  4. When hovering this webhook again, the button will now be a Run button

Wireframes:

Screenshot 2024-10-16 at 11 36 35 Screenshot 2024-10-16 at 11 36 52 Screenshot 2024-10-16 at 11 37 01 Screenshot 2024-10-16 at 11 40 31

@KrishnaIyer
Copy link
Member Author

This looks good. Only one small comment.

The text for the Pause Webhook dialog should be: The Things Stack will not send webhooks to the configured end point until this setting is disabled. Are you sure you want to do this?

@KrishnaIyer
Copy link
Member Author

@mjamescompton for the implementation.

@KrishnaIyer KrishnaIyer modified the milestones: v3.32.2, v3.33.0 Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/application server This is related to the Application Server c/console This is related to the Console needs/ux This needs UX design / approval
Projects
None yet
Development

No branches or pull requests

4 participants