From 0e6836ee1f6b3b7f6c3cb6af7ae5cea401c40bce Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 3 Oct 2020 00:13:51 +0300 Subject: [PATCH 1/6] build(docker): Start building Python 3 images --- docker/Dockerfile | 4 ++-- docker/cloudbuild.yaml | 48 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 62ebe885ed2934..ccbb489334621e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ -# This is the image to be run -FROM python:2.7.16-slim-buster +ARG PY_VER=2.7.16 +FROM python:${PY_VER}-slim-buster LABEL maintainer="oss@sentry.io" LABEL org.opencontainers.image.title="Sentry" diff --git a/docker/cloudbuild.yaml b/docker/cloudbuild.yaml index 3372f737db6998..fc41ff26d3deab 100644 --- a/docker/cloudbuild.yaml +++ b/docker/cloudbuild.yaml @@ -1,5 +1,6 @@ steps: - name: 'gcr.io/kaniko-project/executor:v0.22.0' + id: builder-image args: [ '--cache=true', '--build-arg', 'SOURCE_COMMIT=$COMMIT_SHA', @@ -8,11 +9,15 @@ steps: ] timeout: 180s - name: 'us.gcr.io/$PROJECT_ID/sentry-builder:$COMMIT_SHA' + id: builder-run env: [ 'SOURCE_COMMIT=$COMMIT_SHA' ] timeout: 360s - name: 'gcr.io/kaniko-project/executor:v0.22.0' + id: runtime-image-py2 + waitFor: + - builder-run args: [ '--cache=true', '--build-arg', 'SOURCE_COMMIT=$COMMIT_SHA', @@ -20,8 +25,22 @@ steps: '-f', './docker/Dockerfile' ] timeout: 300s -# Smoke tests +- name: 'gcr.io/kaniko-project/executor:v0.22.0' + id: runtime-image-py3 + waitFor: + - builder-run + args: [ + '--cache=true', + '--build-arg', 'SOURCE_COMMIT=$COMMIT_SHA', + '--build-arg', 'PY_VER=3.6', + '--destination=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA-py3', + '-f', './docker/Dockerfile' + ] + timeout: 300s - name: 'gcr.io/$PROJECT_ID/docker-compose' + id: e2e-test-py2 + waitFor: + runtime-image-py2 entrypoint: 'bash' env: - 'SENTRY_IMAGE=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA' @@ -33,12 +52,34 @@ steps: - | mkdir onpremise && cd onpremise curl -L "https://github.com/getsentry/onpremise/archive/master.tar.gz" | tar xzf - --strip-components=1 - # The following trick is from https://stackoverflow.com/a/52400857/90297 with great gratuity echo '{"version": "3.4", "networks":{"default":{"external":{"name":"cloudbuild"}}}}' > docker-compose.override.yml ./install.sh ./test.sh || docker-compose logs nginx web relay timeout: 450s +- name: 'gcr.io/$PROJECT_ID/docker-compose' + id: e2e-test-py3 + waitFor: + - runtime-image-py3 + entrypoint: 'bash' + env: + - 'SENTRY_IMAGE=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA-py3' + - 'SENTRY_TEST_HOST=http://nginx' + - 'CI=1' + args: + - '-e' + - '-c' + - | + mkdir onpremise && cd onpremise + curl -L "https://github.com/getsentry/onpremise/archive/master.tar.gz" | tar xzf - --strip-components=1 + echo '{"version": "3.4", "networks":{"default":{"external":{"name":"cloudbuild"}}}}' > docker-compose.override.yml + ./install.sh + ./test.sh || docker-compose logs nginx web relay + timeout: 450s + - name: 'gcr.io/cloud-builders/docker' + id: docker-push + waitFor: + - e2e-test-py2 secretEnv: ['DOCKER_PASSWORD'] entrypoint: 'bash' args: @@ -57,6 +98,9 @@ steps: docker tag us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA getsentry/sentry:latest docker push getsentry/sentry:latest - name: 'node:12' + id: zeus-upload + waitFor: + - builder-run secretEnv: ['ZEUS_HOOK_BASE'] entrypoint: 'bash' args: From dca3bc57c4cef01504885c14a7867773fa4f585c Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 3 Oct 2020 00:16:04 +0300 Subject: [PATCH 2/6] fix yaml --- docker/cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/cloudbuild.yaml b/docker/cloudbuild.yaml index fc41ff26d3deab..048a7550bd0043 100644 --- a/docker/cloudbuild.yaml +++ b/docker/cloudbuild.yaml @@ -40,7 +40,7 @@ steps: - name: 'gcr.io/$PROJECT_ID/docker-compose' id: e2e-test-py2 waitFor: - runtime-image-py2 + - runtime-image-py2 entrypoint: 'bash' env: - 'SENTRY_IMAGE=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA' From 94482c2f8b80753cc3cd6991abca9a0a6820433d Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 3 Oct 2020 00:29:36 +0300 Subject: [PATCH 3/6] don't run e2e tests in parallel --- docker/cloudbuild.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/cloudbuild.yaml b/docker/cloudbuild.yaml index 048a7550bd0043..6146fab504efa7 100644 --- a/docker/cloudbuild.yaml +++ b/docker/cloudbuild.yaml @@ -60,6 +60,7 @@ steps: id: e2e-test-py3 waitFor: - runtime-image-py3 + - e2e-test-py2 entrypoint: 'bash' env: - 'SENTRY_IMAGE=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA-py3' From 97b5dea9eb2316de9c001d53e6e08e5e85d867ac Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 3 Oct 2020 00:52:18 +0300 Subject: [PATCH 4/6] strictly pin py3 version --- docker/cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/cloudbuild.yaml b/docker/cloudbuild.yaml index 6146fab504efa7..0eacf37796ae49 100644 --- a/docker/cloudbuild.yaml +++ b/docker/cloudbuild.yaml @@ -32,7 +32,7 @@ steps: args: [ '--cache=true', '--build-arg', 'SOURCE_COMMIT=$COMMIT_SHA', - '--build-arg', 'PY_VER=3.6', + '--build-arg', 'PY_VER=3.6.10', '--destination=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA-py3', '-f', './docker/Dockerfile' ] From 625b348da53d5d8784d8f85fb72521565b84f865 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 3 Oct 2020 02:04:43 +0300 Subject: [PATCH 5/6] py3 fixes -- temporary, will separate --- requirements-base.txt | 2 +- src/sentry/runner/importer.py | 10 ++++++---- src/sentry/utils/compat/__init__.py | 11 +++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/requirements-base.txt b/requirements-base.txt index 7b759a43dd5c74..4e2d5044412529 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -2,7 +2,7 @@ beautifulsoup4>=4.7.1,<4.8 boto3>=1.4.1,<1.4.6 botocore<1.5.71 celery==4.4.7 -click>=5.0,<7.0 +click==7.1.2 confluent-kafka==1.5.0 croniter>=0.3.34,<0.4.0 datadog>=0.15.0,<0.31.0 diff --git a/src/sentry/runner/importer.py b/src/sentry/runner/importer.py index 35c9187592f17e..4a164b8486f014 100644 --- a/src/sentry/runner/importer.py +++ b/src/sentry/runner/importer.py @@ -1,11 +1,13 @@ from __future__ import absolute_import, print_function -import imp +import io import six import sys import click +from sentry.utils.compat import new_module + def install(name, config_path, default_settings, callback=None): sys.meta_path.append(Importer(name, config_path, default_settings, callback)) @@ -66,7 +68,7 @@ def _load_module(self, fullname): else: default_settings_mod = None - settings_mod = imp.new_module(self.name) + settings_mod = new_module(self.name) # Django doesn't play too nice without the config file living as a real # file, so let's fake it. @@ -85,11 +87,11 @@ def _load_module(self, fullname): def load_settings(mod_or_filename, settings, silent=False): if isinstance(mod_or_filename, six.string_types): - conf = imp.new_module("temp_config") + conf = new_module("temp_config") conf.__file__ = mod_or_filename try: - with open(mod_or_filename) as source_file: + with io.open(mod_or_filename, mode="rb") as source_file: six.exec_(source_file.read(), conf.__dict__) except IOError as e: import errno diff --git a/src/sentry/utils/compat/__init__.py b/src/sentry/utils/compat/__init__.py index eae3ea688151e5..deb11826238df2 100644 --- a/src/sentry/utils/compat/__init__.py +++ b/src/sentry/utils/compat/__init__.py @@ -53,6 +53,12 @@ def implements_bool(cls): from binascii import crc32 + import imp + + def new_module(name): + return imp.new_module(name) + + else: implements_to_string = _identity implements_iterator = _identity @@ -78,3 +84,8 @@ def implements_bool(cls): def crc32(*args): rt = _crc32(*args) return rt - ((rt & 0x80000000) << 1) + + import types + + def new_module(name): + return types.ModuleType(name) From a2ab486098267bfe30e1c2362576390d26764bf8 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 3 Oct 2020 02:44:44 +0300 Subject: [PATCH 6/6] revert click upgrade, fix actual error thingy --- requirements-base.txt | 2 +- src/sentry/runner/importer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-base.txt b/requirements-base.txt index 4e2d5044412529..7b759a43dd5c74 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -2,7 +2,7 @@ beautifulsoup4>=4.7.1,<4.8 boto3>=1.4.1,<1.4.6 botocore<1.5.71 celery==4.4.7 -click==7.1.2 +click>=5.0,<7.0 confluent-kafka==1.5.0 croniter>=0.3.34,<0.4.0 datadog>=0.15.0,<0.31.0 diff --git a/src/sentry/runner/importer.py b/src/sentry/runner/importer.py index 4a164b8486f014..956fc26ab57bde 100644 --- a/src/sentry/runner/importer.py +++ b/src/sentry/runner/importer.py @@ -19,7 +19,7 @@ def show(self, file=None): from click._compat import get_text_stderr file = get_text_stderr() - click.secho("!! Configuration error: %s" % self.format_message(), file=file, fg="red") + click.secho("!! Configuration error: %s" % str(self), file=file, fg="red") class Importer(object):