#2212 kojid: remove bootstrap dir
Merged 3 years ago by tkopecek. Opened 3 years ago by tkopecek.
tkopecek/koji issue1988  into  master

file modified
+21 -8
@@ -45,7 +45,8 @@ 

      base64encode,

      dslice,

      parseStatus,

-     to_list

+     to_list,

+     joinpath,

  )

  

  
@@ -728,6 +729,9 @@ 

                              continue

                      else:

                          age = min(age, time.time() - st.st_mtime)

+                 topdir_bootstrap = "%s-bootstrap" % topdir

+                 if not os.path.exists(topdir_bootstrap):

+                     topdir_bootstrap = None

                  # note: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=192153)

                  # If rpmlib is installing in this chroot, removing it entirely

                  # can lead to a world of hurt.
@@ -736,27 +740,36 @@ 

                  if age > 3600 * 24:

                      # dir untouched for a day

                      self.logger.info("Removing buildroot: %s" % desc)

-                     if topdir and safe_rmtree(topdir, unmount=True, strict=False) != 0:

+                     if ((topdir and safe_rmtree(topdir, unmount=True, strict=False) != 0) or

+                         (topdir_bootstrap and

+                             safe_rmtree(topdir_bootstrap, unmount=True, strict=False) != 0)):

                          continue

                      # also remove the config

                      try:

                          os.unlink(data['cfg'])

                      except OSError as e:

                          self.logger.warning("%s: can't remove config: %s" % (desc, e))

-                 elif age > 120:

-                     if rootdir:

+                 elif age > 120 and rootdir:

+                     for d in (topdir, topdir_bootstrap):

+                         if not d:

+                             continue

+                         if d == topdir_bootstrap:

+                             desc2 = "%s [bootstrap]" % desc

+                         else:

+                             desc2 = desc

+                         rootdir = joinpath(d, 'root')

                          try:

                              flist = os.listdir(rootdir)

                          except OSError as e:

-                             self.logger.warning("%s: can't list rootdir: %s" % (desc, e))

+                             self.logger.warning("%s: can't list rootdir: %s" % (desc2, e))

                              continue

                          if flist:

-                             self.logger.info("%s: clearing rootdir" % desc)

+                             self.logger.info("%s: clearing rootdir" % desc2)

                          for fn in flist:

                              safe_rmtree("%s/%s" % (rootdir, fn), unmount=True, strict=False)

-                         resultdir = "%s/result" % topdir

+                         resultdir = "%s/result" % d

                          if os.path.isdir(resultdir):

-                             self.logger.info("%s: clearing resultdir" % desc)

+                             self.logger.info("%s: clearing resultdir" % desc2)

                              safe_rmtree(resultdir, unmount=True, strict=False)

                  else:

                      self.logger.debug("Recent buildroot: %s: %i seconds" % (desc, age))

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

3 years ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

3 years ago

this condition should be age > 3600 * 24 still

rebased onto 0ba1b03

3 years ago

Commit 9e4148e fixes this pull-request

Pull-Request has been merged by tkopecek

3 years ago