Skip to content

Conversation

Alexander-Kita
Copy link
Contributor

@Alexander-Kita Alexander-Kita commented Aug 11, 2025

Fixes #8857

Proposed Changes

  • Will always/only run dry-run if specified in user request
  • Remove podspec-dryrun feature flag

Release Note

* podspec-dryrun feature flag has been removed. Dry run validation will now occur when a user opts into it using `kubectl apply --dry-run=server`

@knative-prow knative-prow bot requested review from dsimansk and skonto August 11, 2025 21:56
Copy link

knative-prow bot commented Aug 11, 2025

Welcome @Alexander-Kita! It looks like this is your first PR to knative/serving 🎉

@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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 11, 2025
Copy link

knative-prow bot commented Aug 11, 2025

Hi @Alexander-Kita. 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.

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.

@dprotaso
Copy link
Member

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 14, 2025
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.17%. Comparing base (6bab565) to head (eec0a1a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/webhook/podspec_dryrun.go 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16008      +/-   ##
==========================================
+ Coverage   80.13%   80.17%   +0.04%     
==========================================
  Files         214      214              
  Lines       16893    16877      -16     
==========================================
- Hits        13537    13531       -6     
+ Misses       2994     2987       -7     
+ Partials      362      359       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 17, 2025
Copy link
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

I think as part of this change we should drop the feature flag

@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 24, 2025
@Alexander-Kita
Copy link
Contributor Author

I think as part of this change we should drop the feature flag

Removed feature flag, dry run validation now only occurs when dry-run=server is specified. Please let me know if I missed anything.

@dprotaso

Copy link
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

some minor feedback

Comment on lines 202 to 217
func PatchServiceWithDryRun(t testing.TB, clients *test.Clients, service *v1.Service, fopt ...rtesting.ServiceOption) (svc *v1.Service, err error) {
newSvc := service.DeepCopy()
for _, opt := range fopt {
opt(newSvc)
}
LogResourceObject(t, ResourceObjects{Service: newSvc})
patchBytes, err := duck.CreateBytePatch(service, newSvc)
if err != nil {
return nil, err
}
return svc, reconciler.RetryTestErrors(func(int) (err error) {
svc, err = clients.ServingClient.Services.Patch(context.Background(), service.ObjectMeta.Name, types.JSONPatchType, patchBytes, metav1.PatchOptions{DryRun: []string{metav1.DryRunAll}})
return err
})
}

Copy link
Member

Choose a reason for hiding this comment

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

Let's move this to test/e2e/service_validation_test.go as it's specific to that test

}

_, err = v1test.PatchService(t, clients, service, withInvalidContainer())
_, err = v1test.PatchServiceWithDryRun(t, clients, service, withInvalidContainer())
Copy link
Member

Choose a reason for hiding this comment

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

This is technically changing the test to use dry-run.

I'd probably suggest having an alternate 'dry-run' e2e test

Copy link
Contributor Author

@Alexander-Kita Alexander-Kita Aug 28, 2025

Choose a reason for hiding this comment

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

This test does not work the same as it used to because we removed the feature flag (it had previously used the annotation). Should the test be renamed or moved instead?

Copy link
Member

Choose a reason for hiding this comment

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

oh then let's rename the test


func TestSkipUpdate(t *testing.T) {
validService := &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Copy link
Member

Choose a reason for hiding this comment

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

TestSkipUpdate - would be more apt-ly named TestSkipDryRun no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it is specifically testing the update portion, so maybe it could be TestSkipUpdateDryrun?

Copy link
Member

@dprotaso dprotaso Aug 28, 2025

Choose a reason for hiding this comment

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

Looking at it more - it's ensuring we skip calling and k8s calls when we perform a dry-run (when the resource hasn't changed).

I say we just remove this behaviour and delete this test. Ideally when a user performs a dry run we ensure we validate everything even if it's the same. The reason is because we wouldn't know if something 'new' is running in the cluster that could influence the podspec dry-run.

I think this will simplify the implementation.

@Alexander-Kita
Copy link
Contributor Author

@dprotaso Implemented requested changes in latest commit

Copy link
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

looks great - just two minor things we don't need.

I removed it from my local copy and it didn't have any material effect

cfg.Domain = v.(*config.Domain)
}

ctx = apis.WithDryRun(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

We can drop this

t.Run(tc.name, func(t *testing.T) {
ingress := &netv1alpha1.Ingress{Status: tc.status}
ctx := config.ToContext(context.Background(), testConfig())
ctx = apis.WithDryRun(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

we can drop this

@dprotaso
Copy link
Member

dprotaso commented Sep 3, 2025

Also two more things

  1. Can you take a look at the linter error in the GitHub Actions?
  2. Can you update the docs here https://github.com/knative/docs (removing the feature flag and maybe adding a dry-run example in under Serving > Developer Topics)

@Alexander-Kita
Copy link
Contributor Author

@dprotaso Looks like the passed except for one, which seems unrelated to the code (seems like some kind of missing file issue)

@dprotaso
Copy link
Member

dprotaso commented Sep 8, 2025

/retest

@dprotaso
Copy link
Member

dprotaso commented Sep 8, 2025

/lgtm
/approve

thanks @Alexander-Kita 🎉

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2025
Copy link

knative-prow bot commented Sep 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Alexander-Kita, dprotaso

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

The pull request process is described here

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 8, 2025
@knative-prow knative-prow bot merged commit 097de3d into knative:main Sep 8, 2025
78 of 79 checks passed
@Alexander-Kita Alexander-Kita deleted the optimize-dryrun branch September 8, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize DryRun
2 participants