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

Broker class based defaults #7631

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

Conversation

Leo6Leo
Copy link
Member

@Leo6Leo Leo6Leo commented Jan 26, 2024

Fixes #5992

Proposed Changes

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


Docs

Signed-off-by: Leo Li <leoli@redhat.com>
Copy link

knative-prow bot commented Jan 26, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 26, 2024
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 26, 2024
@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 29, 2024
Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
@knative-prow knative-prow bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 31, 2024
Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.48%. Comparing base (7e1c082) to head (aef75f5).
Report is 45 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7631      +/-   ##
==========================================
+ Coverage   69.22%   69.48%   +0.26%     
==========================================
  Files         339      344       +5     
  Lines       19494    15921    -3573     
==========================================
- Hits        13494    11063    -2431     
+ Misses       5337     4183    -1154     
- Partials      663      675      +12     

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

Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 31, 2024
@Leo6Leo Leo6Leo marked this pull request as ready for review February 1, 2024 14:13
@knative-prow knative-prow bot requested a review from matzew February 1, 2024 14:13
@Leo6Leo Leo6Leo changed the title [WIP] Broker class based defaults Broker class based defaults Feb 1, 2024
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 1, 2024
pkg/apis/config/defaults.go Outdated Show resolved Hide resolved
return d.ClusterDefaultConfig.BrokerConfig, nil
}

if config, ok := d.ClusterDefaultConfig.BrokerClasses[brokerClassName]; ok && config != nil {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we check before, if d.ClusterDefaultConfig.BrokerClass == brokerClassName and if this is the case return d.ClusterDefaultConfig.BrokerConfig, as you wrote in https://docs.google.com/document/d/1RKij-DYPmcbCTHF26hkXdrtWHqrksA-Fo5qYLRP7xVA/edit

# The brokerClasses contain the configmap, delivery spec for other brokerClasses.
# The one specified above is NOT included.
# Reason: to maintain compatibility, we are not removing those old fields. And it is not 
# necessary to add it again here under brokerClasses.

Otherwise d.ClusterDefaultConfig.BrokerConfig does not take preference over d.ClusterDefaultConfig.BrokerClasses[] (what I meant in #7631 (comment))

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 think the logic here is correct, prob I didn't explain clearly in the Doc, sorry about that! @creydr

if d.ClusterDefaultConfig.BrokerClass == brokerClassName, then we will directly use d.ClusterDefaultConfig.BrokerConfig. And this brokerClass shouldn't appear in d.ClusterDefaultConfig.BrokerClasses.

When I was referring to:

The one specified above is NOT included.

It means the brokerConfig for d.ClusterDefaultConfig.BrokerClass will not be included in the d.ClusterDefaultConfig.BrokerClasses

Copy link
Member

Choose a reason for hiding this comment

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

Could we change this for easier understanding and verification to a table-test? So that we specify for each case the input and expected output? Similar to what we did in TestDefaultsConfiguration()
That way we could also easily add a case for all of the cases described in https://docs.google.com/document/d/1RKij-DYPmcbCTHF26hkXdrtWHqrksA-Fo5qYLRP7xVA/edit and verify if it works as expected

Leo6Leo and others added 5 commits February 9, 2024 01:37
Co-authored-by: Christoph Stäbler <cstabler@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
…e cluster

Signed-off-by: Leo Li <leoli@redhat.com>
Signed-off-by: Leo Li <leoli@redhat.com>
@Leo6Leo
Copy link
Member Author

Leo6Leo commented Feb 9, 2024

/hold currently trying to manually test the functionality

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 9, 2024
@Leo6Leo
Copy link
Member Author

Leo6Leo commented Feb 9, 2024

Manually creating the broker and test it, some problem occurs: the config from the brokerClasses cannot be used. Currently investigating

Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 10, 2024
@Cali0707
Copy link
Member

Hey @Leo6Leo anything I can help with on this PR?

Copy link

knative-prow bot commented May 10, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Leo6Leo
Once this PR has been reviewed and has the lgtm label, please ask for approval from cali0707. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2024
@Leo6Leo
Copy link
Member Author

Leo6Leo commented May 10, 2024

/remove-lifecycle stale

Resume working on the issue

@knative-prow knative-prow bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 10, 2024
@Leo6Leo
Copy link
Member Author

Leo6Leo commented May 14, 2024

Currently, the table unit test Created broker with DLQ and no Cluster Reference namespace for rabbitmq is failing.

broker_test.go:1289: Extra event: Warning InternalError broker.spec.config.[name, namespace] are required

Note: this is where clusterReference.Namespace is set.

@creydr @pierDipi @Cali0707 Do you guys know how to run the tests in the eventing-rabbitmq repo locally with the changes I have made in this PR?

@creydr
Copy link
Member

creydr commented May 16, 2024

Currently, the table unit test Created broker with DLQ and no Cluster Reference namespace for rabbitmq is failing.

broker_test.go:1289: Extra event: Warning InternalError broker.spec.config.[name, namespace] are required

Note: this is where clusterReference.Namespace is set.

@creydr @pierDipi @Cali0707 Do you guys know how to run the tests in the eventing-rabbitmq repo locally with the changes I have made in this PR?

Not sure, if there is a simple way, but you can use your branch to eventing-core in eventing-rabbitsmqs go.mod file via a replace directive. E.g. something like this:

replace (
    knative.dev/eventing => github.com/Leo6Leo/eventing default-broker-class
)

and then run ./hack/update-deps.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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.

Broker class based defaults
3 participants