-
Notifications
You must be signed in to change notification settings - Fork 599
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
fix: sequence updates subscription where possible, instead of recreating it #7948
fix: sequence updates subscription where possible, instead of recreating it #7948
Conversation
…mmutable fields Signed-off-by: Calum Murray <[email protected]>
…iptions Signed-off-by: Calum Murray <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7948 +/- ##
==========================================
+ Coverage 69.51% 69.55% +0.03%
==========================================
Files 344 344
Lines 15994 16055 +61
==========================================
+ Hits 11119 11167 +48
- Misses 4189 4199 +10
- Partials 686 689 +3 ☔ View full report in Codecov by Sentry. |
Once this fix is in, I think implementing the same change for Parallels would be a good first issue |
pkg/reconciler/sequence/sequence.go
Outdated
@@ -190,7 +192,7 @@ func (r *Reconciler) reconcileSubscription(ctx context.Context, step int, p *v1. | |||
// TODO: Send events here, or elsewhere? | |||
//r.Recorder.Eventf(p, corev1.EventTypeWarning, subscriptionCreateFailed, "Create Sequences's subscription failed: %v", err) | |||
return nil, fmt.Errorf("failed to get subscription: %s", err) | |||
} else if !equality.Semantic.DeepDerivative(expected.Spec, sub.Spec) { | |||
} else if equal, err := kmp.SafeEqual(sub.Spec, expected.Spec, ignoreArguments); !equal || err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As only .spec.channel is relevant here, we could also compare only these fields (instead of using ignoreArguments
). So this might be a bit more self speaking directly 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is spec.channel
the only immutable field? I just took this check from the validation webhook to make sure that the change is allowable. Maybe we cold just refactor that into its own function and call it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just had it from the comment Given that spec.channel is immutable...
. Also in the SubscriptionSpec
this is the only one marked as immutable:
eventing/pkg/apis/messaging/v1/subscription_types.go
Lines 74 to 107 in 746dc52
type SubscriptionSpec struct { | |
// Reference to a channel that will be used to create the subscription | |
// You can specify only the following fields of the KReference: | |
// - Kind | |
// - APIVersion | |
// - Name | |
// - Namespace | |
// The resource pointed by this KReference must meet the | |
// contract to the ChannelableSpec duck type. If the resource does not | |
// meet this contract it will be reflected in the Subscription's status. | |
// | |
// This field is immutable. We have no good answer on what happens to | |
// the events that are currently in the channel being consumed from | |
// and what the semantics there should be. For now, you can always | |
// delete the Subscription and recreate it to point to a different | |
// channel, giving the user more control over what semantics should | |
// be used (drain the channel first, possibly have events dropped, | |
// etc.) | |
Channel duckv1.KReference `json:"channel"` | |
// Subscriber is reference to function for processing events. | |
// Events from the Channel will be delivered here and replies are | |
// sent to a Destination as specified by the Reply. | |
Subscriber *duckv1.Destination `json:"subscriber,omitempty"` | |
// Reply specifies (optionally) how to handle events returned from | |
// the Subscriber target. | |
// +optional | |
Reply *duckv1.Destination `json:"reply,omitempty"` | |
// Delivery configuration | |
// +optional | |
Delivery *eventingduckv1.DeliverySpec `json:"delivery,omitempty"` | |
} |
But aligning with the webhook code (via function call) makes sense to me
Signed-off-by: Calum Murray <[email protected]>
/cc @creydr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Cali0707, 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 |
/cherry-pick release-1.13 |
/cherry-pick release-1.14 |
@Cali0707: new pull request created: #7959 In response to this:
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. |
@Cali0707: new pull request created: #7960 In response to this:
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. |
Fixes #7939
Proposed Changes
Release Note