From 9f87266007c1f41fd6bf39800b374bac9ea58172 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Mon, 13 Nov 2023 02:22:42 -0700 Subject: [PATCH] stop using fpsync --- .../empanadas/scripts/finalize_compose.py | 2 ++ iso/empanadas/empanadas/util/dnf_utils.py | 8 ++++--- iso/empanadas/empanadas/util/shared.py | 23 ++++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/iso/empanadas/empanadas/scripts/finalize_compose.py b/iso/empanadas/empanadas/scripts/finalize_compose.py index d9422fe..4e349b8 100755 --- a/iso/empanadas/empanadas/scripts/finalize_compose.py +++ b/iso/empanadas/empanadas/scripts/finalize_compose.py @@ -12,6 +12,7 @@ parser = argparse.ArgumentParser(description="Peridot Sync and Compose") # All of our options parser.add_argument('--release', type=str, help="Major Release Version or major-type (eg 9-beta)", required=True) parser.add_argument('--arch', type=str, help="Architecture") +parser.add_argument('--fpsync', type=str, help="Use fpsync instead of rsync") parser.add_argument('--logger', type=str) # Parse them @@ -28,6 +29,7 @@ a = RepoSync( config, major=major, arch=results.arch, + fpsync=results.fpsync, logger=results.logger, ) diff --git a/iso/empanadas/empanadas/util/dnf_utils.py b/iso/empanadas/empanadas/util/dnf_utils.py index d3a17a1..2aded86 100644 --- a/iso/empanadas/empanadas/util/dnf_utils.py +++ b/iso/empanadas/empanadas/util/dnf_utils.py @@ -63,6 +63,7 @@ class RepoSync: just_pull_everything: bool = False, extra_dnf_args=None, reposync_clean_old: bool = False, + fpsync: bool = False, logger=None ): self.nofail = nofail @@ -76,6 +77,7 @@ class RepoSync: self.repoclosure = repoclosure self.refresh_extra_files = refresh_extra_files self.refresh_treeinfo = refresh_treeinfo + self.fpsync = fpsync # Enables podman syncing, which should effectively speed up operations self.parallel = parallel # This makes it so every repo is synced at the same time. @@ -1406,7 +1408,7 @@ class RepoSync: # Standard ISOs self.log.info(Color.INFO + 'Starting to sync ISOs to compose') - if os.path.exists('/usr/bin/fpsync'): + if os.path.exists('/usr/bin/fpsync') and self.fpsync: self.log.info(Color.INFO + 'Starting up fpsync') message, ret = Shared.fpsync_method(iso_root, sync_iso_root, tmp_dir) elif os.path.exists('/usr/bin/parallel') and os.path.exists('/usr/bin/rsync'): @@ -1430,7 +1432,7 @@ class RepoSync: if os.path.exists(live_root): self.log.info(Color.INFO + 'Starting to sync live images to compose') - if os.path.exists('/usr/bin/fpsync'): + if os.path.exists('/usr/bin/fpsync') and self.fpsync: message, ret = Shared.fpsync_method(live_root, sync_live_root, tmp_dir) elif os.path.exists('/usr/bin/parallel') and os.path.exists('/usr/bin/rsync'): message, ret = Shared.rsync_method(live_root, sync_live_root) @@ -1444,7 +1446,7 @@ class RepoSync: if os.path.exists(images_root): self.log.info(Color.INFO + 'Starting to sync cloud images to compose') - if os.path.exists('/usr/bin/fpsync'): + if os.path.exists('/usr/bin/fpsync') and self.fpsync: message, ret = Shared.fpsync_method(images_root, sync_images_root, tmp_dir) elif os.path.exists('/usr/bin/parallel') and os.path.exists('/usr/bin/rsync'): message, ret = Shared.rsync_method(images_root, sync_images_root) diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index 98381e0..07f4e34 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -564,12 +564,29 @@ class Shared: """ find_cmd = '/usr/bin/find' parallel_cmd = '/usr/bin/parallel' - rsync_cmd = '/usr/bin/rsync' + cmd = '/usr/bin/rsync' switches = '-av --chown=10004:10005 --progress --relative --human-readable' + rsync_cmd = '{} {} {}/ {}'.format(cmd, switches, src, dest) - os.makedirs(dest, exist_ok=True) + #os.makedirs(dest, exist_ok=True) + process = subprocess.call( + shlex.split(rsync_cmd), + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + if process != 0: + message = 'Syncing (rsync) failed' + retval = process + return message, retval - return 'Not available', 1 + if os.path.exists(dest): + message = 'Syncing (rsync) succeeded' + retval = process + else: + message = 'Path synced does not seem to exist for some reason.' + retval = 1 + + return message, retval @staticmethod def s3_determine_latest(s3_bucket, release, arches, filetype, name, logger):