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

Add ConsumerGroup scheduling #1632

Conversation

pierDipi
Copy link
Member

Part of #1537

Proposed Changes

  • Add ConsumerGroup scheduling

Release Note

None

Docs

None

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/control-plane size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 17, 2021
@codecov
Copy link

codecov bot commented Dec 17, 2021

Codecov Report

Merging #1632 (59cbd86) into main (5fcac54) will increase coverage by 0.77%.
The diff coverage is 68.83%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1632      +/-   ##
============================================
+ Coverage     71.86%   72.64%   +0.77%     
- Complexity      595      597       +2     
============================================
  Files           122      122              
  Lines          4521     4569      +48     
  Branches        171      171              
============================================
+ Hits           3249     3319      +70     
+ Misses         1008      977      -31     
- Partials        264      273       +9     
Flag Coverage Δ
java-unittests 81.90% <ø> (+0.10%) ⬆️

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

Impacted Files Coverage Δ
...afka/eventing/v1alpha1/consumer_group_lifecycle.go 0.00% <0.00%> (ø)
...ls/kafka/eventing/v1alpha1/consumer_group_types.go 0.00% <0.00%> (ø)
...nternals/kafka/eventing/v1alpha1/consumer_types.go 0.00% <ø> (ø)
...apis/internals/kafka/eventing/v1alpha1/register.go 0.00% <ø> (ø)
...lane/pkg/reconciler/consumergroup/consumergroup.go 76.82% <80.30%> (+76.82%) ⬆️
control-plane/pkg/prober/cache.go 100.00% <0.00%> (+4.76%) ⬆️
...dispatcher/impl/consumer/BaseConsumerVerticle.java 93.75% <0.00%> (+6.25%) ⬆️
control-plane/pkg/prober/prober.go 75.00% <0.00%> (+15.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fcac54...59cbd86. Read the comment docs.

@pierDipi pierDipi force-pushed the SRVKE-1060-ConsumerGroup-scheduling branch 4 times, most recently from b1fe326 to 87933be Compare December 17, 2021 17:46
@pierDipi pierDipi force-pushed the SRVKE-1060-ConsumerGroup-scheduling branch from 87933be to de48c2f Compare January 4, 2022 09:26
@pierDipi pierDipi changed the title [WIP] Add ConsumerGroup scheduling Add ConsumerGroup scheduling Jan 4, 2022
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 4, 2022
@pierDipi
Copy link
Member Author

pierDipi commented Jan 4, 2022

Flaky
/retest

@pierDipi pierDipi force-pushed the SRVKE-1060-ConsumerGroup-scheduling branch from de48c2f to 4cc955a Compare January 7, 2022 07:32
@pierDipi
Copy link
Member Author

pierDipi commented Jan 7, 2022

Can I please get a review of this PR? @matzew @aliok @devguyio @aavarghese @lionelvillard


if _, err := r.InternalsClient.Consumers(cg.GetNamespace()).Create(ctx, c, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("failed to create consumer %s/%s: %w", c.GetNamespace(), c.GetName(), err)
// Check if there is a consumer for the given placement.
Copy link
Contributor

Choose a reason for hiding this comment

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

if there is no consumer, we create/reconcile an internal consumer and return it ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

}

// Stable sort consumers so that we give consumers different deletion
// priorities based on their state.
Copy link
Contributor

Choose a reason for hiding this comment

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

I may lack context, but what state? the IsLessThan compares what?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make this part more explicit in a follow-up PR.

IsLessThan defines the order for deleting consumers in the same placement.

Imagine there are consumer c1 and consumer c2 in pod p1.
We want to have only one consumer for a placement, so we remove one of them based on their state.
In our case, we're considering readiness or the creation time as a state, meaning that we try to keep ready consumers over not ready ones or if they aren't ready we remove the most recently created ones.

@matzew
Copy link
Contributor

matzew commented Jan 7, 2022

I gave a first review. any more to read for better context ?

@pierDipi
Copy link
Member Author

pierDipi commented Jan 7, 2022

The scheduler doc and API may be helpful: https://github.com/knative/eventing/tree/main/pkg/scheduler

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 10, 2022
pierDipi and others added 2 commits January 10, 2022 08:48
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi force-pushed the SRVKE-1060-ConsumerGroup-scheduling branch from 8207334 to 59cbd86 Compare January 10, 2022 07:48
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 10, 2022
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-sandbox-eventing-kafka-broker-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
control-plane/pkg/reconciler/consumergroup/consumergroup.go 0.0% 87.1% 87.1

@pierDipi pierDipi requested a review from matzew January 10, 2022 07:58
@matzew
Copy link
Contributor

matzew commented Jan 10, 2022

/lgtm
thanks or addressing my comments. +1 on the follow up PR

/hold
waiting for final approval from @aavarghese and/or @lionelvillard

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 10, 2022
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 10, 2022
}
}

func ConsumerTopics(topics ...string) ConsumerSpecOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, can some of these funcs be renamed to WithConsumerTopics, WithConsumerPlacement, WithConsumerConfigs, WithConsumerBootstrapServersConfig, etc. Wdyt?

Copy link
Contributor

@aavarghese aavarghese left a comment

Choose a reason for hiding this comment

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

All looks good! Func name change not critical for this iteration so..
/lgtm

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aavarghese, 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

@pierDipi
Copy link
Member Author

Thanks!

/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 10, 2022
@knative-prow-robot knative-prow-robot merged commit 8887191 into knative-extensions:main Jan 10, 2022
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants