FBR: Make new-updates-sync resync on re-stage without need for state deletion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

So, for now (until https://github.com/fedora-infra/bodhi/pull/1986 gets finished and merged), it might happen that Bodhi stages a repo a second time (if it crashed while waiting for sync), which new-updates-sync doesn't notice, meaning releng needs to manually clean up the state file.
This patch should make new-updates-sync detect this case and force a resync.
Can I get +1s?

Patrick


diff --git a/roles/bodhi2/backend/files/new-updates-sync b/roles/bodhi2/backend/files/new-updates-sync
index fba2a3d27..df59cd421 100755
--- a/roles/bodhi2/backend/files/new-updates-sync
+++ b/roles/bodhi2/backend/files/new-updates-sync
@@ -328,6 +328,28 @@ def sync_single_release(release):
                 with open(curstatefile, 'r') as f:
                     curstate = f.read().split()[0]
 
+            # Resync if Bodhi failed out during the sync waiting, which leads
+            # to changed repomd.xml without an updated repo.
+            # (updateinfo is inserted again)
+            # Fix: https://github.com/fedora-infra/bodhi/pull/1986
+            if curstate and curstate == target:
+                curstatestat = os.stat(curstatefile)
+                repostat = os.stat(os.path.join(
+                    target, 'compose', 'Everything',
+                    RELEASES[release]['repos'][repo]['to'][0]['arches'][0],
+                    'os', 'repodata', 'repomd.xml'))
+                if curstatestat[stat.ST_MTIME] < repostat[stat.ST_MTIME]:
+                    # If the curstate file has an earlier mtime than the repomd
+                    # of the first architecture, this repo was re-generated
+                    # after the first time it got staged. Resync.
+                    logger.error(
+                        'Re-stage detected of %s %s. '
+                        'State mtime: %s, repo mtime: %s',
+                        release, repo,
+                        curstatestat[stat.ST_MTIME],
+                        repostat[stat.ST_MTIME])
+                    curstate = None
+
             if curstate and curstate == target:
                 logger.info('This repo has already been synced')
             else:
_______________________________________________
infrastructure mailing list -- infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to infrastructure-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux