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

Rollover api for main indices #1309

Merged

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Jan 31, 2019

Resolves #1242 #1308

Other significant changes:

  • moved mappings to separate files - it's important if we want to consume them in other components e.g. rollover script needs mappings when creating index.
  • json files are compiled to go as we do with static files in query service
  • marked --es.use-aliases as experimental
  • mark aliases as experimental

cc @jaegertracing/elasticsearch

Makefile Show resolved Hide resolved
print('ACTION ... one of:')
print('\tinit - creates archive index and aliases')
print('\trollover - rollover to new write index')
print('\tlookback - removes old indices from read alias')
print('HOSTNAME ... specifies which ElasticSearch hosts to search and delete indices from.')
print('INDEX_PREFIX ... specifies index prefix.')
print('init configuration:')
print('\tSHARDS ... the number of shards per index in ElasticSearch (default 5)')
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 should remove this, defaults are in the first line

if action == 'init':
index = prefix + ARCHIVE_INDEX + '-000001'
if create_template:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the create_template parameter necessary, couldn't you just check for init action and create the index template for the supplied index_to_rollover?

Copy link
Member Author

Choose a reason for hiding this comment

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

See how the func is called, it would create templates two times in some cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can only see the three calls to the function - each with different index - so each call could pass the mapping file name. However the first call, for span-archive doesn't seem to create the index template - is that correct?

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 template should be created for all indices. I forgot to add the param to archive branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

This still needs to be done? Still think it would be better to just pass the mapping file name instead of the boolean, so each call to perform_action would just create the one index.

go get -u github.com/jteeuwen/go-bindata/...
go get -u github.com/elazarl/go-bindata-assetfs/...

.PHONE: statik-elasticsearch-mappings
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be changed to remove statik from the task?

Copy link
Member Author

Choose a reason for hiding this comment

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

will be changed in a follow pr with the unification of statik and go-bindata

if action == 'init':
index = prefix + ARCHIVE_INDEX + '-000001'
if create_template:
Copy link
Contributor

Choose a reason for hiding this comment

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

This still needs to be done? Still think it would be better to just pass the mapping file name instead of the boolean, so each call to perform_action would just create the one index.

@pavolloffay pavolloffay force-pushed the rollover-api-for-main-indices branch from 702541f to 66fbd65 Compare February 8, 2019 08:27
@objectiser
Copy link
Contributor

@pavolloffay Tried using the following with a fresh Elasticsearch db:

docker run test/jaeger-es-rollover init localhost

and got:

Creating index template jaeger-span
Traceback (most recent call last):
  File "/es-rollover/esRollover.py", line 163, in <module>
    main()
  File "/es-rollover/esRollover.py", line 53, in main
    perform_action(action, client, write_alias, read_alias, 'jaeger-span', 'jaeger-span')
  File "/es-rollover/esRollover.py", line 64, in perform_action
    create_index_template(fix_mapping(mapping, shards, replicas), template_name)
  File "/es-rollover/esRollover.py", line 83, in create_index_template
    r = requests.put(sys.argv[2] + '/_template/' + template_name, headers=headers, data=template)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 131, in put
    return request('put', url, data=data, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'localhost/_template/jaeger-span': No schema supplied. Perhaps you meant http://localhost/_template/jaeger-span?

The usage message says /es-rollover/esRollover.py ACTION HOSTNAME[:PORT] so implies localhost for host should be fine?

@pavolloffay
Copy link
Member Author

The usage message says /es-rollover/esRollover.py ACTION HOSTNAME[:PORT] so implies localhost for host should be fine?

localhost if fine but when using docker the localhost of the container is different than the one where ES runs.

@objectiser
Copy link
Contributor

Still getting same error even using:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:5.6.3

docker run --network host test/jaeger-es-rollover init localhost

so looks like it is not to do with localhost, but schema?

@objectiser
Copy link
Contributor

The command that worked is:

docker run --network host test/jaeger-es-rollover init http://localhost:9200

so looks like the usage message needs to be updated to change host:[port] to url?

@objectiser
Copy link
Contributor

@pavolloffay Tested without index prefix and all worked great. When I then restarted ES and ran:

docker run --network host -e INDEX_PREFIX=test test/jaeger-es-rollover init http://localhost:9200

I got:

$ curl http://localhost:9200/_cat/aliases
test-jaeger-service-read  jaeger-service-000001 - - -
test-jaeger-service-write jaeger-service-000001 - - -
test-jaeger-span-read     jaeger-span-000001    - - -
test-jaeger-span-write    jaeger-span-000001    - - -

$ curl http://localhost:9200/_cat/indices
yellow open .watches                    YiM56sWTRvKYiSqjglbC1Q 1 1  4  0  35.4kb  35.4kb
yellow open jaeger-service-000001       8dkgLAPTQ0-JNL4WDLV4ig 5 1  0  0    810b    810b
yellow open .monitoring-es-6-2019.02.08 y2H-_7sTRf6kSw_BmJAoow 1 1 65 32 251.5kb 251.5kb
yellow open jaeger-span-000001          vdVviIpURbu54oywhCEN1Q 5 1  0  0    810b    810b

Shouldn't the indexes also have the prefix?

@pavolloffay pavolloffay mentioned this pull request Feb 8, 2019
4 tasks
Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

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

Some usage text to update - also appears some failure on travis that needs to be investigated. But otherwise have tested the rollover commands and work great.


def main():
if len(sys.argv) != 3:
print('USAGE: [INDEX_PREFIX=(default "")] [ARCHIVE=(default false)] [CONDITIONS=(default {})] [UNIT=(default {})] [UNIT_COUNT=(default {})] {} ACTION HOSTNAME[:PORT]'.format(ROLLBACK_CONDITIONS, UNIT, UNIT_COUNT, sys.argv[0]))
print('USAGE: [INDEX_PREFIX=(default "")] [ARCHIVE=(default false)] [SHARDS=(default {})] [REPLICAS=(default {})] [CONDITIONS=(default {})] [UNIT=(default {})] [UNIT_COUNT=(default {})] {} ACTION HOSTNAME[:PORT]'.format(SHARDS, REPLICAS, ROLLBACK_CONDITIONS, UNIT, UNIT_COUNT, sys.argv[0]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update HOSTNAME[:PORT] to be URL, as only seems to work when specifying http://<host>:9200.


def main():
if len(sys.argv) != 3:
print('USAGE: [INDEX_PREFIX=(default "")] [ARCHIVE=(default false)] [CONDITIONS=(default {})] [UNIT=(default {})] [UNIT_COUNT=(default {})] {} ACTION HOSTNAME[:PORT]'.format(ROLLBACK_CONDITIONS, UNIT, UNIT_COUNT, sys.argv[0]))
print('USAGE: [INDEX_PREFIX=(default "")] [ARCHIVE=(default false)] [SHARDS=(default {})] [REPLICAS=(default {})] [CONDITIONS=(default {})] [UNIT=(default {})] [UNIT_COUNT=(default {})] {} ACTION HOSTNAME[:PORT]'.format(SHARDS, REPLICAS, ROLLBACK_CONDITIONS, UNIT, UNIT_COUNT, sys.argv[0]))
print('ACTION ... one of:')
print('\tinit - creates archive index and aliases')
print('\trollover - rollover to new write index')
print('\tlookback - removes old indices from read alias')
print('HOSTNAME ... specifies which ElasticSearch hosts to search and delete indices from.')
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above - needs to be URL.

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

codecov bot commented Feb 12, 2019

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1309   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         162     162           
  Lines        7282    7295   +13     
======================================
+ Hits         7282    7295   +13
Impacted Files Coverage Δ
plugin/storage/es/options.go 100% <100%> (ø) ⬆️
plugin/storage/es/spanstore/writer.go 100% <100%> (ø) ⬆️
plugin/storage/es/factory.go 100% <100%> (ø) ⬆️
plugin/storage/es/spanstore/reader.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 307c62b...5599108. Read the comment docs.

@pavolloffay pavolloffay merged commit 80b3dbb into jaegertracing:master Feb 12, 2019
@ghost ghost removed the review label Feb 12, 2019
iori-yja pushed a commit to iori-yja/jaeger that referenced this pull request Feb 15, 2019
* Add support for rollover to main indices

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Add prefix

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix test-ci

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping in ES itest

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Iori Yoneji <fivo.11235813@gmail.com>
iori-yja pushed a commit to iori-yja/jaeger that referenced this pull request Feb 15, 2019
* Add support for rollover to main indices

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Add prefix

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix test-ci

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping in ES itest

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
iori-yja pushed a commit to iori-yja/jaeger that referenced this pull request Feb 15, 2019
* Add support for rollover to main indices

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Add prefix

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix test-ci

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping in ES itest

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
iori-yja pushed a commit to iori-yja/jaeger that referenced this pull request Feb 15, 2019
* Add support for rollover to main indices

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Add prefix

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix test-ci

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix mapping in ES itest

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants