Populate a Subscriptions subscriber and reply namespace only if not set already#6671
Conversation
…et already Signed-off-by: Christoph Stäbler <cstabler@redhat.com>
Codecov ReportBase: 80.60% // Head: 80.55% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #6671 +/- ##
==========================================
- Coverage 80.60% 80.55% -0.05%
==========================================
Files 236 236
Lines 12018 12018
==========================================
- Hits 9687 9681 -6
- Misses 1851 1855 +4
- Partials 480 482 +2
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. |
| if subscriber.Ref != nil { | ||
| // Populate the namespace for the subscriber if required | ||
| if subscriber.Ref != nil && subscriber.Ref.Namespace == "" { | ||
| subscriber.Ref.Namespace = subscription.Namespace |
There was a problem hiding this comment.
I see that the defaulting was always happening here but it may be better to move it to the defaulting webhook for subscriptions.
There was a problem hiding this comment.
Thanks for the review. I agree the defaulting webhook would be a better place. Let me move it...
There was a problem hiding this comment.
This defaulting should be kept here for backward compatibility since existing resources won't have it defaulted until an update happens
There was a problem hiding this comment.
@pierDipi: So we don't we resync the resources after a couple of time?
There was a problem hiding this comment.
resync is not necessarily producing an update (knative/pkg tries to reduce updates as much as possible to reduce API server load) therefore the webhook is not always applied
There was a problem hiding this comment.
what I meant is that even with the current code (before this PR), the namespace was set (latest on a periodic resync) on the resource. So my chance from this PR (being in a webhook or not) would not change anything IIUC. My PR would only change anything on resources which don't have the namespace set on reply/subscribers - which should only be the case for new resources. Or am I missing something?
There was a problem hiding this comment.
This is only a status update:
ReconcileKind are not persisted.
In addition, on upgrade controller and webhook are not atomically updated at the same time, so during this time period we might not have this logic running anywhere
There was a problem hiding this comment.
I think I got the point. This logic is only operating on a copy of the subscription. The sequence webhook sets the namespace correctly, but it gets overwritten by the subscription reconciler. As the subscription reconciler needs the namespace of the ref, it must be set - and since we can create subscriptions directly without a namespace for the ref this is an issue (and there might be some out there without a ref.namespace already).
|
/assign @pierDipi @gab-satchi |
pierDipi
left a comment
There was a problem hiding this comment.
We can make the webhook addition as a follow up PR
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: creydr, pierDipi The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test upgrade-tests |
…et already (knative#6671) Fixes knative#6539 In case a Subscription with a `.spec.subscriber.ref` pointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see knative#6539). Same happens with a subscriptions `.spec.reply.ref`. This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply. ## Proposed Changes * 🐛 Populate a subscriptions subscriber & reply namespace field with the Subscriptions namespace only in case it is not set ### Pre-review Checklist - [ ] **At least 80% unit test coverage** - [ ] **E2E tests** for any new behavior - [ ] **Docs PR** for any user-facing impact - [ ] **Spec PR** for any new API feature - [ ] **Conformance test** for any change to the spec **Release Note** ```release-note ``` **How to verify** 1. Install a eventing with this patch 2. Create a sequence with steps and a reply in different namespaces (e.g. https://gist.github.com/creydr/57235f35b03ab8f1285eee0a64350576) 3. Check that the subscriptions and sequence becomes ready Signed-off-by: Christoph Stäbler <cstabler@redhat.com> (cherry picked from commit bd67450)
…et already (knative#6671) (#93) Fixes knative#6539 In case a Subscription with a `.spec.subscriber.ref` pointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see knative#6539). Same happens with a subscriptions `.spec.reply.ref`. This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply. ## Proposed Changes * 🐛 Populate a subscriptions subscriber & reply namespace field with the Subscriptions namespace only in case it is not set ### Pre-review Checklist - [ ] **At least 80% unit test coverage** - [ ] **E2E tests** for any new behavior - [ ] **Docs PR** for any user-facing impact - [ ] **Spec PR** for any new API feature - [ ] **Conformance test** for any change to the spec **Release Note** ```release-note ``` **How to verify** 1. Install a eventing with this patch 2. Create a sequence with steps and a reply in different namespaces (e.g. https://gist.github.com/creydr/57235f35b03ab8f1285eee0a64350576) 3. Check that the subscriptions and sequence becomes ready Signed-off-by: Christoph Stäbler <cstabler@redhat.com> (cherry picked from commit bd67450)
…et already (knative#6671) Fixes knative#6539 In case a Subscription with a `.spec.subscriber.ref` pointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see knative#6539). Same happens with a subscriptions `.spec.reply.ref`. This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply. ## Proposed Changes * 🐛 Populate a subscriptions subscriber & reply namespace field with the Subscriptions namespace only in case it is not set ### Pre-review Checklist - [ ] **At least 80% unit test coverage** - [ ] **E2E tests** for any new behavior - [ ] **Docs PR** for any user-facing impact - [ ] **Spec PR** for any new API feature - [ ] **Conformance test** for any change to the spec **Release Note** ```release-note ``` **How to verify** 1. Install a eventing with this patch 2. Create a sequence with steps and a reply in different namespaces (e.g. https://gist.github.com/creydr/57235f35b03ab8f1285eee0a64350576) 3. Check that the subscriptions and sequence becomes ready Signed-off-by: Christoph Stäbler <cstabler@redhat.com> (cherry picked from commit bd67450)
…et already (knative#6671) Fixes knative#6539 In case a Subscription with a `.spec.subscriber.ref` pointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see knative#6539). Same happens with a subscriptions `.spec.reply.ref`. This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply. ## Proposed Changes * 🐛 Populate a subscriptions subscriber & reply namespace field with the Subscriptions namespace only in case it is not set ### Pre-review Checklist - [ ] **At least 80% unit test coverage** - [ ] **E2E tests** for any new behavior - [ ] **Docs PR** for any user-facing impact - [ ] **Spec PR** for any new API feature - [ ] **Conformance test** for any change to the spec **Release Note** ```release-note ``` **How to verify** 1. Install a eventing with this patch 2. Create a sequence with steps and a reply in different namespaces (e.g. https://gist.github.com/creydr/57235f35b03ab8f1285eee0a64350576) 3. Check that the subscriptions and sequence becomes ready Signed-off-by: Christoph Stäbler <cstabler@redhat.com> (cherry picked from commit bd67450)
…et already (knative#6671) (#95) Fixes knative#6539 In case a Subscription with a `.spec.subscriber.ref` pointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see knative#6539). Same happens with a subscriptions `.spec.reply.ref`. This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply. ## Proposed Changes * 🐛 Populate a subscriptions subscriber & reply namespace field with the Subscriptions namespace only in case it is not set ### Pre-review Checklist - [ ] **At least 80% unit test coverage** - [ ] **E2E tests** for any new behavior - [ ] **Docs PR** for any user-facing impact - [ ] **Spec PR** for any new API feature - [ ] **Conformance test** for any change to the spec **Release Note** ```release-note ``` **How to verify** 1. Install a eventing with this patch 2. Create a sequence with steps and a reply in different namespaces (e.g. https://gist.github.com/creydr/57235f35b03ab8f1285eee0a64350576) 3. Check that the subscriptions and sequence becomes ready Signed-off-by: Christoph Stäbler <cstabler@redhat.com> (cherry picked from commit bd67450) Co-authored-by: Christoph Stäbler <cstabler@redhat.com>
…et already (knative#6671) (#94) Fixes knative#6539 In case a Subscription with a `.spec.subscriber.ref` pointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see knative#6539). Same happens with a subscriptions `.spec.reply.ref`. This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply. ## Proposed Changes * 🐛 Populate a subscriptions subscriber & reply namespace field with the Subscriptions namespace only in case it is not set ### Pre-review Checklist - [ ] **At least 80% unit test coverage** - [ ] **E2E tests** for any new behavior - [ ] **Docs PR** for any user-facing impact - [ ] **Spec PR** for any new API feature - [ ] **Conformance test** for any change to the spec **Release Note** ```release-note ``` **How to verify** 1. Install a eventing with this patch 2. Create a sequence with steps and a reply in different namespaces (e.g. https://gist.github.com/creydr/57235f35b03ab8f1285eee0a64350576) 3. Check that the subscriptions and sequence becomes ready Signed-off-by: Christoph Stäbler <cstabler@redhat.com> (cherry picked from commit bd67450) Co-authored-by: Christoph Stäbler <cstabler@redhat.com>
Fixes #6539
In case a Subscription with a
.spec.subscriber.refpointing to a service in another namespace, the Subscription will not become ready because it is trying to find the service on the subscription's namespace (see #6539). Same happens with a subscriptions.spec.reply.ref.This PR addresses it and only uses the namespace of the Subscription, if no namespace was given for the subscriber/reply.
Proposed Changes
Pre-review Checklist
Release Note
How to verify