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

only requeue consumergroups from appropriate statefulset on change #3825

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Cali0707
Copy link
Member

@Cali0707 Cali0707 commented Apr 5, 2024

Fixes #3824

Proposed Changes

  • Check the owner kind for the consumergroup and only requeue it if necessary for a given statefulset change

Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/control-plane size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 5, 2024
@Cali0707
Copy link
Member Author

Cali0707 commented Apr 5, 2024

/cc @pierDipi @creydr @Leo6Leo

@knative-prow knative-prow bot requested review from creydr and pierDipi April 5, 2024 19:55
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 2.70270% with 36 lines in your changes are missing coverage. Please review.

Project coverage is 49.49%. Comparing base (551691c) to head (6814585).
Report is 38 commits behind head on main.

Files Patch % Lines
...l-plane/pkg/reconciler/consumergroup/controller.go 4.76% 18 Missing and 2 partials ⚠️
...apis/internals/kafka/eventing/v1alpha1/register.go 0.00% 9 Missing ⚠️
...ontrol-plane/pkg/reconciler/consumer/controller.go 0.00% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main    #3825       +/-   ##
=============================================
- Coverage     73.90%   49.49%   -24.41%     
=============================================
  Files           100      246      +146     
  Lines          3407    14817    +11410     
  Branches        288        0      -288     
=============================================
+ Hits           2518     7334     +4816     
- Misses          716     6730     +6014     
- Partials        173      753      +580     
Flag Coverage Δ
java-unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@pierDipi
Copy link
Member

pierDipi commented Apr 8, 2024

/retest-required

Comment on lines +79 to +89
func GetOwnerKindFromStatefulSetName(name string) (string, bool) {
switch name {
case SourceStatefulSetName:
return "KafkaSource", true
case ChannelStatefulSetName:
return "KafkaChannel", true
case BrokerStatefulSetName:
return "Trigger", true
}
return "", false
}
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use this one?

// GetUserFacingResourceRef gets the resource reference to the user-facing resources
// that are backed by this ConsumerGroup using the OwnerReference list.
func (cg *ConsumerGroup) GetUserFacingResourceRef() *metav1.OwnerReference {
for i, or := range cg.OwnerReferences {
// TODO hardcoded resource kinds.
if strings.EqualFold(or.Kind, "trigger") ||
strings.EqualFold(or.Kind, "kafkasource") ||
strings.EqualFold(or.Kind, "kafkachannel") {
return &cg.OwnerReferences[i]
}
}
return nil
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This one goes consumergroup -> ownerReference, we need to go statefulset -> ownerReference.Kind

Copy link
Member

Choose a reason for hiding this comment

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

I see

Comment on lines +79 to +89
func GetOwnerKindFromStatefulSetName(name string) (string, bool) {
switch name {
case SourceStatefulSetName:
return "KafkaSource", true
case ChannelStatefulSetName:
return "KafkaChannel", true
case BrokerStatefulSetName:
return "Trigger", true
}
return "", false
}
Copy link
Member

Choose a reason for hiding this comment

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

I see

@@ -189,8 +189,30 @@ func NewController(ctx context.Context, watcher configmap.Watcher) *controller.I
})
consumerInformer.Informer().AddEventHandler(controller.HandleAll(enqueueConsumerGroupFromConsumer(impl.EnqueueKey)))

globalResync := func(interface{}) {
impl.GlobalResync(consumerGroupInformer.Informer())
globalResync := func(obj interface{}) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename this variable?

This is not a globalResync anymore as it's dealing with statefulset changes vs the primary controlled objects

Copy link
Member

Choose a reason for hiding this comment

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

If we don't plan to reuse this anywhere I think we can inline this on the ResyncOnStatefulSetChange call as it's now very specific

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/cc @pierDipi

@knative-prow knative-prow bot requested a review from pierDipi April 11, 2024 14:50
Signed-off-by: Calum Murray <cmurray@redhat.com>
@@ -90,7 +90,7 @@ func NewController(ctx context.Context, watcher configmap.Watcher) *controller.I
impl.GlobalResync(consumerInformer.Informer())
}

cgreconciler.ResyncOnStatefulSetChange(ctx, globalResync)
cgreconciler.ResyncOnStatefulSetChange(ctx, impl.FilteredGlobalResync, consumerInformer.Informer())
Copy link
Member

Choose a reason for hiding this comment

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

The provided informer here will have consumers but in the function we do:

		filteredResync(func(i interface{}) bool {
			cg, ok := i.(*kafkainternals.ConsumerGroup)
			if !ok {
				return false
			}

Copy link
Member Author

Choose a reason for hiding this comment

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

that makes sense, thanks for catching this! (just saved me lots of debugging time)

Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/retest-required

1 similar comment
@Cali0707
Copy link
Member Author

/retest-required

@pierDipi
Copy link
Member

/retest

@Cali0707
Copy link
Member Author

/retest-required

@Cali0707
Copy link
Member Author

/cc @pierDipi

@knative-prow knative-prow bot requested a review from pierDipi April 12, 2024 11:36
}

for _, ref := range c.GetOwnerReferences() {
if ref.Kind == "ConsumerGroup" {
Copy link
Member

@pierDipi pierDipi Apr 12, 2024

Choose a reason for hiding this comment

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

I'd use case insensitive match as it's more robust

Suggested change
if ref.Kind == "ConsumerGroup" {
if strings.EqualFold(ref.Kind, "ConsumerGroup") {

Copy link
Member

Choose a reason for hiding this comment

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

(Make sure the import is there)

Copy link
Member

Choose a reason for hiding this comment

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

Actually, there is this function

// GetConsumerGroup gets the resource reference to the ConsumerGroup
// using the OwnerReference list.
func (c *Consumer) GetConsumerGroup() *metav1.OwnerReference {
for i, or := range c.OwnerReferences {
if strings.EqualFold(or.Kind, ConsumerGroupGroupVersionKind.Kind) {
return &c.OwnerReferences[i]
}
}
return nil
}

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/cc @pierDipi

@knative-prow knative-prow bot requested a review from pierDipi April 12, 2024 13:02
Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 12, 2024
Copy link

knative-prow bot commented Apr 12, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

return nil, false
}

cgRef := c.GetConsumerGroup()
Copy link
Member

Choose a reason for hiding this comment

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

nit: We would need to check for non nil here

@pierDipi
Copy link
Member

/retest-required

@Cali0707
Copy link
Member Author

/test integration-tests

@Cali0707
Copy link
Member Author

/retest-required

4 similar comments
@Cali0707
Copy link
Member Author

/retest-required

@pierDipi
Copy link
Member

/retest-required

@pierDipi
Copy link
Member

/retest-required

@Cali0707
Copy link
Member Author

/retest-required

@Cali0707
Copy link
Member Author

/retest

@Cali0707
Copy link
Member Author

/retest-required

@pierDipi
Copy link
Member

pierDipi commented May 3, 2024


    triggerv2_downgrade.go:54: failed to downgrade from triggerv2 failed to get deployment: client rate limiter Wait returned an error: context deadline exceeded

@Cali0707
Copy link
Member Author

Cali0707 commented May 3, 2024


    triggerv2_downgrade.go:54: failed to downgrade from triggerv2 failed to get deployment: client rate limiter Wait returned an error: context deadline exceeded

@pierDipi this should be fixed by #3868

/test upgrade-tests

@pierDipi
Copy link
Member

pierDipi commented May 6, 2024

/retest-required

@pierDipi
Copy link
Member

/test upgrade-tests

Copy link

knative-prow bot commented May 21, 2024

@Cali0707: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
reconciler-tests-namespaced-broker_eventing-kafka-broker_main 6814585 link unknown /test reconciler-tests-namespaced-broker
reconciler-tests_eventing-kafka-broker_main 6814585 link unknown /test reconciler-tests

Your PR dashboard.

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. I understand the commands that are listed here.

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. area/control-plane lgtm Indicates that a PR is ready to be merged. 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.

Consumergroup should only requeue when when relevant statefulset changes
2 participants