0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ElastAlertで使用するPythonを3.6より上にしてDockerコンテナ起動するとJiraのPythonライブラリで「SyntaxError: invalid syntax」が出る

Last updated at Posted at 2020-04-26

エラーメッセージの一部

09:49:15.062Z ERROR elastalert-server:
    ProcessController:  Traceback (most recent call last):
      File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/opt/elastalert/elastalert/elastalert.py", line 30, in <module>
        from .alerts import DebugAlerter
      File "/opt/elastalert/elastalert/alerts.py", line 26, in <module>
        from jira.client import JIRA
      File "/home/node/.local/lib/python3.8/site-packages/jira/__init__.py", line 10, in <module>
        from jira.client import Comment  # noqa: E402
      File "/home/node/.local/lib/python3.8/site-packages/jira/client.py", line 225
        validate=False, get_server_info=True, async=False, logging=True, max_retries=3, proxies=None,
                                              ^
    SyntaxError: invalid syntax

対処方法

version 0.2.1 broken for python 3.7 (jira) #2437

requirements.txtの「jira>=1.0.10,<1.0.15」を「jira>=2.0.0」にしている対応が取りこまれれば問題は解決するが、まだプルリクエストは取り込まれていないので、ElastAlertのDockerイメージ作成時にrequirements.txtでPythonのライブラリを実行する前にrequirements.txtの「jira>=1.0.10,<1.0.15」を「jira>=2.0.0」に書き換えるようにする。ちなみに、setup.pyは「jira>=2.0.0」になっていた。

ServerCentral/elastalert-server のDockerfileを変更

Dockerfile
FROM python:3.8.2-alpine3.11 as py-ea
ARG ELASTALERT_VERSION=v0.2.4
ENV ELASTALERT_VERSION=${ELASTALERT_VERSION}
ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip
ENV ELASTALERT_URL=${ELASTALERT_URL}
ENV ELASTALERT_HOME /opt/elastalert

WORKDIR /opt

RUN apk add --update --no-cache ca-certificates openssl-dev openssl python3-dev python3 libffi-dev gcc musl-dev wget && \
    wget -O elastalert.zip "${ELASTALERT_URL}" && \
    unzip elastalert.zip && \
    rm elastalert.zip && \
    mv e* "${ELASTALERT_HOME}"

WORKDIR "${ELASTALERT_HOME}"

RUN python3 setup.py install

FROM node:alpine
LABEL maintainer="John Susek <john@johnsolo.net>"
ENV TZ Etc/UTC

RUN apk add --update --no-cache curl tzdata python3 ca-certificates openssl-dev openssl python3-dev gcc musl-dev make libffi-dev libmagic wget

COPY --from=py-ea /usr/lib/python3.8/site-packages /usr/lib/python3.8/site-packages
COPY --from=py-ea /opt/elastalert /opt/elastalert
# COPY --from=py-ea /usr/bin/elastalert* /usr/bin/

WORKDIR /opt/elastalert-server
COPY . /opt/elastalert-server

RUN npm install --production --quiet
COPY config/elastalert.yaml /opt/elastalert/config.yaml
COPY config/config.json config/config.json
COPY rule_templates/ /opt/elastalert/rule_templates
COPY elastalert_modules/ /opt/elastalert/elastalert_modules

# Add default rules directory
# Set permission as unpriviledged user (1000:1000), compatible with Kubernetes
RUN mkdir -p /opt/elastalert/rules/ /opt/elastalert/server_data/tests/ \
    && chown -R node:node /opt

USER node

EXPOSE 3030

WORKDIR /opt/elastalert

# version 0.2.1 broken for python 3.7 (jira) #2437 (https://github.com/Yelp/elastalert/issues/2437)
RUN sed -i 's/jira>=1.0.10,<1.0.15/jira>=2.0.0/g' requirements.txt && \
    pip3 install -r requirements.txt --user

WORKDIR /opt/elastalert-server

ENTRYPOINT ["npm", "start"]

ServerCentral/elastalert-serverのGitHubのサイトでプルリクエスト

Update dockerfile for python3.8 and elastalert 0.2.4 #4

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?