Skip to content

Allow registering custom conditions for the Broker#3545

Merged
knative-prow-robot merged 2 commits into
knative:masterfrom
pierDipi:KNATIVE-3094
Jul 10, 2020
Merged

Allow registering custom conditions for the Broker#3545
knative-prow-robot merged 2 commits into
knative:masterfrom
pierDipi:KNATIVE-3094

Conversation

@pierDipi
Copy link
Copy Markdown
Member

@pierDipi pierDipi commented Jul 8, 2020

Fixes #3094

Proposed Changes

  • Allow registering custom conditions for the Broker

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 8, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 8, 2020
@knative-prow-robot knative-prow-robot requested review from aliok and aslom July 8, 2020 19:06
@pierDipi
Copy link
Copy Markdown
Member Author

pierDipi commented Jul 8, 2020

/cc @vaikas @grantr
I would like to know your opinions on the approach.

@knative-test-reporter-robot
Copy link
Copy Markdown

The following jobs failed:

Test name Triggers Retries
pull-knative-eventing-upgrade-tests pull-knative-eventing-upgrade-tests
pull-knative-eventing-upgrade-tests
pull-knative-eventing-upgrade-tests
pull-knative-eventing-upgrade-tests
3/3

Job pull-knative-eventing-upgrade-tests expended all 3 retries without success.

@pierDipi pierDipi changed the title [WIP] Allow registering custom conditions for the Broker Allow registering custom conditions for the Broker Jul 9, 2020
@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 Jul 9, 2020
Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
Copy link
Copy Markdown
Contributor

@vaikas vaikas left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on!! I understood we were going to just expose the simpler solution as described here:
#3094

I'd like to first focus on moving mt broker to use this so there's no special casing for that Broker and that also validates the model as well as makes it a good reference implementation.
What do y'all think?

Comment thread pkg/apis/eventing/v1/broker_lifecycle.go Outdated
Comment thread pkg/apis/eventing/v1/broker_lifecycle.go Outdated
Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1/broker_lifecycle.go 95.5% 100.0% 4.5
pkg/apis/eventing/v1/broker_lifecycle_mt.go Do not exist 100.0%
pkg/apis/eventing/v1beta1/broker_lifecycle.go 95.5% 100.0% 4.5
pkg/apis/eventing/v1beta1/broker_lifecycle_mt.go Do not exist 100.0%
pkg/reconciler/mtbroker/controller.go 65.7% 66.7% 1.0

@pierDipi pierDipi requested a review from vaikas July 9, 2020 19:19
@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 9, 2020

I'm sorry I must have misunderstood what the single broker proposal was. In my mind I had been thinking that we'd be converting the class variable to instance variable, something like this (obvs not necessarily the best place)? And hence each Broker instance would have the conditionset that it uses. But now I'm wondering if your use of the annotation to store which condition set data is really the only way to achieve this without changing the actual API shape visible to the user. Hm... @grantr @dprotaso thoughts on which way is better.

Does it actually need to be persisted anywhere? (sorry, been a long week already :) )

diff --git a/pkg/apis/eventing/v1/broker_types.go b/pkg/apis/eventing/v1/broker_types.go
index 7771fc866..b238151e1 100644
--- a/pkg/apis/eventing/v1/broker_types.go
+++ b/pkg/apis/eventing/v1/broker_types.go
@@ -48,6 +48,10 @@ type Broker struct {
        // date.
        // +optional
        Status BrokerStatus `json:"status,omitempty"`
+        // not visible to the user, only injected to reconciler
+       // +optional
+       BrokerCondSet *apis.ConditionSet
 }

@@ -0,0 +1,62 @@
/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had actually been thinking about moving them away from our API directory alltogether and into the pkg/reconciler. Does not have to be part of this PR obviously :) But again, just sharing my thoughts.

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 9, 2020

Instead of that field living in the Broker.Spec (what the diff shows), it really should be living in the Broker.Status for this case. and it needs the proper json status tag (not just the comment).
Anyhoo, had a quick "would it be bad chat with @mattmoor " and they might be also interested in this for net-* status management as well, perhaps with these being KRshaped, maybe we should think about adding this to duck.Status as a field (non-serialized as described above), and then others would benefit. @whaught since you've done so much around that, we could chat about this thought experiment?

That would also pave the way to the injection path (since we already inject the class annotations), we could just inject the whole configset for direct manipulation by the actual controller?
@n3wscott

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 9, 2020

And just to be clear, I'm not advocating that we do all these obviously as part of this, just trying to figure out the eventual shape we want things to look that would make the migration then easier. I think having it in the Broker.Status today might make it easier migration path 🤔
Ok, I'm done yammering for now :)

@grantr
Copy link
Copy Markdown
Contributor

grantr commented Jul 9, 2020

Thanks for tackling this @pierDipi! I haven't read the PR, so this is more a response to the comment by @vaikas about persistence.

I don't understand why the flavor of ConditionSet needs to be persisted in the object if we already have the broker class annotation there. Maybe if I tried to write the code it would become more obvious. But my initial thought is that the only indicator necessary is the broker class. The controller binary knows in advance what broker class it's going to be reconciling and what conditions are necessary for that broker class, so having a field to say what condition set is being used seems redundant.

In my head, the simplest solution is an exported package variable for BrokerCondSet that a controller main can override before starting controllers:

func main() {
  // ...
  
  v1beta1.BrokerCondSet = myBrokerClassCondSet()
  
  // Start controllers
}

Again I haven't read the PR or tried to implement this so I don't know if this really works or if there are benefits to something more complex. I know it doesn't work if we want to support multiple broker classes in a single process (as mentioned above), and maybe there's a reason to expect we'll need that sooner rather than later.

Just my thoughts from a high level.

@pierDipi
Copy link
Copy Markdown
Member Author

pierDipi commented Jul 10, 2020

Just to clarify what I'm doing in this PR:

I'm not changing Broker, Broker.Status or Broker.Spec.

Am I missing something in the big picture that you have instead?

Does it actually need to be persisted anywhere?

No, it doesn't.

That would also pave the way to the injection path (since we already inject the class annotations), we could just inject the whole configset for direct manipulation by the actual controller?

If I understand correctly, this is the longterm goal of the plan: #3094 (comment)

In my head, the simplest solution is an exported package variable for BrokerCondSet that a controller main can override before starting controllers:

func main() {
    // ...

   v1beta1.BrokerCondSet = myBrokerClassCondSet()

   // Start controllers
}

This is what this PR does through the function RegisterAlternateBrokerConditionSet instead of manipulating the variable directly.

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 10, 2020

Thanks! And sorry for all the thought dumping on your PR :)
/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pierDipi, vaikas

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2020
@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 10, 2020

/check-cla

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 10, 2020

@googlebot check-cla

@pierDipi
Copy link
Copy Markdown
Member Author

@vaikas No problem 😄. As I wrote before, I agree with your thoughts, in particular, this one: #3545 (comment)
FYI, I've enabled this feature here: knative-extensions/eventing-kafka-broker#39, and it looks like it's working.

@dprotaso
Copy link
Copy Markdown
Member

dprotaso commented Jul 13, 2020

To clarify are you adding a dependent condition? ie. when your condition is false it changes 'Ready/Succeeded' to false?

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 13, 2020

@dprotaso it's being able to add / replace the entire condition set. For example, something like kafka / rabbitmq broker might not even have a Channel, so exposing conditions that talk about them doesn't make sense. Does that make sense?
As I was talking to @mattmoor about this last week, he also mentioned that some of the net* classes might have a similar need (iirc, I think there are conditions that talk about virtual services that does not really make sense in some of the other net-* components).

pierDipi added a commit to pierDipi/eventing-kafka that referenced this pull request Oct 20, 2020
…ions

Different KafkaChannel implementation might want to have different
conditions, this PR add the ability to register custom conditions
like we did upstream in knative/eventing#3545
for the Broker.

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
pierDipi added a commit to pierDipi/eventing-kafka that referenced this pull request Oct 20, 2020
…ions

Different KafkaChannel implementation might want to have different
conditions, this PR adds the ability to register custom conditions
like we did upstream in knative/eventing#3545
for the Broker.

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
knative-prow-robot pushed a commit to knative-extensions/eventing-kafka that referenced this pull request Oct 29, 2020
…ions (#117)

Different KafkaChannel implementation might want to have different
conditions, this PR adds the ability to register custom conditions
like we did upstream in knative/eventing#3545
for the Broker.

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alternate brokers need alternate ConditionSets for Broker and Trigger

8 participants