Skip to content

fix: improve logging for webhook debugging - #5

Open
twallac10 wants to merge 6 commits into
feature/atomic-munching-donutfrom
fix/improve-debugging-logs
Open

fix: improve logging for webhook debugging#5
twallac10 wants to merge 6 commits into
feature/atomic-munching-donutfrom
fix/improve-debugging-logs

Conversation

@twallac10

Copy link
Copy Markdown
Contributor

Summary

  • Add debug-level (V1) request entry logging to webhook handler — logs method, path, content-length, remote-addr on every request
  • Log HMAC validation failure details (header presence, signature length, body length) instead of a bare "invalid" message
  • Log filtered/ignored events with reason, kind, name, namespace at debug level
  • Add startup diagnostics for HMAC secret status and GitHub credentials configuration
  • Fix bug where controller logged "skipping GitHub status post" but didn't actually skip the call

Test plan

  • go build ./... passes
  • All unit tests pass (go test ./internal/...)
  • Deploy to kind cluster and verify startup logs show HMAC and GitHub config
  • Trigger a podinfo upgrade and verify webhook request logs appear
  • Verify filtered events (non-upgrade) produce debug-level logs

🤖 Generated with Claude Code

twallac10 and others added 6 commits March 8, 2026 07:24
* Implement HelmReleaseTest operator (atomic-munching-donut plan)

- Scaffold kubebuilder project with HelmReleaseTest CRD
- CRD types: HelmReleaseTestSpec (helmReleaseRef, kustomizationRef, cronJobRef),
  full status fields, kubebuilder print columns
- Webhook handler (internal/webhook): HMAC-SHA256 validation, Flux event parsing,
  HelmReleaseTest matching, 5-min dedup window, Job creation from CronJob template
- Job watcher controller: watches batch/v1 Jobs by label, lazy SHA resolution,
  updates HelmReleaseTest status, posts GitHub commit status
- Kustomization SHA resolver (internal/kustomization): unstructured Kustomization fetch
- GitHub status reporter (internal/github): POST /statuses/{sha} with env-based config
- cmd/main.go: webhook goroutine on :8080, probes on :8082, metrics on :8081,
  leader election ID helm-release-test-operator.testing.platform.io
- RBAC markers: batch jobs/cronjobs, kustomize+helm flux CRDs, helmreleasetests
- Sample manifests: HelmReleaseTest CR, suspended CronJob, Flux Provider+Alert
- Unit tests: HMAC validation, SHA parsing, dedup logic, GitHub status posting
- All verification steps pass: make generate, manifests, build, test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix duplicate workflow runs on PR creation

Scope push trigger to main only so feature branch pushes don't
fire a second run alongside the pull_request trigger.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix all golangci-lint issues

- errcheck: wrap resp.Body.Close in func literal, remove duplicate os.Setenv calls
- lll: break long flag.StringVar line in main.go
- staticcheck QF1008: drop embedded .Time from CreationTimestamp.After call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add Docker build and push workflow for GHCR

Multi-platform build (linux/amd64 + linux/arm64) covers Ubuntu k8s nodes
and Mac OS kind clusters (Apple Silicon). On PRs, builds both platforms
without pushing to verify the Dockerfile. On push to main, pushes
ghcr.io/<owner>/testrun-operator:latest and :sha-<sha> tags.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Address all critical and important code review findings

Critical:
- Controller: add LastRunJob guard to prevent re-processing completed Jobs,
  eliminating redundant status patches and duplicate GitHub API calls

Important:
- Webhook: add 1 MiB body size limit via http.MaxBytesReader
- Webhook: remove unused testing.platform.io/helmrelease annotation write
- GitHub: convert PostCommitStatus to Poster struct with injectable HTTPClient,
  read Token/Repo once at startup in main.go instead of inside the leaf function
- main.go: implement fluxWebhookRunnable (manager.Runnable) for graceful shutdown
  with 5s drain timeout instead of bare goroutine
- main.go: inject github.Poster into reconciler
- manager.yaml: fix health probe arg and port from :8081 to :8082
- api types: remove LastTestedRevision field that was declared but never populated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix slow multi-platform Docker builds by pinning builder to BUILDPLATFORM

Without --platform=\$BUILDPLATFORM, Docker pulls the arm64 golang image and
runs the entire Go compile under QEMU on the amd64 runner, which takes many
minutes. With this flag the builder always runs natively; GOARCH=\$TARGETARCH
handles cross-compilation. Only the final distroless layer needs QEMU.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: add Helm chart design doc

* feat: add helm chart scaffold

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add CRD to helm chart

* feat: add RBAC templates to helm chart

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add deployment template to helm chart

* fix: add imagePullSecrets support for private registry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add service template to helm chart

* feat: add helm chart package and push to CI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: bump chart version per CI run for Flux detection
Add debug-level (V1) request logging to the webhook handler so HTTP
requests from Flux notification-controller are visible in operator logs.
Log HMAC validation details and filtered event metadata. Add startup
diagnostics for HMAC secret and GitHub config. Fix controller bug where
"skipping GitHub status post" was logged but the call was not actually
skipped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant