Skip to content

PipelineRun webhook defaulting skips default-service-account when another MutatingWebhookConfiguration intercepts CREATE first #9647

@waveywaves

Description

@waveywaves

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

  1. Install OpenShift Pipelines (or Tekton Pipelines) with config-defaults ConfigMap set to default-service-account: pipeline
  2. 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" ✅
  3. Install any component that registers a MutatingWebhookConfiguration intercepting PipelineRun CREATE (e.g., tekton-kueue/scheduler)
  4. Repeat the same dry-run test:
    # Returns: "default" ❌
  5. Delete the additional MutatingWebhookConfiguration:
    kubectl delete mutatingwebhookconfiguration <name>
  6. 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: IfNeeded and does get reinvoked, but returns no SA patch
  • The additional webhook (tekton-kueue) does NOT modify serviceAccountName — it only sets spec.status and 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release.

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions