Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve webhook namespaceSelector.matchLabels #2605

Merged
merged 2 commits into from
Oct 6, 2022

Conversation

pierDipi
Copy link
Member

@pierDipi pierDipi commented Oct 5, 2022

I have a webhook with this definition and the reconciler is removing the namespaceSelector.matchLabels field:

Current resource:

				  namespaceSelector:
				    matchExpressions:
				    - key: webhooks.knative.dev/exclude
				      operator: DoesNotExist
				  objectSelector:
				    matchLabels:
				      app.kubernetes.io/component: kafka-dispatcher

Applied resource:

				    namespaceSelector:
				      matchExpressions: [ ]
				      matchLabels:
				        app.kubernetes.io/name: knative-eventing
				    objectSelector:
				      matchLabels:
				        app.kubernetes.io/component: kafka-dispatcher

Signed-off-by: Pierangelo Di Pilato [email protected]

Changes

  • Preserve webhook namespaceSelector.matchLabels

/kind bug

Release Note

Preserve webhook namespaceSelector.matchLabels

I have a webhook with this definition and the reconciler is
removing the matchLabels field:

Current resource:
```
				  namespaceSelector:
				    matchExpressions:
				    - key: webhooks.knative.dev/exclude
				      operator: DoesNotExist
				  objectSelector:
				    matchLabels:
				      app.kubernetes.io/component: kafka-dispatcher

```

Applied resource:
```
				    namespaceSelector:
				      matchExpressions: [ ]
				      matchLabels:
				        app.kubernetes.io/name: knative-eventing
				    objectSelector:
				      matchLabels:
				        app.kubernetes.io/component: kafka-dispatcher
```

Signed-off-by: Pierangelo Di Pilato <[email protected]>
@pierDipi
Copy link
Member Author

pierDipi commented Oct 5, 2022

/cc @dprotaso @evankanderson

@knative-prow knative-prow bot added kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 5, 2022
@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Base: 81.29% // Head: 81.30% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (6980ede) compared to base (158538c).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2605   +/-   ##
=======================================
  Coverage   81.29%   81.30%           
=======================================
  Files         162      162           
  Lines        9820     9824    +4     
=======================================
+ Hits         7983     7987    +4     
  Misses       1597     1597           
  Partials      240      240           
Impacted Files Coverage Δ
webhook/helper.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 37 to 39
if len(current.MatchExpressions) == 0 {
return want
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Dropping the return here has us always calling ensureLabelSelectorRequirements(), which makes a new list of structs... not sure what the cost of that is (could be negligible), but should we consider keeping this block (and adding the MatchLabels to the return) in order to bypass that call if it's not needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you! Done!

@pierDipi pierDipi requested a review from psschwei October 6, 2022 15:33
Copy link
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

The change post Paul's suggestion makes complete sense to me. Working through the logic pre-change was getting me a little confused -- thanks Paul!

/approve
/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2022
@knative-prow
Copy link

knative-prow bot commented Oct 6, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: evankanderson, pierDipi

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 Oct 6, 2022
@evankanderson
Copy link
Member

Not sure what's going on with EasyCLA right now

@psschwei
Copy link
Contributor

psschwei commented Oct 6, 2022

Yeah, seems to be having problems in all knative/* repos except func

@jarias-lfx
Copy link

/easycla

@knative-prow knative-prow bot merged commit fb2e4fb into knative:main Oct 6, 2022
@pierDipi pierDipi deleted the preserve-webhook-match-labels branch October 7, 2022 07:16
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. 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.

4 participants