← Back to team overview

canonical-ubuntu-qa team mailing list archive

Re: [Merge] ~andersson123/autopkgtest-cloud:s-n-r-prepend-series-version-to-uuid into autopkgtest-cloud:master

 


Diff comments:

> diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release
> index ca047b6..43732af 100755
> --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release
> +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/seed-new-release
> @@ -7,12 +7,59 @@
>  from __future__ import print_function
>  
>  import argparse
> +import io
> +import json
>  import os
>  import sqlite3
>  import sys
> +import tarfile
> +import tempfile
>  import time
>  
>  import swiftclient
> +from distro_info import UbuntuDistroInfo
> +
> +
> +def prepend_old_series_version_to_uuid(contents, old_series_version):
> +    try:
> +        object_tar_bytes = io.BytesIO(contents)
> +        result_tar = {}
> +        temp_dir = tempfile.TemporaryDirectory()
> +        result_dir = temp_dir.name + "/result"
> +        os.makedirs(result_dir)
> +        # try:

remove

> +        testinfo = {}
> +        with tarfile.open(None, "r", object_tar_bytes) as tar:
> +            testinfo = json.loads(
> +                tar.extractfile("testinfo.json").read().decode()
> +            )
> +            testinfo["uuid"] = old_series_version + "-" + testinfo["uuid"]

change to fstring

> +            existing_files = tar.getnames()
> +            for f in existing_files:
> +                result_tar[f] = tar.extractfile(f).read().decode().strip()
> +        result_tar["testinfo.json"] = testinfo
> +        # write the files to new directory for tar'ing
> +        for file_name, values in result_tar.items():
> +            with open(f"{result_dir}/{file_name}", "w") as f:
> +                if file_name.endswith(".json"):
> +                    json.dump(values, f)
> +                else:
> +                    f.write(values)
> +        # tar up the directory
> +        output_result_tar = temp_dir.name + "/result.tar"
> +        with tarfile.open(output_result_tar, "w") as tar:
> +            for fn in os.listdir(result_dir):
> +                p = os.path.join(result_dir, fn)
> +                tar.add(p, arcname=fn)
> +        new_content = None
> +        with open(output_result_tar, "rb") as f:
> +            new_content = f.read()
> +        return new_content
> +    except Exception as e:
> +        print(f"Modifying uuid failed with {e} - not modifying")
> +        return contents
> +    finally:
> +        temp_dir.cleanup()
>  
>  
>  def srchash(src):
> @@ -62,6 +109,14 @@ def copy_result(rel_path, source, target, retries=0):
>          except KeyError:
>              pass
>  
> +    if "result.tar" in from_path:
> +        old_contents = contents
> +        contents = prepend_old_series_version_to_uuid(
> +            contents, old_series_version
> +        )
> +        if old_contents == contents:

perhaps a comment and some logging is required here?

> +            return
> +
>      try:
>          if not args.dry_run:
>              print("Putting %s" % to_path)
> @@ -169,8 +237,15 @@ for package, arch, run_id in db_con.execute(
>      "GROUP BY package, arch" % args.old_release
>  ):
>      copy_run_results(
> -        package, arch, run_id, args, source_container, target_container
> +        package,
> +        arch,
> +        run_id,
> +        args,
> +        source_container,
> +        target_container,
> +        args.old_release,
>      )
> +    sys.exit(0)

remove

>  
>  for package, arch, run_id in db_con.execute(
>      "SELECT package, arch, MAX(run_id) "


-- 
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/470103
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:s-n-r-prepend-series-version-to-uuid into autopkgtest-cloud:master.



Follow ups