-
Notifications
You must be signed in to change notification settings - Fork 263
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 broker create, delete and list cmds #894
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsimansk: 8 warnings.
In response to this:
Description
Since the Eventing
0.15
multitenant broker is the new default. This PR adds commands to manage broker CR.Changes
- Add
broker create
,broker delete
,broker list
commandsNote 1: E2E are missing right now, I'm currently working on them.
Note 2: I haven't added
update
operation since the current impl only creates Broker CR with a name without additional specs.Reference
Fixes #
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, looks good so far.
The only bigger question is, whether we should allow a default value for the name. As mentioned in the comments, it is is very unlikely that the user is using multiple brokers ever, then allowing a kn broker create
for creating the default broker makes much sense (much like kn trigger create --inject-broker
also only creates the default broker).
What are your opinions on this ? // cc: @maximilien @daisy-ycguo @navidshaikh @duglin
Create a broker. | ||
|
||
``` | ||
kn broker create NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is a good default for a broker (named 'default') I wonder whether we can make the name optional for all broker commands.
That would help in creating a default broker like the injection would do
kn broker create
Broker 'default' is created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for requiring the name explicitly as arg for create
. Keeping create
formula consistent with other resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to keep create
consistent with the rest of resource creation flow, but I've had those thoughts myself that "default" might be worth. However, we can consider "default" to be exclusive for annotation created broker, therefore keeping name
argument required here.
if len(args) != 1 { | ||
return errors.New("'broker create' requires the broker name given as single argument") | ||
} | ||
name := args[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might defaullt to "default" here, but I leave this open for discussion.
if len(args) != 1 { | ||
return errors.New("'broker delete' requires the broker name given as single argument") | ||
} | ||
name := args[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm less sure whether we should default to "default", as this could lead to an accidental deletion of a broker.
It really depends how likely the use case to have multiple brokers in a namespace is. If 95% of all usescases only use the default broker, then having a default value is helpful as this supports the user (who might not even now that he can have more than one broker).
Co-authored-by: Roland Huß <[email protected]>
Co-authored-by: Roland Huß <[email protected]>
Co-authored-by: Roland Huß <[email protected]>
/lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsimansk: 1 unresolved warnings and 1 new warnings.
In response to this:
/lint
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small issues but one "bigger" one in lack of testing in describe command.
Overall, nice work. Thanks for contribution.
} | ||
|
||
// GetBroker records a call for GetBroker with the expected object or error. Either trigger or err should be nil | ||
func (sr *EventingRecorder) GetBroker(name interface{}, broker *v1beta1.Broker, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why name the interface{}
parameter name
here but broker
in line 118?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 118 it is supposed to be a Broker
object normally (but is in an interface{} due to the way the mocking works with expectactions), but here its the name of a Broke (a string normally, again an interface to allow setting expectatiions like Any()
...)
I think its totally fine to mimic the names of the interface here.
pkg/eventing/v1beta1/client_mock.go
Outdated
} | ||
|
||
// DeleteBroker records a call for DeleteBroker with the expected error (nil if none) | ||
func (sr *EventingRecorder) DeleteBroker(name interface{}, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see response above, the wording should reflect the wording of the interface.
"knative.dev/client/pkg/util" | ||
) | ||
|
||
func TestBrokerDescribe(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test is not complete... I can comment out following and still pass the test:
// describeBroker print broker details to the provided output writer
func describeBroker(out io.Writer, broker *v1beta1.Broker, printDetails bool) error {
dw := printers.NewPrefixWriter(out)
commands.WriteMetadata(dw, &broker.ObjectMeta, printDetails)
// dw.WriteLine()
dw.WriteAttribute("Address", "").WriteAttribute("URL", broker.Status.Address.URL.String())
// dw.WriteLine()
// commands.WriteConditions(dw, broker.Status.Conditions, printDetails)
if err := dw.Flush(); err != nil {
return err
}
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 25ec5bd, let me know if the test's acceptable now.
/retest |
brokerCreate(r, "foo2") | ||
verifyBrokerList(r, "foo2") | ||
brokerDelete(r, "foo2") | ||
verifyBrokerNotfound(r, "foo2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per our chat discussion, there seems to be race condition between actual completion of broker delete
operation out verifyBrokerNotfound
. I've addes sync delete in commit e7b5261. Lets see if it helps.
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested a few nits
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree now that we should require an explicit name and no implicit "default". If we ever change our minds we can change to a default "default" broker in a backwards-compatible way later. But not vice versa.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dsimansk, rhuss 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 |
kn broker create mybroker --namespace myproject | ||
` | ||
# Delete a broker 'mybroker' in the 'myproject' namespace | ||
kn broker create mybroker --namespace myproject` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/lgtm |
Description
Since the Eventing
0.15
multitenant broker is the new default. MT Broker is easier to manage from user's namespace because there're no more requirements for additional permission as majority of broker deployment is installed inknative-eventing
namespace. This PR adds commands to manage broker CR.Changes
broker create
,broker delete
,broker list
commandsNote 1: E2E are missing right now, I'm currently working on them.
Note 2: I haven't added
update
operation since the current impl only creates Broker CR with a name without additional specs.Reference
Fixes #