Repository navigation
Description
we've been trying to setup gogs which uses github style webhooks so that a git push in gogs results in a new build in OpenShift. There's no errors in openshift but the webhook request is ignored.
However we can use the webhook REST API (generic) without passing any payload and it works fine - a build is actually triggered. (We use this in hawtio-kubernetes to trigger new builds and it works fine).
However both github and gogs post a blob of JSON when they fire a webhook which seems to not get parsed correctly by OpenShift meaning the webhook doesn't result in a new build and there's no error in the log to indicate whats wrong.
Its far better if in doubt, to trigger a new build. I can imagine various git / scm hosting solutions posting various JSON blobs & its better to assume its a well intentioned attempt to trigger a build than just ignore the request and not to log any useful information about why the request was ignored ;)
So can we either:
- make the webhook work even if the code can't parse the JSON correctly (despite it being valid JSON - just not of the expected shape)
- have a new webhook API (or query argument) which ignores the payload if any is posted and just trigger a new build?
Ideally having better logging would help too so that we've a clue trying to diagnose why webhooks don't work; there's no errors in the openshift log right now when gogs invokes it.
FWIW here's an example blob of JSON sent from gogs:
{
"secret":"secret101",
"ref": "refs/heads/master",
"commits": [{
"id": "0330eeb868d42499ecfad174f415aabd166f16af",
"message": "testing webhook\n",
"url": "http://localhost:3000/jstrachan/lager1/commit/0330eeb868d42499ecfad174f415aabd166f16af",
"author": {
"name": "James Strachan",
"email": "[email protected]",
"username": "jstrachan"
}
}],
"repository": {
"id": 2,
"name": "lager1",
"url": "http://localhost:3000/jstrachan/lager1",
"description": "",
"website": "",
"watchers": 1,
"owner": {
"name": "jstrachan",
"email": "[email protected]",
"username": "jstrachan"
},
"private": false
},
"pusher": {
"name": "jstrachan",
"email": "[email protected]",
"username": "jstrachan"
},
"before": "826aa9e6424006faff9440b4cd336aaf72de8136",
"after": "0330eeb868d42499ecfad174f415aabd166f16af",
"compare_url": "http://localhost:3000/jstrachan/lager1/compare/826aa9e6424006faff9440b4cd336aaf72de8136...0330eeb868d42499ecfad174f415aabd166f16af"
}```
Activity
smarterclayton commentedon Mar 17, 2015
Are you using the generic webhook? That's what supports arbitrary schemas.
jstrachan commentedon Mar 17, 2015
Yes, generic webhook.
jstrachan commentedon Mar 17, 2015
Our workaround for now is to write a custom proxy to strip the JSON payload out and send an empty body so that we can get gogs to trigger builds on a git push
soltysh commentedon Mar 17, 2015
@jstrachan if you have a look at our webhook controller, you'll notice we're sending the error back to the source of the request (see here). The other things being checked besides json are listed here, this includes: POST, non-empty User-Agent and Content-Length headers. It would be helpful if you could provide us with full request being passed to OpenShift (including headers) as the json itself is not enough.
Re error logging see #1333
smarterclayton commentedon Mar 17, 2015
Generic web hooks should not fail if the JSON is invalid, period. We should log it, and move on.
----- Original Message -----
soltysh commentedon Mar 17, 2015
@smarterclayton updated PR with that behavior.
jimmidyson commentedon Apr 13, 2015
@soltysh - we've just tried that out with 0.4.3 & sadly this doesn't work. I guess something needs updating in webhook controller to work properly if there is no source revision available from the webhook payload?
jstrachan commentedon Apr 14, 2015
I was looking at the swagger for 0.4.3 and couldn't find the /osapi/v1beta1/buildConfigHooks/{name}/{secret}/{type} URI any more to trigger a build from a webhook but I spotted this URI:
Is this the new URL used to trigger a build? Only I couldn't seem to invoke it from 0.4.3; gets a 404 when I try use it. Maybe buildConfigHooks is still there it just isn't in swagger?
smarterclayton commentedon Apr 14, 2015
It's not in swagger yet - there's an issue open to move it into the framework that will allow that.
jstrachan commentedon Apr 14, 2015
@smarterclayton thanks!
jstrachan commentedon Apr 14, 2015
FWIW trying to POST to the webhook from java on 0.4.3 I get:
smarterclayton commentedon Apr 14, 2015
Hrm, that may be swagger setting that (since there's no response defined). Definitely a bug @soltysh
soltysh commentedon Apr 14, 2015
We should accept that, probably our accept logic is wrong, I guess our
acceptance for 'application/json' is hard coded. Definitely a bug.
On Tue, Apr 14, 2015 at 3:35 PM Clayton Coleman [email protected]
wrote:
smarterclayton commentedon Apr 14, 2015
Probably. We should be very flexible about what we accept, and log an error if it doesn't quite match the expected input (not fail).
----- Original Message -----
soltysh commentedon Apr 14, 2015
This will be related to #1480 as well, in that we should exactly the same
mechanism used here.
On Tue, Apr 14, 2015 at 5:43 PM, Clayton Coleman [email protected]
wrote:
soltysh commentedon May 8, 2015
@jstrachan looking carefully at our output there's one thing that bothers me:
We specifically expect
application/jsoncontent-type, but for some reason you (or your server) are setting it wrong. Could you please double check that. I just did small test with curl:But with
application/jsonit works just fine:smarterclayton commentedon May 8, 2015
We should probably not require a mime type - a generic web-hook is an endpoint you should be able to ping from anywhere
soltysh commentedon May 8, 2015
And parse contents of the body only if it matches the content-type? I'll start coding that right away.
smarterclayton commentedon May 8, 2015
Yeah, application/json is required to handle the body as a structured object.
----- Original Message -----
soltysh commentedon May 8, 2015
@jstrachan give it a try once again when #2136 gets merged and if it works, please close the issue. Thanks 😄
Squashed 'cmd/service-catalog/go/src/github.com/kubernetes-incubator/…
Add referential integrity check on ServiceBroker for Service/Plan (op…