apache / openwhisk-catalog

Curated catalog of Apache OpenWhisk packages to interface with event producers and consumers
https://openwhisk.apache.org/
Apache License 2.0
33 stars 49 forks source link

Github is failing to clean up webhooks during DELETE lifecycle #252

Open eweiter opened 6 years ago

eweiter commented 6 years ago

I was using the IBM Cloud Functions UI and I noticed the following behavior for Github trigger.

When I would create a trigger it would appear to create the Trigger and the Feed fine. The feed calls response was: {"duration":589,"name":"webhook","subject":"eweiter@us.ibm.com","activationId":"e8ec3315288c4457ac3315288cf457d1","publish":false,"annotations":[{"key":"path","value":"whisk.system/github/webhook"},{"key":"waitTime","value":37},{"key":"kind","value":"nodejs:6"},{"key":"limits","value":{"timeout":60000,"memory":256,"logs":10}},{"key":"initTime","value":249}],"version":"0.0.264","response":{"result":{"response":"{\"type\":\"Repository\",\"id\":20159188,\"name\":\"web\",\"active\":true,\"events\":[\"push\"],\"config\":{\"url\":\"https://xxx:yyy@10.121.10.111:443/api/v1/namespaces/eweiter%40us.ibm.com_dev/triggers/JasonTest\",\"content_type\":\"json\",\"insecure_ssl\":\"0\"},\"updated_at\":\"2018-01-16T17:52:37Z\",\"created_at\":\"2018-01-16T17:52:37Z\",\"url\":\"https://api.github.com/repos/eweiter/bumblefoot/hooks/20159188\",\"test_url\":\"https://api.github.com/repos/eweiter/bumblefoot/hooks/20159188/test\",\"ping_url\":\"https://api.github.com/repos/eweiter/bumblefoot/hooks/20159188/pings\",\"last_response\":{\"code\":null,\"status\":\"unused\",\"message\":null}}"},"success":true,"status":"success"},"end":1516125157900,"logs":[],"start":1516125157311,"namespace":"eweiter@us.ibm.com_dev"} To me it is showing that a "Push" event was created and that it is Active.

However when I go to delete that Trigger, the Feed deletion encounters an error. The Feed deletion response was: {"duration":207,"name":"webhook","subject":"eweiter@us.ibm.com","activationId":"6a3da00bcc7448e6bda00bcc7438e60d","publish":false,"annotations":[{"key":"limits","value":{"timeout":60000,"memory":256,"logs":10}},{"key":"path","value":"whisk.system/github/webhook"},{"key":"kind","value":"nodejs:6"},{"key":"waitTime","value":23}],"version":"0.0.264","response":{"result":{"error":"Found no existing webhooks for trigger URL https://xxx:yyy@10.121.10.111:443/api/v1/namespaces/eweiter%40us.ibm.com_dev/triggers/JasonTest"},"success":false,"status":"application error"},"end":1516125185130,"logs":[],"start":1516125184923,"namespace":"eweiter@us.ibm.com_dev"} Where it is telling me that it couldn't find any hooks on that trigger to delete and it is returning a status code of 502.

Steps to recreate: 1) Create a Trigger with the Github feed using the "push" event 2) Delete the Trigger

prabhashthere commented 6 years ago

This happens if we edit the generated webhook manually from the GitHub site. Sometimes the callBackUrl will be slightly changed if you just pressed the edit button of the webhook (whether you did any changes or not).

The callBackUrl which GitHub package sends to create the webhook includes the TCP port name 443. But if we try to edit the webhook, GitHub will remove the port name (which is not mandatorily needed to find the trigger location) from the callBackUrl. When the package tries to delete the webhook, they look for the previous callbackUrl and it is not available anymore causing a failure in deleting the webhook. If we can update the git package to generate the callBackUrl without the port name, then we can mitigate this problem.

Example callBackUrls before edit: https://auth@apihost:443/api/v1/namespaces/_/triggers/myGitTrigger after edit: https://auth@apihost/api/v1/namespaces/_/triggers/myGitTrigger