Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

[kn-source-kafka] Add kafka source command group #33

Merged
merged 1 commit into from
Jun 26, 2020

Conversation

daisy-ycguo
Copy link
Member

@daisy-ycguo daisy-ycguo commented May 21, 2020

Including:

  • source kafka create
  • source kafka delete
  • source kafka describe

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 21, 2020
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 21, 2020
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:
prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)

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:
prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)

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:
prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)

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:
prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)

@knative-prow-robot
Copy link

@daisy-ycguo: you cannot LGTM your own PR.

In response to this:

/lgtm

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.

Copy link
Contributor

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

I tried building locally and noticed the auto generated README is out of sync with the PR, also added a few suggestions in README

plugins/source-kafka/README.md Outdated Show resolved Hide resolved
plugins/source-kafka/README.md Outdated Show resolved Hide resolved
plugins/source-kafka/README.md Outdated Show resolved Hide resolved
plugins/source-kafka/README.md Outdated Show resolved Hide resolved
plugins/source-kafka/pkg/client/client_fake.go Outdated Show resolved Hide resolved
@maximilien
Copy link
Contributor

Please address @navidshaikh comments. Once done LGTM

@maximilien
Copy link
Contributor

/approve

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 23, 2020
Copy link
Contributor

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

Can we try and bump the client dep to master and see how that goes? This should help use broker at v1beta1 in sink prefixes for addressable of kafka source.

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:
prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)

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:
prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)

plugins/source-kafka/README.md Show resolved Hide resolved
plugins/source-kafka/README.md Show resolved Hide resolved
plugins/source-kafka/README.md Show resolved Hide resolved
plugins/source-kafka/README.md Show resolved Hide resolved
plugins/source-kafka/README.md Show resolved Hide resolved
plugins/source-kafka/README.md Show resolved Hide resolved
@daisy-ycguo
Copy link
Member Author

daisy-ycguo commented Jun 24, 2020

@navidshaikh thank you for the review. I have addressed your comments.
To answer your question about README.md out of sync, it is because that README.md is auto generated when building but the auto generated README.md cannot meet with the format review by mattmoore. So I updated README.md manually after building. Based on our discussion in slack, I will stick with the auto generated version of README.md and ignore the format review comments.
I update e2e test script a little to apply kafka topic yaml file when setting up kafka cluster also.

@maximilien
Copy link
Contributor

@navidshaikh LGTM so feel free to check @daisy-ycguo’s changes and merge when you feel ready. Best.

Copy link
Contributor

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

Suggested multiple changes, IMO there are a few important changes we should address, for example error handling, client dependency, command help messages, etc. We may also look at doing these fixes in next iteration(s) as well.


func (f *kafkaSourceCommandFactory) CreateCommand() *cobra.Command {
createCmd := f.defaultCommandFactory.CreateCommand()
createCmd.Short = "create NAME"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be createCmd.Use with signature for mandatory flags.

See https://github.com/knative/client/blob/master/pkg/kn/commands/source/ping/create.go#L35-L36 for reference.

sourceCmd := f.defaultCommandFactory.SourceCommand()
sourceCmd.Use = "kafka"
sourceCmd.Short = "Knative eventing Kafka source plugin"
sourceCmd.Long = "Manage your Knative Kafka eventing sources"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sourceCmd.Long = "Manage your Knative Kafka eventing sources"
sourceCmd.Long = "Manage Knative Kafka eventing sources"

Copy link
Contributor

Choose a reason for hiding this comment

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

or remove sourceCmd.Long if its same as .Short text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I removed Long but use Short instead. I also changed short to use. Thank you.

gotest.tools v2.2.0+incompatible
k8s.io/apimachinery v0.17.4
k8s.io/client-go v0.17.4
knative.dev/client v0.14.0
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, we should try to keep to client's dep on the latest release (or even master) to make sure the latest fixes, eventing/serving API support is up-to-date. For example: client v0.14.0 refers brokers at v1alpha1, client master refers brokers at v1beta1 in sink prefixes; this could bring uncertain behavior. Also, IMO plugins should declare the deps and support on its root README for API support.

// NewKafkaSourceClient is to create a KafkaSourceClient
func NewKafkaSourceClient(kafkaParams *types.KafkaSourceParams, c clientv1alpha1.SourcesV1alpha1Interface, ns string) types.KafkaSourceClient {
if c == nil {
c, _ = kafkaParams.NewSourcesClient()
Copy link
Contributor

Choose a reason for hiding this comment

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

not handling error here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

throws stacktrace in absence of kubeconfig

kn source kafka create mykafkasrc --servers my-cluster-kafka-bootstrap.kafka.svc:9092 --topics test-topic --consumergroup test-consumer-group --sink svc:event-display      

panic: Could not create Kn source client, error: no kubeconfig has been provided, please use a valid configuration to connect to the cluster

goroutine 1 [running]:
github.com/maximilien/kn-source-pkg/pkg/client.NewKnSourceClient(0xc0000f7c80, 0x160ef5d, 0x7, 0xc00078f200, 0x180ab60)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/vendor/github.com/maximilien/kn-source-pkg/pkg/client/client.go:35 +0x193
knative.dev/client-contrib/plugins/source-kafka/pkg/client.NewKafkaSourceClient(0xc000057000, 0x1818a40, 0x0, 0x160ef5d, 0x7, 0xc00078e1a0, 0x0)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/pkg/client/client.go:46 +0x63
knative.dev/client-contrib/plugins/source-kafka/pkg/factories.(*kafkaClientFactory).initKafkaSourceClient(0xc0003e1740, 0x160ef5d, 0x7)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/pkg/factories/source_factory.go:99 +0x65
knative.dev/client-contrib/plugins/source-kafka/pkg/factories.(*kafkaClientFactory).CreateKafkaSourceClient(0xc0003e1740, 0x160ef5d, 0x7, 0x7, 0x0)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/pkg/factories/source_factory.go:51 +0x62
knative.dev/client-contrib/plugins/source-kafka/pkg/factories.(*kafkaSourceRunEFactory).KafkaSourceClient(...)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/pkg/factories/rune_factory.go:62
knative.dev/client-contrib/plugins/source-kafka/pkg/factories.(*kafkaSourceRunEFactory).CreateRunE.func1(0xc0000cedc0, 0xc00018e2d0, 0x1, 0x9, 0x0, 0x0)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/pkg/factories/rune_factory.go:81 +0xaf
github.com/spf13/cobra.(*Command).execute(0xc0000cedc0, 0xc00018e1b0, 0x9, 0x9, 0xc0000cedc0, 0xc00018e1b0)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/vendor/github.com/spf13/cobra/command.go:832 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000ceb00, 0xc0003e1740, 0x7f9ef81c2180, 0xc0005110a0)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/vendor/github.com/spf13/cobra/command.go:920 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/vendor/github.com/spf13/cobra/command.go:870
main.main()
	/home/nshaikh/go/src/github.com/knative/client-contrib/plugins/source-kafka/cmd/main.go:34 +0x40c
Error: exit status 2
Run 'kn --help' for usage

@@ -0,0 +1,222 @@
// Copyright © 2018 The Knative Authors
Copy link
Contributor

Choose a reason for hiding this comment

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

run_factory.go instead of rune_factory.go ?

return nil
}

//GetKafkaSource is used to create an instance of KafkaSource
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//GetKafkaSource is used to create an instance of KafkaSource
//GetKafkaSource to get an instance of Kafka source by given name

func (f *kafkaSourceCommandFactory) DescribeCommand() *cobra.Command {
describeCmd := f.defaultCommandFactory.DescribeCommand()
describeCmd.Short = "describe NAME"
describeCmd.Long = "update a Kafka source"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describeCmd.Long = "update a Kafka source"
describeCmd.Long = "describe a Kafka source"

Comment on lines +207 to +208
ref := sink.Ref
if ref != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ref := sink.Ref
if ref != nil {
if sink.Ref != nil {

Comment on lines +36 to +38
if err.Error() != "subcommand is required" {
fmt.Fprintln(os.Stderr, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if err.Error() != "subcommand is required" {
fmt.Fprintln(os.Stderr, err)
}
fmt.Fprintln(os.Stderr, err)

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2020
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: daisy-ycguo, maximilien, navidshaikh

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:
  • OWNERS [maximilien,navidshaikh]

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 49864fb into knative:master Jun 26, 2020
@navidshaikh
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants