-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Expected Behavior
When a PipelineRun is created without an explicit serviceAccountName, the Tekton webhook should apply the value from config-defaults ConfigMap's default-service-account field (e.g., pipeline), regardless of whether other mutating webhooks run before or after the Tekton webhook.
Actual Behavior
When another MutatingWebhookConfiguration (e.g., tekton-kueue's tekton-kueue-mutating-webhook-configuration) is registered and intercepts PipelineRun CREATE requests before the Tekton webhook, the Tekton webhook's SetDefaults() does not apply the default-service-account value. The PipelineRun ends up with serviceAccountName: "default" instead of the configured value ("pipeline").
The Tekton webhook log shows PatchBytes: null for the PipelineRun CREATE, meaning SetDefaults ran but produced no SA patch.
TaskRun creation is NOT affected — TaskRuns correctly receive the configured default SA even with the same additional webhook present.
Steps to Reproduce the Problem
- Install OpenShift Pipelines (or Tekton Pipelines) with
config-defaultsConfigMap set todefault-service-account: pipeline - Verify PipelineRun defaulting works:
kubectl create --dry-run=server -o jsonpath='{.spec.taskRunTemplate.serviceAccountName}' -f - <<'EOF' apiVersion: tekton.dev/v1 kind: PipelineRun metadata: generateName: test- spec: pipelineSpec: tasks: - name: echo taskSpec: steps: - image: busybox script: echo hello EOF # Returns: "pipeline" ✅
- Install any component that registers a MutatingWebhookConfiguration intercepting PipelineRun CREATE (e.g., tekton-kueue/scheduler)
- Repeat the same dry-run test:
# Returns: "default" ❌ - Delete the additional MutatingWebhookConfiguration:
kubectl delete mutatingwebhookconfiguration <name>
- Repeat the dry-run test:
# Returns: "pipeline" ✅ (works again)
Additional Info
- Kubernetes version: OpenShift 4.20.16
- Tekton Pipeline version: 1.22.0
- The issue is 100% reproducible: MWC present → SA defaults to
"default", MWC absent → SA defaults to"pipeline" - TaskRun defaulting is NOT affected (always gets the correct SA)
- The Tekton webhook has
reinvocationPolicy: IfNeededand does get reinvoked, but returns no SA patch - The additional webhook (tekton-kueue) does NOT modify
serviceAccountName— it only setsspec.statusand labels - Webhook execution order is alphabetical: the additional webhook runs before
webhook.pipeline.tekton.dev - Restarting the Tekton webhook pod does not fix the issue
- This may be related to how controller-runtime serializes typed Go structs back to JSON after mutation, potentially introducing zero-value fields that prevent the Tekton webhook from applying its defaults