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

Only support the Kafka storage in Collector #1231

Closed

Conversation

ledor473
Copy link
Member

@ledor473 ledor473 commented Dec 1, 2018

Which problem is this PR solving?

Short description of the changes

  • Add an unsupported list to the storage factory
  • Make Kafka as unsupported in Ingester, Query, all-in-one (because Ingester is not started anyway)

@ledor473 ledor473 force-pushed the restrict-ingester-datastore branch 2 times, most recently from 00e967c to 19c6433 Compare December 1, 2018 04:34
@ledor473 ledor473 changed the title Prevent the usage of Kafka storage in Ingester and in all-in-one Prevent the usage of Kafka storage except in Collector Dec 1, 2018
@ledor473 ledor473 changed the title Prevent the usage of Kafka storage except in Collector Only support the Kafka storage in Collector Dec 1, 2018
@ledor473 ledor473 force-pushed the restrict-ingester-datastore branch 2 times, most recently from a3812e7 to 3cc4298 Compare December 1, 2018 05:05
Signed-off-by: Louis-Etienne Dorval <louis-etienne.dorval@ticketmaster.com>
@@ -76,7 +76,8 @@ func main() {
if os.Getenv(storage.SpanStorageTypeEnvVar) == "" {
os.Setenv(storage.SpanStorageTypeEnvVar, "memory") // other storage types default to SpanStorage
}
storageFactory, err := storage.NewFactory(storage.FactoryConfigFromEnvAndCLI(os.Args, os.Stderr))
storageFactory, err := storage.NewFactory(storage.FactoryConfigFromEnvAndCLI(os.Args, os.Stderr),
[]string{storage.KafkaStorageType})
Copy link
Member

Choose a reason for hiding this comment

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

if we want to introduce optional params, we should switch to passing an Options struct instead of positional args.

https://github.com/jaegertracing/jaeger-lib/blob/3fa9aa04b65a266a1bbe0a5c8ac1408281b2a64a/metrics/factory.go#L31

Copy link
Member Author

Choose a reason for hiding this comment

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

I choose to make it an optional parameter as the FactoryConfig is currently only for config from the Cobra, but I could indeed add an Options struct inside the same package and use that!

@codecov
Copy link

codecov bot commented Dec 10, 2018

Codecov Report

Merging #1231 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1231   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         159     159           
  Lines        7145    7152    +7     
======================================
+ Hits         7145    7152    +7
Impacted Files Coverage Δ
plugin/storage/factory.go 100% <100%> (ø) ⬆️
plugin/storage/factory_config.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f6af99...80b6a82. Read the comment docs.

Signed-off-by: Louis-Etienne Dorval <louis-etienne.dorval@ticketmaster.com>
@yurishkuro
Copy link
Member

The design of this fix doesn't sit well with me. Right now the details of the storage are fully abstracted from the binaries, but here we're introducing some very specific & peculiar dependency that they have to declare Kafka as unsuitable storage.

The reason Kafka doesn't work for all-in-one is because it does not implement the SpanReader. The reason it does not work for ingester is because the flags are clashing (aside from the flags issue, however, there's no strong reason why ingester wouldn't do Kafka->Kafka, e.g. as a form of replicating data to another topic). If we somehow solved the clash of flags issue, then I assume all-in-one would've exited with a better error message like "reader not implemented", and we wouldn't need to do any changes. Alternatively, if we did want to handle it more explicitly, then the storage factory could expose metadata methods like CanRead(), CanWrite(), and all-in-one would check both and fail for Kafka storage whose factory would return false from CanRead().

@ledor473
Copy link
Member Author

ledor473 commented Jan 24, 2019

there's no strong reason why ingester wouldn't do Kafka->Kafka, e.g. as a form of replicating data to another topic)

@yurishkuro if we want to support that, maybe we could have a set of flags for the consumer and another set of flags for the producer. Something like this:

--kafka.consumer.brokers
--kafka.consumer.topic
--kafka.consumer.encoding
--kafka.consumer.group-id

And:

--kafka.producer.brokers
--kafka.producer.topic
--kafka.producer.encoding

This way you can both replicate from one topic to another, but we can also replicate to one cluster to another cluster. This would also get around the flags being declared twice.

@yurishkuro
Copy link
Member

@ledor473 do you plan to finish this one?

@ledor473
Copy link
Member Author

ledor473 commented Feb 4, 2019

@yurishkuro I was waiting for a confirmation on the latest suggestion (renaming the flags to avoid the exception and to allow the use of multiples brokers/topics).

I might have missed the 👍 on it, but yes I plan to fix this PR.

@yurishkuro
Copy link
Member

cool.

I think GitHub doesn't notify of reactions via +1 button, I'll make sure to comment explicitly in the future.

@ledor473
Copy link
Member Author

ledor473 commented Feb 12, 2019

@yurishkuro the change is mostly done in another branch but I see that we do not pass the logger to InitFromViper (https://github.com/jaegertracing/jaeger/blob/master/plugin/storage/kafka/options.go#L75-L81).

I see 2 options to log the current flag as deprecated:

  1. I change that method in the Configurable interface to provide a logger and use logger.warn

    • Similar to this:
      func (b *Builder) InitFromViper(v *viper.Viper, logger *zap.Logger) *Builder {
      if len(v.GetString(collectorHostPort)) > 0 {
      logger.Warn("Using deprecated configuration", zap.String("option", collectorHostPort))
      b.CollectorHostPorts = strings.Split(v.GetString(collectorHostPort), ",")
      }
  2. I use fmt.Printf

    • Similar to this:
      fmt.Fprintf(
      log,
      "WARNING: found deprecated command line option %s, please use environment variable %s instead\n",
      token,
      SpanStorageTypeEnvVar,
      )

@yurishkuro
Copy link
Member

I would go with option 2, much fewer changes this way

@ledor473
Copy link
Member Author

#1360 is merged, closing this one

@ledor473 ledor473 closed this Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants