rancher / fleet

Deploy workloads from Git to large fleets of Kubernetes clusters
https://fleet.rancher.io/
Apache License 2.0
1.52k stars 229 forks source link

[forward] Azure Webhook Support [SURE-7047] #1974

Closed manno closed 5 months ago

manno commented 11 months ago

forwardport of https://github.com/rancher/fleet/issues/1997

manno commented 11 months ago

/forwardport v2.9.0 release/v0.9

manno commented 11 months ago

/backport v2.9.0 release/v0.9

raulcabello commented 10 months ago

QA Template

Solution

Add webhook support for Azure Webhooks. It works the same way as existing webhooks for GitHub, Gitlab and BitBucket

Testing

Additional notes

thehejik commented 6 months ago

Seems this is working with private Azure HTTPS repo but there are two issues:

thehejik commented 5 months ago

Test report

I successfully re-validated Azure devops Webhook support on rancher:v2.9-head with fleet:104.0.0+up0.10.0-rc.15. Tested were

both were deployed on fleet-default namespace with and without webhook BASIC auth enabled. For testing I used new gitrepo flag spec.disablePolling: true.

For enabling webhook payload visibility in gitjob logs I created fleet entry in rancher-config configmap with multi-line entry:

debug: true
debugLevel: 1

Only know problem I spotted is not so nice stacktrace when webhook credentials doesn't match with those defined in webhook secret defined by kubectl create secret generic gitjob-webhook -n cattle-fleet-system --from-literal=azure-username=user --from-literal=azure-password=password:

2024-06-17T12:31:02Z    DEBUG   webhook Webhook payload {"payload": null}
2024-06-17T12:31:02Z    ERROR   webhook Webhook processing failed   {"error": "basic auth verification failed"}
github.com/rancher/fleet/pkg/webhook.(*Webhook).logAndReturn
    /home/runner/work/fleet/fleet/pkg/webhook/webhook.go:301
github.com/rancher/fleet/pkg/webhook.(*Webhook).ServeHTTP
    /home/runner/work/fleet/fleet/pkg/webhook/webhook.go:183
github.com/gorilla/mux.(*Router).ServeHTTP
    /home/runner/go/pkg/mod/github.com/gorilla/mux@v1.8.1/mux.go:212
net/http.serverHandler.ServeHTTP
    /opt/hostedtoolcache/go/1.22.4/x64/src/net/http/server.go:3137
net/http.(*conn).serve
    /opt/hostedtoolcache/go/1.22.4/x64/src/net/http/server.go:2039

Closing as we know how to enabled verbose logs for webhook payloads in gitjob pod in rancher and the issue for the stacktrace is reported.