--- created: 2026-11-20T12:44:38 updated: 2026-11-24T11:40:34 --- ## Kueue live test on local kind GitHub App tokens expire after one hour. If a PipelineRun waits in Kueue longer than that, its git-auth Secret holds an expired token when the build starts and cloning a private repo fails. This is [pull request #3105](https://github.com/tektoncd/pipelines-as-code/pull/3105), introduced by [commit c622a93](https://github.com/tektoncd/pipelines-as-code/commit/c622a9303c0f190bead91c308b884a747bdb229e). It fixes this with a validating webhook (`queued-token.pipelinesascode.tekton.dev`). PaC stores the token expiry on the git-auth Secret when it creates the run. When Kueue clears `PipelineRunPending` to start the build, the webhook intercepts that update, requests a new scoped token from GitHub if the current one has five minutes or less left, writes it into the same Secret, and then allows the release. I tested this against a private repo (`chmouel/pac-e2e-tests`, GitHub App installation `20722724`) on a cluster built by startpaac. The PaC checkout for startpaac was on the PR #3105 branch, so `ko` built and deployed that revision of the controller, watcher and webhook. startpaac ran with `--install-kueue`, which installs cert-manager 1.19.2, Kueue 0.16.6 and tekton-kueue 0.4.3 on Kubernetes 1.37.0, creates the `startpaac-pipelines` ClusterQueue admitting one PipelineRun at a time, labels `default` with `startpaac.dev/kueue=enabled` and gives it a `pipelines-queue` LocalQueue. That is the [startpaac Kueue guide](https://github.com/openshift-pipelines/startpaac/blob/main/docs/configuration.md) with the queue definitions in [lib/kueue/queues.yaml](https://github.com/openshift-pipelines/startpaac/blob/main/lib/kueue/queues.yaml), and it matches the setup I wrote about in [startpaac-kueue](startpaac-kueue.md). To avoid waiting an hour, I paused `ClusterQueue/startpaac-pipelines` with `stopPolicy: Hold`, registered the repo in `default` (where `LocalQueue/pipelines-queue` is active), and opened PR #452 with a normal clone pipeline (no `PipelineRunPending` in the YAML). PaC created `git-clone-private-kueue-mt42v` and `Secret/pac-gitauth-iyrkhs`, and tekton-kueue mutated the PipelineRun to `PipelineRunPending` under `pipelines-queue`: ```json { "name": "git-clone-private-kueue-mt42v", "spec_status": "PipelineRunPending", "kueue_queue": "pipelines-queue", "git_auth_secret": "pac-gitauth-iyrkhs", "installation_id": "20722724" } ``` Initial Secret state before patching: ```json { "name": "pac-gitauth-iyrkhs", "uid": "316ddb32-346b-4893-8abe-f727fba76147", "resourceVersion": "32991", "expiry": "2026-11-24T11:13:56Z", "token_sha256_prefix": "7c5713226551da3f" } ``` While the run waited, I patched `pac-gitauth-iyrkhs` with an expired timestamp (`2000-01-01T00:00:00Z`) and replaced the token with `invalid-kueue-e2e-token` (`00ef82da140c2d1b`). At `10:14:38Z`, I set `stopPolicy: None` on `startpaac-pipelines`. Kueue admitted the workload, `tekton-kueue-controller-manager` sent the `UPDATE` clearing `PipelineRunPending`, and the API server routed it to `pipelines-as-code-webhook`: ```text 10:14:38.684Z kueue-controller-manager Admitted by ClusterQueue startpaac-pipelines (Workload pipelinerun-git-clone-private-kueue-mt42v-1e81d) 10:14:39.549Z pipelines-as-code-webhook github-app: initialized OAuth2 client (caller: system:serviceaccount:tekton-kueue:tekton-kueue-controller-manager) 10:14:39.549Z pipelines-as-code-webhook setupAuthenticatedClient: scoping github app token 10:14:39.827Z pipelines-as-code-webhook admissionreview/allowed=true (admissionreview/uid: 5c7f3b00-38fb-486a-8352-44b618723c92) 10:14:46Z tekton-kueue Workload 'default/pipelinerun-git-clone-private-kueue-mt42v-1e81d' is declared finished ``` Post-release Secret state (same UID, new token hash, new future expiry): ```json { "name": "pac-gitauth-iyrkhs", "uid": "316ddb32-346b-4893-8abe-f727fba76147", "resourceVersion": "33213", "expiry": "2026-11-24T11:14:39Z", "token_sha256_prefix": "8dbc194bd7a2fc3d" } ``` Tekton cloned the private repo on the first try and finished the PipelineRun at `10:14:46Z`. ## Local checks From the PaC checkout, run the refresh and scoping tests: ```sh go test -race ./pkg/webhook -run 'Test(RefreshBeforeRelease|IssueQueuedTokenUsesConfiguredScope)$' ``` The tests cover expiry, fresh tokens, and failed Secret writes. They also send a release request through admission and check that PaC uses the second controller’s App and repository scope. Run `make check` for the full suite and lint. The [design note](konflux-16750-design.md) explains the admission sequence. ## Automated cluster test Set `TEST_GITHUB_REPO_OWNER_GITHUBAPP` to a private test repository with the App installed and `TEST_GITHUB_REPO_INSTALLATION_ID` to its installation ID. Use the usual GitHub App E2E configuration. ```sh TEST_GITHUB_API_URL=https://api.github.com go test -tags=e2e ./test \ -run '^TestGithubPullRequestRefreshQueuedToken$' -count=1 -v ``` The test uses one PR and one run. It checks that a bad expiry blocks release, then sets a valid past expiry and checks that release refreshes the same Secret and the first clone succeeds. I ran this on local kind against `chmouel/pac-e2e-tests` (PR #450) and it passed in 73.7 seconds: ```text --- PASS: TestGithubPullRequestRefreshQueuedToken (73.69s) PASS ok github.com/openshift-pipelines/pipelines-as-code/test 73.707s ``` ## Smoke test without Kueue Deploy the branch on a test cluster with Tekton and the GitHub App. Use a disposable private-repo PipelineRun template that clones with `{{ git_auth_secret }}` and has no task retries. Set `spec.status: PipelineRunPending` in the template and leave PaC’s concurrency limit unset so the run waits for manual release. Trigger it through PaC so it gets a real git-auth Secret. The test replaces that token with a dummy value and backdates the expiry, then clears Pending. ```mermaid sequenceDiagram participant U as Tester participant C as PaC controller participant A as Kubernetes API participant W as PaC webhook participant G as GitHub participant T as Tekton U->>C: Trigger a private build C->>A: Create the Secret and pending run U->>A: Set a past expiry and dummy token U->>A: Clear PipelineRunPending A->>W: Review release via admission rule W->>G: Request a replacement token G-->>W: Scoped token and expiry W->>A: Update the same Secret W-->>A: Allow release A-->>T: Runnable PipelineRun T->>G: First private clone U->>A: Check run result and Secret expiry %% title: Test refresh with a manual release %% play: Release a private run with an expired token %% C -> A | PaC creates the Secret the same way it does for a regular run. %% U -> A | A dummy token makes the old credential unusable without waiting an hour. %% U -> A | Clear the Pending status to trigger the same admission rule a queue would. %% A -> W %% W -> G %% W -> A : token | PaC saves a working token under the original Secret name. %% W -> A | PaC allows the release after the Secret write succeeds. %% A -> T %% T -> G | The first private clone should succeed. %% U -> A | Check the run succeeded and the original Secret has a future expiry. ``` ## Prepare the queued run Set `NS` and `RUN` in Bash, then check the run is pending and owns the Secret. ```bash set -euo pipefail : "${NS:?Set NS to the test namespace}" "${RUN:?Set RUN to the test PipelineRun}" prefix=pipelinesascode.tekton.dev expiry_key="$prefix/github-token-expiry" run=$(kubectl -n "$NS" get pipelinerun "$RUN" -o json) jq -e '.spec.status == "PipelineRunPending"' <<< "$run" >/dev/null secret=$(jq -er --arg key "$prefix/git-auth-secret" '.metadata.annotations[$key] | select(length > 0)' <<< "$run") repo=$(jq -er --arg key "$prefix/repo-url" '.metadata.annotations[$key] | select(startswith("https://github.com/"))' <<< "$run") run_uid=$(jq -er .metadata.uid <<< "$run") kubectl -n "$NS" get secret "$secret" -o json | jq -e --arg uid "$run_uid" --arg key "$expiry_key" ' any(.metadata.ownerReferences[]?; .kind == "PipelineRun" and .uid == $uid) and (.metadata.annotations[$key] != null) ' >/dev/null ``` ## Force a refresh Run this in the same shell while the build is still pending. ```bash patch=$(jq -nc --arg key "$expiry_key" --arg credentials "https://git:invalid-smoke-token@${repo#https://}" ' {metadata: {annotations: {($key): "2000-01-01T00:00:00Z"}}, stringData: {".git-credentials": $credentials, "git-provider-token": "invalid-smoke-token"}} ') kubectl -n "$NS" patch secret "$secret" --type=merge -p "$patch" ``` ## Release and verify Clear Pending yourself. That calls the admission webhook before Kubernetes saves the change. Verify the original Secret has a future expiry and the private clone succeeds. ```bash kubectl -n "$NS" patch pipelinerun "$RUN" --type=merge \ -p '{"spec":{"status":null}}' kubectl -n "$NS" wait --for=condition=Succeeded "pipelinerun/$RUN" --timeout=5m kubectl -n "$NS" get secret "$secret" -o json | jq -er --arg key "$expiry_key" '.metadata.annotations[$key] | select(fromdateiso8601 > now)' ``` For a control, release a fresh run without changing its Secret and compare the expiry before and after. It should stay the same. To test actual GitHub expiry too, keep a run queued past its recorded expiry and release it without patching the Secret. ## Review coverage The Go regression test exercises the `Admit` route for a second controller and checks the Secret update. The local kind runs confirmed the CEL `matchConditions` on a real API server and the full Kueue hold-and-release refresh flow. Still open: - Verify PaC’s own concurrency queue retries a denied release after a temporary Secret-write failure.