У меня проблемы с выполнением скрипта ниже Python.это работало в течение пары раз, и позже это начало вызывать у меня проблемы.ниже сценарий и его вывод.
import boto3
from requests_aws4auth import AWS4Auth
from elasticsearch import Elasticsearch, RequestsHttpConnection
import curator
host = 'search-xxxx-xxxxx-xxxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxxxxxxxx.us-east-1.es.amazonaws.com' # For example, search-my-domain.region.es.amazonaws.com
region = 'us-east-1' # For example, us-west-1
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)
# Build the Elasticsearch client.
es = Elasticsearch(
hosts = [{'host': host, 'port': 443}],
http_auth = awsauth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection
)
index_list = curator.IndexList(es)
# Filters by age, anything with a time stamp older than 30 days in the index name.
index_list.filter_by_age(source='name', direction='older', timestring='%Y.%m.%d', unit='days', unit_count=67)
print("Found %s indices to delete" % len(index_list.indices))
ниже - ошибка, которую я получаю.
[root@8bd6e182566c ~]# python -d testpy.py
Traceback (most recent call last):
File "testpy.py", line 21, in <module>
index_list = curator.IndexList(es)
File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 31, in __init__
self.__get_indices()
File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 72, in __get_indices
self._get_index_stats()
File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 149, in _get_index_stats
iterate_over_stats(stats_result)
File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 121, in iterate_over_stats
for index in stats['indices']:
Я на самом деле запускаю этот скрипт из контейнера Docker.и ниже находится докер-файл.
FROM alpine:3.7
RUN apk --no-cache add bash python py-setuptools py-pip gcc libffi py-cffi python-dev libffi-dev py-openssl musl-dev linux-headers openssl-dev libssl1.0
RUN pip install elasticsearch-curator==5.6.0 && \
pip install boto3==1.9.59 && \
pip install requests-aws4auth==0.9 && \
pip install cryptography && \
sed -i '/import sys/a urllib3.contrib.pyopenssl.inject_into_urllib3()' /usr/bin/curator && \
sed -i '/import sys/a import urllib3.contrib.pyopenssl' /usr/bin/curator && \
sed -i '/import sys/a import urllib3' /usr/bin/curator
ENTRYPOINT ["/usr/bin/curator"]