[Fuego] [PATCH 11/29] ftc:rm-jobs: remove the corresponding log folders

Bird, Timothy Tim.Bird at sony.com
Tue Jul 25 00:12:04 UTC 2017


Nak - there needs to be a command line flag to control this.
Removing a job should not automatically remove the logs
associated with it.
 -- Tim


> -----Original Message-----
> From: fuego-bounces at lists.linuxfoundation.org [mailto:fuego-
> bounces at lists.linuxfoundation.org] On Behalf Of Daniel Sangorrin
> Sent: Friday, July 21, 2017 1:02 AM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH 11/29] ftc:rm-jobs: remove the corresponding log
> folders
> 
> When we remove a job from jenkins, we also want to delete
> the corresponding log folders.
> 
> Executing ftc rm-jobs will leave the logs and buildzone in
> a pristine state. This is useful when we fix something in
> Fuego but previous logs causes the code not to work.
> 
> Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
> ---
>  engine/scripts/ftc | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index e885c5f..15e0f27 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -44,7 +44,7 @@
>  import os, sys, string, re
>  import time
>  import commands
> -from shutil import copy2
> +from shutil import copy2, rmtree
>  from lxml import etree
>  import io
>  import subprocess
> @@ -57,6 +57,7 @@ import shutil
>  import tempfile
>  import yaml
>  import jenkins
> +import glob
> 
>  # MAJOR, MINOR, REVISION
>  VERSION = (1,2,0)
> @@ -1078,7 +1079,24 @@ def do_build_jobs(conf, options):
>  def do_rm_jobs(conf, options):
>      count = 0
>      if len(options) == 0:
> -        # FIXTHIS: warn user that all jobs will be removed
> +        raw_input("WARNING: this will remove all logs and generated binaries.
> Press ENTER to confirm...")
> +        # remove files and folders in LOGDIR
> +        path = conf.FUEGO_RW + "/logs/*"
> +        files = glob.glob(path)
> +        for f in files:
> +            if os.path.isfile(f):
> +                os.remove(f)
> +            else:
> +                shutil.rmtree(f, ignore_errors=True)
> +        # remove files and folders in Buildzone
> +        path = conf.FUEGO_RW + "/buildzone/*"
> +        files = glob.glob(path)
> +        for f in files:
> +            if os.path.isfile(f):
> +                os.remove(f)
> +            else:
> +                shutil.rmtree(f, ignore_errors=True)
> +        # remove jenkins jobs
>          jobs = [job['name'] for job in server.get_jobs()]
>          for job in jobs:
>              server.delete_job(job)
> @@ -1097,6 +1115,20 @@ def do_rm_jobs(conf, options):
>              else:
>                  for match in matches:
>                      server.delete_job(match)
> +                    path = conf.FUEGO_RW + '/logs/' + '.'.join(match.split('.')[2:]) + '/'
> + '.'.join(match.split('.')[:2]) + '*'
> +                    folders = glob.glob(path)
> +                    for folder in folders:
> +                        print 'Removing folder ' + folder
> +                        shutil.rmtree(folder, ignore_errors=True)
> +                    folders = glob.glob(path)
> +                    if not folders:
> +                        shutil.rmtree(conf.FUEGO_RW + '/logs/' +
> '.'.join(match.split('.')[2:]), ignore_errors=True)
> +                    else:
> +                        path = conf.FUEGO_RW + '/logs/' + '.'.join(match.split('.')[2:]) +
> '/run-' + match + '.*'
> +                        files = glob.glob(path)
> +                        for f in files:
> +                            print 'Removing file ' + f
> +                            os.remove(f)
>                      count = count + 1
>      if not quiet:
>          print "Deleted %d jobs." % count
> --
> 2.7.4
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego


More information about the Fuego mailing list