Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Reconciliation for default broker selection #186

Merged
merged 6 commits into from
Apr 14, 2020

Conversation

aliok
Copy link
Member

@aliok aliok commented Apr 9, 2020

Issue to be fixed

Fixes #175

Proposed Changes

  • New DefaultBrokerClass in KnativeEventing CR
  • Make the given broker default broker

Notes:

  • Overwrites the default-br-config field of the config-br-defaults configmap based on the value given on CR.
  • If the configmap already exists, it will still be overridden. This behavior is like that for everything, not specific to this configmap. For example, if a deployment/configmap/whatever that's defined in the manifest exists, it will be overwritten by Manifestival. I didn't do anything special for this configmap.
  • I didn't want to introduce dependency to knative/eventing, but in the end it was super bad to duplicate the parsing logic of the configmap's data (YAML in string) and I decided to reuse some functions from knative/eventing. The functions used are specific to eventing only and cannot be really moved to knative/pkg.

Verification instructions:

  • Create eventing with following CR and you will see MTBroker in the created pods.
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
spec:
  defaultBrokerClass: MTChannelBasedBroker
  • With no defaultBrokerClass defined in the spec, ChannelBasedBroker is used in config-br-defaults configmap in knative-eventing namespace.

Release Note

NONE

Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@aliok: 0 warnings.

In response to this:

Issue to be fixed

Fixes #175

Proposed Changes

  • New DefaultBrokerClass in KnativeEventing CR
  • Make the given broker default broker

Notes:

  • Overwrites the config-br-defaults configmap based on the value given on CR

TODO:

Release Note

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/test-infra repository.

@aliok
Copy link
Member Author

aliok commented Apr 9, 2020

Closed #184 as it didn't support custom brokers and pushed this one for early feedback.
The configmap config-br-defaults exists in manifest, eventing.yaml.
The code does a transformation for that configmap.
Sample value for the configmap is this: https://raw.githubusercontent.com/knative/eventing/2c1c5c2e2e7cbb36a716e6fca8802f71704775ff/test/config/mt-channel-broker.yaml

FYI, I simply have done string operations. Didn't want to parse the string content of the configmap's default-br-config field.

cc @jcrossley3

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@aliok aliok marked this pull request as ready for review April 9, 2020 20:08
@aliok aliok changed the title Reconciliation for default broker selection [WIP] Reconciliation for default broker selection Apr 9, 2020
@aliok
Copy link
Member Author

aliok commented Apr 9, 2020

/hold

Still waiting for the gs://knative-nightly/eventing/latest/eventing.yaml to get updated.

@aliok
Copy link
Member Author

aliok commented Apr 10, 2020

/unhold

The nightly manifest is pushed now.

@aliok aliok changed the title [WIP] Reconciliation for default broker selection Reconciliation for default broker selection Apr 10, 2020
}

defaultBrokerClass := instance.Spec.DefaultBrokerClass
if defaultBrokerClass == "" {

Choose a reason for hiding this comment

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

I suggest if channelBasedBrokerClass is empty, we can just do nothing by not changing the configmap, since configmap may have existing values.

Copy link
Member Author

@aliok aliok Apr 11, 2020

Choose a reason for hiding this comment

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

@houshengbo I pushed some new commits and added some notes in the PR description.

To answer this concern:

If the configmap already exists, it will still be overridden. This behavior is like that for everything, not specific to this configmap. For example, if a deployment/configmap/whatever that's defined in the manifest exists, it will be overwritten by Manifestival. I didn't do anything special for this configmap.

@aliok
Copy link
Member Author

aliok commented Apr 10, 2020

I was trying to get away with no YAML parsing, but there are valid points. I will make some changes.

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@aliok
Copy link
Member Author

aliok commented Apr 11, 2020

@houshengbo @jcrossley3 Pushed new commits and added some notes in the PR description. Mind having another look?

@matzew
Copy link
Member

matzew commented Apr 14, 2020

@aliok can you rebase? looks like the recent dependency update conflicts your change, a bit

@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/reconciler/knativeeventing/common/defaultbroker.go Do not exist 68.6%

@aliok
Copy link
Member Author

aliok commented Apr 14, 2020

Rebased

@@ -62,19 +62,19 @@ func TestTransformers(t *testing.T) {
results, err := platform.Transformers(kubeclient.Get(ctx), ke, logger)
assertEqual(t, err, nil)
// By default, there are 3 functions.
assertEqual(t, len(results), 3)
assertEqual(t, len(results), 4)

Choose a reason for hiding this comment

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

The comment above should change.


platform = append(platform, fakePlatform)
results, err = platform.Transformers(kubeclient.Get(ctx), ke, logger)
assertEqual(t, err, nil)
// There is one function in existing platform, so there will be 4 functions in total.
assertEqual(t, len(results), 4)
assertEqual(t, len(results), 5)

Choose a reason for hiding this comment

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

The comment above should change.


platformErr = append(platformErr, fakePlatformErr)
results, err = platformErr.Transformers(kubeclient.Get(ctx), ke, logger)
assertEqual(t, err.Error(), "Test Error")
// By default, there are 3 functions.
assertEqual(t, len(results), 3)
assertEqual(t, len(results), 4)

Choose a reason for hiding this comment

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

The comment above should change.

Copy link

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

There are some minor nits, but I still want to accept it for now.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliok, houshengbo

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

@knative-prow-robot knative-prow-robot merged commit d703711 into knative:master Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broker selection fields on install
7 participants