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

Event rule and webhook not triggered for branch reversion #81

Open
mrmrcoleman opened this issue Sep 6, 2024 · 5 comments · Fixed by #92
Open

Event rule and webhook not triggered for branch reversion #81

mrmrcoleman opened this issue Sep 6, 2024 · 5 comments · Fixed by #92
Assignees
Labels
app: branching type: bug A confirmed report of unexpected behavior in the application

Comments

@mrmrcoleman
Copy link

mrmrcoleman commented Sep 6, 2024

Plugin Version

0.3.1

NetBox Version

Release v4.1-beta1

Python Version

3.10

Steps to Reproduce

  1. Create a Webhook called "Branch Merged"
  2. Create an event rule with Object Types "NetBox Branching -> Branch" and Event Types "Branch merged"
  3. Point the event rule at Webhook "Branch Merged"
  4. Create a branch and then merge it

Expected Behavior

I expect to receive a webhook for the Branch Merged event

Observed Behavior

No webhook is received for the Branch Merged event

Notes:

@mrmrcoleman mrmrcoleman added the type: bug A confirmed report of unexpected behavior in the application label Sep 6, 2024
@jeremystretch
Copy link
Contributor

I wasn't able to reproduce this on v0.4.0 with NetBox v4.1.0, however I did notice that triggering an event rule for the revert event is broken. All the other events (provision, sync, merge, and deprovision) appear to work as intended.

It's likely that some change either in the plugin or in NetBox v4.1 has addressed the issue with the merge event.

@jeremystretch jeremystretch changed the title Event rule and webhook not triggered for branch merge Event rule and webhook not triggered for branch reversion Sep 6, 2024
@jeremystretch jeremystretch self-assigned this Sep 6, 2024
@mrmrcoleman
Copy link
Author

mrmrcoleman commented Sep 9, 2024

I still don't see branch merge events.

NetBox Version: 4.1
Branching Plugin Version: 0.4.0

Reproduce steps

  • Create a webhook
  • Create an event rule on Branching and select all event types, then point it at the webhook
  • Create a branch
  • Add a site to the branch
  • Merge the branch

Expected output

Create Branch

Object Creation event (Branch)
Job Started event
Job Ended event

Merge Branch

Branch merged event
Job Started event
Job Ended event

Actual Output

When merging the branch I only see the Job Started and Job Ended events, not the Branch merged event

@mrmrcoleman
Copy link
Author

We discussed the posibility of rate limiting or other issues with the webhooks exiting the testing VM. To rule that out I ran the Django webhook test endpoint on the machine locally manage.py webhook_recevier

The expected webhooks still don't arrive, even when being sent to localhost:9000

Revert

[1] Mon, 09 Sep 2024 19:32:31 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 147

{
  "event": "job_started",
  "timestamp": "2024-09-09T19:32:30.638191+00:00",
  "model": "branch",
  "username": "admin",
  "request_id": null,
  "data": null
}
Completed request #1
------------
[2] Mon, 09 Sep 2024 19:32:31 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 365

{
  "event": "job_ended",
  "timestamp": "2024-09-09T19:32:30.984506+00:00",
  "model": "branch",
  "username": "admin",
  "request_id": null,
  "data": {
    "log": [
      "Reverting branch MergeWebhookTest (branch_0w5algh5)",
      "Found 1 changes to revert",
      "Setting branch status to reverting",
      "Setting branch status to ready",
      "Recording branch event: reverted",
      "Reversion completed"
    ]
  }
}
Completed request #2

Merge

[3] Mon, 09 Sep 2024 19:33:35 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 147

{
  "event": "job_started",
  "timestamp": "2024-09-09T19:33:35.479234+00:00",
  "model": "branch",
  "username": "admin",
  "request_id": null,
  "data": null
}
Completed request #3
------------
[4] Mon, 09 Sep 2024 19:33:35 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 357

{
  "event": "job_ended",
  "timestamp": "2024-09-09T19:33:35.774954+00:00",
  "model": "branch",
  "username": "admin",
  "request_id": null,
  "data": {
    "log": [
      "Merging branch MergeWebhookTest (branch_0w5algh5)",
      "Found 1 changes to merge",
      "Setting branch status to merging",
      "Setting branch status to merged",
      "Recording branch event: merged",
      "Merging completed"
    ]
  }
}
Completed request #4
------------

@mrmrcoleman
Copy link
Author

Retested this on 4.1.1 and 0.5.0 using the method above and I still don't see webhooks for merge or revert.

@mrmrcoleman mrmrcoleman reopened this Sep 18, 2024
@jeremystretch
Copy link
Contributor

I'm still not able to reproduce this using v0.5.0 of the plugin and NetBox v4.1.1. Here's the output from webhook_worker showing the provision, merge, and revert operations (I did not enable triggers for object creations or job starts/stops in my rule as we know those work):

[1] Thu, 19 Sep 2024 13:49:37 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 444

{
    "event": "branch_provisioned",
    "timestamp": "2024-09-19T13:49:37.486356+00:00",
    "model": "branch",
    "username": "admin",
    "request_id": null,
    "data": {
        "created": "2024-09-19T13:49:31.938Z",
        "last_updated": "2024-09-19T13:49:31.938Z",
        "description": "",
        "comments": "",
        "name": "Branch 3",
        "owner": 1,
        "schema_id": "68yw7uvk",
        "status": "new",
        "last_sync": null,
        "merged_time": null,
        "merged_by": null,
        "custom_fields": {},
        "tags": [],
        "id": 14
    }
}
Completed request #1
------------
[2] Thu, 19 Sep 2024 13:50:46 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 461

{
    "event": "branch_merged",
    "timestamp": "2024-09-19T13:50:46.614627+00:00",
    "model": "branch",
    "username": "admin",
    "request_id": null,
    "data": {
        "created": "2024-09-19T13:49:31.938Z",
        "last_updated": "2024-09-19T13:50:46.603Z",
        "description": "",
        "comments": "",
        "name": "Branch 3",
        "owner": 1,
        "schema_id": "68yw7uvk",
        "status": "merged",
        "last_sync": null,
        "merged_time": "2024-09-19T13:50:46.603Z",
        "merged_by": 1,
        "custom_fields": {},
        "tags": [],
        "id": 14
    }
}
Completed request #2
------------
[3] Thu, 19 Sep 2024 13:50:53 GMT 127.0.0.1 "POST / HTTP/1.1" 200 -
Host: localhost:9000
Accept-Encoding: identity
User-Agent: python-urllib3/2.2.2
Content-Type: application/json
Content-Length: 443

{
    "event": "branch_reverted",
    "timestamp": "2024-09-19T13:50:53.123097+00:00",
    "model": "branch",
    "username": "admin",
    "request_id": null,
    "data": {
        "created": "2024-09-19T13:49:31.938Z",
        "last_updated": "2024-09-19T13:50:53.112Z",
        "description": "",
        "comments": "",
        "name": "Branch 3",
        "owner": 1,
        "schema_id": "68yw7uvk",
        "status": "ready",
        "last_sync": null,
        "merged_time": null,
        "merged_by": null,
        "custom_fields": {},
        "tags": [],
        "id": 14
    }
}
Completed request #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app: branching type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants