Skip to content

test: add regression coverage for SinkBinding preserving existing volumes - #9252

Open
pujitha24 wants to merge 1 commit into
knative:mainfrom
pujitha24:auto/issue-8261
Open

test: add regression coverage for SinkBinding preserving existing volumes#9252
pujitha24 wants to merge 1 commit into
knative:mainfrom
pujitha24:auto/issue-8261

Conversation

@pujitha24

Copy link
Copy Markdown

Motivation:
Issue #8261 reported that SinkBinding's mutation of a Deployment
subject (SinkBinding.Do in pkg/apis/sources/v1/sinkbinding_lifecycle.go)
eliminated pre-existing volumes/volumeMounts on the subject as soon as
K_SINK env vars were injected, filed against v1.14.0. A maintainer
later attempted to reproduce this on a newer release with a Deployment
carrying a custom ConfigMap volume and was unable to reproduce it, and
no further activity or linked fix followed.

Reviewing the current code, SinkBinding.Do only ever appends to
Volumes/VolumeMounts/Env (including the trust-bundle and OIDC token
volume injection paths), and the admission webhook applies the change
as a computed JSON patch diff rather than a wholesale object replace,
so there is no remaining code path that would drop unrelated volumes.
This change has no user-visible behavior impact today; the bug does
not currently reproduce.

Approach:
Add a regression test case to TestSinkBindingDo that starts from a
subject with a pre-existing user-defined Volume and a container
VolumeMount referencing it, and asserts both are still present after
Do() runs alongside the injected K_SINK/K_CA_CERTS/K_CE_OVERRIDES env
vars. This locks in the current correct behavior and will catch a
regression if this code path changes in the future.

Validation:
go build ./...
go test ./pkg/apis/sources/v1/... -run TestSinkBindingDo -v
(new subtest "preserves_existing_volumes_and_volumeMounts_on_subject"
passes, along with all sibling subtests)

/kind bug

NONE

Fixes #8261

Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com

…umes

Motivation:
Issue knative#8261 reported that SinkBinding's mutation of a Deployment
subject (SinkBinding.Do in pkg/apis/sources/v1/sinkbinding_lifecycle.go)
eliminated pre-existing volumes/volumeMounts on the subject as soon as
K_SINK env vars were injected, filed against v1.14.0. A maintainer
later attempted to reproduce this on a newer release with a Deployment
carrying a custom ConfigMap volume and was unable to reproduce it, and
no further activity or linked fix followed.

Reviewing the current code, SinkBinding.Do only ever appends to
Volumes/VolumeMounts/Env (including the trust-bundle and OIDC token
volume injection paths), and the admission webhook applies the change
as a computed JSON patch diff rather than a wholesale object replace,
so there is no remaining code path that would drop unrelated volumes.
This change has no user-visible behavior impact today; the bug does
not currently reproduce.

Approach:
Add a regression test case to TestSinkBindingDo that starts from a
subject with a pre-existing user-defined Volume and a container
VolumeMount referencing it, and asserts both are still present after
Do() runs alongside the injected K_SINK/K_CA_CERTS/K_CE_OVERRIDES env
vars. This locks in the current correct behavior and will catch a
regression if this code path changes in the future.

Validation:
go build ./...
go test ./pkg/apis/sources/v1/... -run TestSinkBindingDo -v
(new subtest "preserves_existing_volumes_and_volumeMounts_on_subject"
passes, along with all sibling subtests)

/kind bug

```release-note
NONE
```

Fixes knative#8261

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 29, 2026 00:19
@knative-prow knative-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@knative-prow

knative-prow Bot commented Jul 29, 2026

Copy link
Copy Markdown

Welcome @pujitha24! It looks like this is your first PR to knative/eventing 🎉

@knative-prow

knative-prow Bot commented Jul 29, 2026

Copy link
Copy Markdown

Hi @pujitha24. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 29, 2026
@knative-prow

knative-prow Bot commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pujitha24
Once this PR has been reviewed and has the lgtm label, please assign creydr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow
knative-prow Bot requested review from Cali0707 and Leo6Leo July 29, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SinkBinding eliminates all volumes on Deployment subject

2 participants