#5 Add patches fixing a problem with Python3 and compatibility with current ODCS
Closed 5 years ago by cverna. Opened 6 years ago by otaylor.
rpms/ otaylor/atomic-reactor python3-and-odcs-fixes-f27  into  f27

file modified
+11 -1
@@ -32,7 +32,7 @@ 

  

  Name:           %{project}

  Version:        1.6.29

- Release:        2%{?dist}

+ Release:        3%{?dist}

  

  Summary:        Improved builder for Docker images

  Group:          Development/Tools
@@ -53,6 +53,11 @@ 

  # https://github.com/projectatomic/atomic-reactor/pull/906

  Patch1:         atomic-reactor-fix-multiarch-test.patch

  

+ # https://github.com/projectatomic/atomic-reactor/pull/920

+ Patch2:         git-commit-id-as-string.patch

+ # https://github.com/projectatomic/atomic-reactor/pull/921

+ Patch3:         module-version-format.patch

+ 

  BuildArch:      noarch

  

  %if 0%{?with_check}
@@ -247,6 +252,8 @@ 

  

  %patch0 -p0

  %patch1 -p1

+ %patch2 -p1

+ %patch3 -p1

  

  %build

  %py2_build
@@ -432,6 +439,9 @@ 

  

  

  %changelog

+ * Fri Feb 16 2018 Owen Taylor <otaylor@redhat.com> - 1.6.29-3

+ - Add patches fixing a problem with Python3 and compatibility with current ODCS

+ 

  * Thu Feb 01 2018 Clement Verna <cverna@fedoraproject.orf> - 1.6.29-2

  - Added patch to fix unit test on multi arch

  - Build Requires osbs-client version 0.45 for unit test

@@ -0,0 +1,43 @@ 

+ From fb609e6121bf5674a270050bb3dfa379995a293b Mon Sep 17 00:00:00 2001

+ From: "Owen W. Taylor" <otaylor@fishsoup.net>

+ Date: Thu, 15 Feb 2018 14:17:37 -0500

+ Subject: [PATCH] util.py: make sure that the git commit ID is a string, not

+  bytes

+ 

+ subprocess.check_output() by default returns bytes for python3. Using

+ universal_newlines=True is a trick to get strings for both python2

+ and python3, since the encoding option is python3 only.

+ ---

+  atomic_reactor/util.py | 2 +-

+  tests/test_util.py     | 2 +-

+  2 files changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/atomic_reactor/util.py b/atomic_reactor/util.py

+ index 8d6fa29..ba8d51a 100644

+ --- a/atomic_reactor/util.py

+ +++ b/atomic_reactor/util.py

+ @@ -276,7 +276,7 @@ def clone_git_repo(git_url, target_dir, commit=None, retry_times=GIT_MAX_RETRIES

+      subprocess.check_call(cmd, cwd=target_dir)

+      cmd = ["git", "rev-parse", "HEAD"]

+      logger.debug("getting SHA-1 of provided ref '%s'", cmd)

+ -    commit_id = subprocess.check_output(cmd, cwd=target_dir)

+ +    commit_id = subprocess.check_output(cmd, cwd=target_dir, universal_newlines=True)

+      commit_id = commit_id.strip()

+      logger.info("commit ID = %s", commit_id)

+      return commit_id

+ diff --git a/tests/test_util.py b/tests/test_util.py

+ index cd8abca..e50f74f 100644

+ --- a/tests/test_util.py

+ +++ b/tests/test_util.py

+ @@ -153,7 +153,7 @@ def test_clone_git_repo_by_sha1(tmpdir):

+      tmpdir_path = str(tmpdir.realpath())

+      commit_id = clone_git_repo(DOCKERFILE_GIT, tmpdir_path, commit=DOCKERFILE_SHA1)

+      assert commit_id is not None

+ -    assert six.text_type(commit_id, encoding="ascii") == six.text_type(DOCKERFILE_SHA1)

+ +    assert commit_id == DOCKERFILE_SHA1

+      assert len(commit_id) == 40  # current git hashes are this long

+      assert os.path.isdir(os.path.join(tmpdir_path, '.git'))

+  

+ -- 

+ 2.14.3

+ 

@@ -0,0 +1,84 @@ 

+ From a16599c827e475c65dc5709b067283cef37931e1 Mon Sep 17 00:00:00 2001

+ From: "Owen W. Taylor" <otaylor@fishsoup.net>

+ Date: Thu, 15 Feb 2018 14:32:17 -0500

+ Subject: [PATCH] pre_resolve_module_compose.py: Handle change to module

+  separator

+ 

+ It was officially decided that module versions are formatted as N:V:R not N-V-R.

+ ODCS on input accepts either, so keep on passing N-V-R, but we need to accept

+ N:V:R if we receive it.

+ ---

+  atomic_reactor/plugins/pre_resolve_module_compose.py |  7 ++++++-

+  tests/plugins/test_resolve_module_compose.py         | 11 ++++++-----

+  2 files changed, 12 insertions(+), 6 deletions(-)

+ 

+ diff --git a/atomic_reactor/plugins/pre_resolve_module_compose.py b/atomic_reactor/plugins/pre_resolve_module_compose.py

+ index f5e076e..3eed644 100644

+ --- a/atomic_reactor/plugins/pre_resolve_module_compose.py

+ +++ b/atomic_reactor/plugins/pre_resolve_module_compose.py

+ @@ -138,6 +138,8 @@ class ResolveModuleComposePlugin(PreBuildPlugin):

+          # makes things simpler.

+          pdc_client = PDCClient(server=self.pdc_url, ssl_verify=not self.pdc_insecure, develop=True)

+  

+ +        # The module separator was changed from '-' to ':'. Older versions of ODCS only accept

+ +        # '-' as a separator, newer versions accept either. Use '-' for compatibility.

+          fmt = '{n}-{s}' if self.module_version is None else '{n}-{s}-{v}'

+          source_spec = fmt.format(n=self.module_name, s=self.module_stream, v=self.module_version)

+  

+ @@ -156,7 +158,10 @@ class ResolveModuleComposePlugin(PreBuildPlugin):

+          resolved_modules = {}

+  

+          for module_spec in compose_source.strip().split():

+ -            m = re.match(r'^(.*)-([^-]+)-(\d{14})$', module_spec)

+ +            m = re.match(r'^(.*):([^-]+):(\d{14})$', module_spec)

+ +            if not m:

+ +                # Older versions of ODCS return '-' as the separator

+ +                m = re.match(r'^(.*)-([^-]+)-(\d{14})$', module_spec)

+              if not m:

+                  raise RuntimeError("Cannot parse resolved module in compose: %s" % module_spec)

+  

+ diff --git a/tests/plugins/test_resolve_module_compose.py b/tests/plugins/test_resolve_module_compose.py

+ index 9632165..7d5a0ba 100644

+ --- a/tests/plugins/test_resolve_module_compose.py

+ +++ b/tests/plugins/test_resolve_module_compose.py

+ @@ -88,13 +88,13 @@ LATEST_VERSION_JSON = [{"modulemd": FLATPAK_APP_MODULEMD,

+                          "rpms": FLATPAK_APP_RPMS}]

+  

+  

+ -def compose_json(state, state_name):

+ +def compose_json(state, state_name, module_version_colon=True):

+      return json.dumps({

+          "flags": [],

+          "id": 84,

+          "owner": "Unknown",

+          "result_repo": "http://odcs.fedoraproject.org/composes/latest-odcs-84-1/compose/Temporary",

+ -        "source": MODULE_NSV,

+ +        "source": MODULE_NSV.replace('-', ':') if module_version_colon else MODULE_NSV,

+          "source_type": 2,

+          "state": state,

+          "state_name": state_name

+ @@ -105,7 +105,8 @@ def compose_json(state, state_name):

+  @pytest.mark.skipif(not MODULEMD_AVAILABLE,

+                      reason="modulemd not available")

+  @pytest.mark.parametrize('specify_version', [True, False])

+ -def test_resolve_module_compose(tmpdir, docker_tasker, specify_version):

+ +@pytest.mark.parametrize('module_version_colon', [True, False])

+ +def test_resolve_module_compose(tmpdir, docker_tasker, specify_version, module_version_colon):

+      secrets_path = os.path.join(str(tmpdir), "secret")

+      os.mkdir(secrets_path)

+      with open(os.path.join(secrets_path, "token"), "w") as f:

+ @@ -139,9 +140,9 @@ def test_resolve_module_compose(tmpdir, docker_tasker, specify_version):

+          assert request.headers['Authorization'] == 'Bearer green_eggs_and_ham'

+  

+          if state['count'] == 1:

+ -            response_json = compose_json(1, 'generating')

+ +            response_json = compose_json(1, 'generating', module_version_colon=module_version_colon)

+          else:

+ -            response_json = compose_json(2, 'done')

+ +            response_json = compose_json(2, 'done', module_version_colon=module_version_colon)

+          state['count'] += 1

+  

+          return (200, {}, response_json)

+ -- 

+ 2.14.3

+ 

https://github.com/projectatomic/atomic-reactor/pull/920
https://github.com/projectatomic/atomic-reactor/pull/921

(Note that the current upstream patch for PR#921 is different, because of changes in atomic-reactor master.)

let's close this since we now have version 1.6.31 available in rawhide and f28

Pull-Request has been closed by cverna

5 years ago