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 41 commits into
base: main
Choose a base branch
from

Conversation

Leo6Leo
Copy link
Member

@Leo6Leo Leo6Leo commented Jan 26, 2024

Fixes #5992

Proposed Changes

  • Allowing users to set the default configuration for the namespaces adds more flexibility, in case they want to have the different configuration settings for different namespaces.
    Corner cases - what will happen if the user do these:

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

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
@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 67.86%. Comparing base (844dcbf) to head (d9df59f).
Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7631      +/-   ##
==========================================
+ Coverage   67.73%   67.86%   +0.12%     
==========================================
  Files         354      363       +9     
  Lines       16512    16923     +411     
==========================================
+ Hits        11184    11484     +300     
- Misses       4639     4733      +94     
- Partials      689      706      +17     

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

@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
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

@Leo6Leo
Copy link
Member Author

Leo6Leo commented Jun 20, 2024

Steps to test

  1. Apply the following default br config
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: config-br-defaults
  namespace: knative-eventing
  labels:

data:
  default-br-config: |
    clusterDefault:
      brokerClass: default-cluster-class
      apiVersion: v1
      kind: ConfigMap
      name: config-default-cluster-class
      namespace: knative-eventing
      delivery:
        retry: 3
        deadLetterSink:
          ref:
            apiVersion: serving.knative.dev/v1
            kind: Service
            name: mt-handle-error
            namespace: knative-eventing
        backoffPolicy: exponential
        backoffDelay: PT0.2S
      brokerClasses:
        cluster-class-2:
          delivery:
            retry: 3
            deadLetterSink:
              ref:
                apiVersion: serving.knative.dev/v1
                kind: Service
                name: mt-handle-error
                namespace: knative-eventing
            backoffPolicy: exponential
            backoffDelay: PT0.2S

          apiVersion: v1
          kind: ConfigMap
          name: config-cluster-class-2
          namespace: knative-eventing

        shared-class:
          delivery:
            retry: 3
            deadLetterSink:
              ref:
                apiVersion: serving.knative.dev/v1
                kind: Service
                name: kafka-handle-error
                namespace: knative-eventing
            backoffPolicy: exponential
            backoffDelay: PT0.2S

          apiVersion: v1
          kind: ConfigMap
          name: config-shared-class
          namespace: knative-eventing


    namespaceDefaults:
      namespace-1:
        brokerClass: namespace-1-class
        apiVersion: v1
        kind: ConfigMap
        name: config-namespace-1-class
        namespace: namespace-1
        delivery:
          retry: 5
          deadLetterSink:
            ref:
              apiVersion: serving.knative.dev/v1
              kind: Service
              name: someother-handle-error
              namespace: knative-eventing
          backoffPolicy: linear
          backoffDelay: PT0.2S
        brokerClasses:
          namespace-1-class-2:
            delivery:
              retry: 3
              deadLetterSink:
                ref:
                  apiVersion: serving.knative.dev/v1
                  kind: Service
                  name: mt-handle-error
                  namespace: knative-eventing
              backoffPolicy: exponential
              backoffDelay: PT0.2S

            apiVersion: v1
            kind: ConfigMap
            name: config-namespace-1-class-2
            namespace: knative-eventing

          shared-class:
            delivery:
              retry: 3
              deadLetterSink:
                ref:
                  apiVersion: serving.knative.dev/v1
                  kind: Service
                  name: kafka-handle-error
                  namespace: knative-eventing
              backoffPolicy: exponential
              backoffDelay: PT0.2S

            apiVersion: v1
            kind: ConfigMap
            name: config-shared-class-in-namespace-1
            namespace: knative-eventing

      namespace-2:
        brokerClass: default-namespace-2-class


      namespace-3:
  1. Create brokers and then describe it to see whether the correct broker config is used.

@Leo6Leo Leo6Leo requested a review from creydr June 20, 2024 05:33
@Leo6Leo
Copy link
Member Author

Leo6Leo commented Jun 20, 2024

/unhold
The PR is ready for review.

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 20, 2024
@Cali0707
Copy link
Member

@Leo6Leo is there a plan to add a rekt test for this feature? Maybe in another PR?

return config, nil
}

return d.ClusterDefaultConfig.BrokerConfig, nil
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to return an error here instead? At this point we know there is no config for the requested broker class, so we might get weird behaviour for brokers with a random config that doesn't match their class. @pierDipi @creydr any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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