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

Add Elasticsearch index cleaner as cron job #155

Merged
merged 2 commits into from
Dec 5, 2018

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Dec 4, 2018

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@jpkrohling
Copy link
Contributor

This change is Reviewable

@@ -16,27 +16,21 @@ spec:
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.0
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
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 have bumped patch version. And disabled xpack, we should not use it anyways. There an official ES6x without licensed xpack, but I would rather keep using the lowest supported version.

// JaegerEsIndexCleanerSpec holds the options related to es-index-cleaner
type JaegerEsIndexCleanerSpec struct {
Enabled bool `json:"enabled"`
NumberOfDays int `json:"numberOfDays"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Used 7 days as default. TTL in c* is 2 day though...

Copy link
Member Author

Choose a reason for hiding this comment

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

The script supports other configuration properties, see https://github.com/jaegertracing/jaeger/blob/master/plugin/storage/es/esCleaner.py#L11

index prefix, es hostname, I have not exposed them directly but they are derived from storage properties map.

@codecov
Copy link

codecov bot commented Dec 4, 2018

Codecov Report

Merging #155 into master will increase coverage by 0.03%.
The diff coverage is 97.4%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #155      +/-   ##
==========================================
+ Coverage   96.32%   96.36%   +0.03%     
==========================================
  Files          29       30       +1     
  Lines        1362     1430      +68     
==========================================
+ Hits         1312     1378      +66     
- Misses         39       40       +1     
- Partials       11       12       +1
Impacted Files Coverage Δ
pkg/apis/io/v1alpha1/jaeger_types.go 100% <ø> (ø) ⬆️
pkg/strategy/controller.go 100% <100%> (ø) ⬆️
pkg/strategy/production.go 100% <100%> (ø) ⬆️
pkg/strategy/all-in-one.go 100% <100%> (ø) ⬆️
pkg/cronjob/spark_dependencies.go 97.46% <100%> (-0.18%) ⬇️
pkg/cronjob/es_index_cleaner.go 96% <96%> (ø)

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 893144d...06edd1c. Read the comment docs.

@@ -150,6 +151,14 @@ type JaegerDependenciesSpec struct {
ElasticsearchNodesWanOnly bool `json:"elasticsearchNodesWanOnly"`
}

// JaegerEsIndexCleanerSpec holds the options related to es-index-cleaner
type JaegerEsIndexCleanerSpec struct {
Enabled bool `json:"enabled"`
Copy link
Member Author

Choose a reason for hiding this comment

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

By default disabled.

I think we should enable it by default along with dependencies job. I would rather do it in a separate PR to keep this minimal.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 20 of 20 files at r1.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @pavolloffay)


deploy/examples/simple-prod.yaml, line 13 at r1 (raw file):

      es:
        server-urls: http://elasticsearch:9200
        username: elastic

Isn't this the default one?


pkg/apis/io/v1alpha1/jaeger_types.go, line 156 at r1 (raw file):

Previously, pavolloffay (Pavol Loffay) wrote…

By default disabled.

I think we should enable it by default along with dependencies job. I would rather do it in a separate PR to keep this minimal.

+1

Could you also check the other Enabled flags? I think they are *bool, mostly because they default to true. While it would be OK to have bool instead of *bool for this one, I think we should consider being consistent.

In time: I know there are other Enabled bool there, but those are recent changes as well and should be changed to *bool if we decide to be consistent among all Enabled flags.


pkg/cronjob/es_index_cleaner.go, line 18 at r1 (raw file):

func CreateEsIndexCleaner(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob {
	applyIndexCleanerDefaults(&jaeger.Spec.Storage.EsIndexCleaner)

I think this might belong to the normalize() function in the strategy package.


pkg/cronjob/es_index_cleaner_test.go, line 28 at r1 (raw file):

func TestApplyEsCleanerDefaults(t *testing.T) {
	viper.Set("jaeger-es-index-cleaner-image", "foo")

You might need a defer viper.Reset(), otherwise other tests might be affected if they get this value from viper later on.


pkg/cronjob/spark_dependencies.go, line 24 at r1 (raw file):

func CreateSparkDependencies(jaeger *v1alpha1.Jaeger) *batchv1beta1.CronJob {
	applySparkDependenciesDefaults(jaeger)

I think I missed this before, but the same comment I left before applies here: this might belong to the normalize function. The idea is to centralize all this kind of logic there, which might be composed of different values from different objects (like, production with in-memory storage).


pkg/strategy/all-in-one.go, line 90 at r1 (raw file):

	}

	if c.jaeger.Spec.Storage.Type == "elasticsearch" && c.jaeger.Spec.Storage.EsIndexCleaner.Enabled {

The same comment as I left for a previous PR: if the value is true here, it means the user has explicitly set it to true, so, there's an expectation that the cleaner will be installed. So, log.Info if Enabled == true and Storage != es.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Copy link
Member Author

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

Reviewable status: 14 of 22 files reviewed, 8 unresolved discussions (waiting on @jpkrohling)


deploy/examples/simple-prod.yaml, line 13 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

Isn't this the default one?

it is, but I have disabled xpack. ES cleaner does not support auth


pkg/apis/io/v1alpha1/jaeger_types.go, line 156 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

+1

Could you also check the other Enabled flags? I think they are *bool, mostly because they default to true. While it would be OK to have bool instead of *bool for this one, I think we should consider being consistent.

In time: I know there are other Enabled bool there, but those are recent changes as well and should be changed to *bool if we decide to be consistent among all Enabled flags.

As I mention in the previous comment i would rather do it in a separate PR


pkg/cronjob/es_index_cleaner.go, line 18 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

I think this might belong to the normalize() function in the strategy package.

+1


pkg/cronjob/es_index_cleaner_test.go, line 28 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

You might need a defer viper.Reset(), otherwise other tests might be affected if they get this value from viper later on.

+1


pkg/cronjob/spark_dependencies.go, line 24 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

I think I missed this before, but the same comment I left before applies here: this might belong to the normalize function. The idea is to centralize all this kind of logic there, which might be composed of different values from different objects (like, production with in-memory storage).

Done.


pkg/strategy/all-in-one.go, line 90 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

The same comment as I left for a previous PR: if the value is true here, it means the user has explicitly set it to true, so, there's an expectation that the cleaner will be installed. So, log.Info if Enabled == true and Storage != es.

Done.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @pavolloffay)


pkg/apis/io/v1alpha1/jaeger_types.go, line 156 at r1 (raw file):

Previously, pavolloffay (Pavol Loffay) wrote…

As I mention in the previous comment i would rather do it in a separate PR

Agreed.

@pavolloffay pavolloffay merged commit 9adb6a2 into jaegertracing:master Dec 5, 2018
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