#395 do not remove the vm when no-destroy is specified
Closed 5 years ago by jskladan. Opened 6 years ago by lnie.
taskotron/ lnie/libtaskotron no_destroy  into  develop

@@ -345,7 +345,7 @@ 

      links_list = []

  

      for module in modules:

-         if 'pyc' in module:

+         if not module.endswith('.py'):

              continue

  

          result = process_module(module,

file modified
+1 -1
@@ -110,7 +110,7 @@ 

  ``depcheck``, ``upgradepath`` and ``repoclosure`` results in one run).

  

  ``note`` adds a short valuable information that should be easily visible in the

-  result overview.

+ result overview.

  

  ``arch`` and ``package`` are custom fields that do not have any special meaning

  for the Taskotron tooling, but provide additional information about the check

@@ -103,7 +103,6 @@ 

  

  from libtaskotron import check

  from libtaskotron import config

- from libtaskotron import buildbot_utils

  from libtaskotron.exceptions import TaskotronDirectiveError, TaskotronValueError

  from libtaskotron.logger import log

  from libtaskotron.ext.fedora import rpm_utils
@@ -279,17 +278,13 @@ 

              return check.export_YAML(check_details)

  

          checkname = '%s.%s' % (arg_data['namespace'], arg_data['checkname'])

+         artifactsdir_url = '%s/all/%s' % (self.artifacts_baseurl, arg_data['uuid'])

  

          # find out if the task is allowed to post results into the namespace

          if config.get_config().profile == config.ProfileName.PRODUCTION:

              self.check_namespace(checkname, arg_data)

  

          # for now, we're creating the resultsdb group at reporting time

-         _, log_url = buildbot_utils.get_urls(arg_data['jobid'],

-                                              self.masterurl,

-                                              self.task_stepname)

-         artifactsdir_url = '%s/all/%s' % (self.artifacts_baseurl, arg_data['uuid'])

- 

          group_data = self.create_resultsdb_group(uuid=arg_data['uuid'], name=checkname)

  

          log.info('Posting %s results to ResultsDB...' % len(check_details))
@@ -298,7 +293,7 @@ 

                                     detail.checkname or arg_data['checkname'])

  

              self.ensure_testcase_exists(checkname)

-             result_log_url = log_url

+             result_log_url = artifactsdir_url

              if detail.artifact:

                  artifact_path = self.get_artifact_path(

                      arg_data['artifactsdir'],

file modified
+9 -6
@@ -99,21 +99,24 @@ 

          :param str ipaddr: IP address of the machine the task will be run on

          '''

  

-         taskdir = os.path.dirname(self.arg_data['task'])

-         taskfile = os.path.basename(self.arg_data['task'])

+         if os.path.isfile(os.path.join(self.arg_data['taskdir'], 'inventory')):

+             sti_inventory = os.path.join(config.get_config().client_taskdir, "inventory")

+         else:

+             sti_inventory = "/usr/share/ansible/inventory"

  

          cmd = [

              'ansible-playbook', 'runner.yml',

              '--inventory=%s,' % ipaddr,

              '-e', 'artifacts=%s' % self.arg_data['artifactsdir'],

              '-e', 'subjects=%s' % self.arg_data['item'],

-             '-e', 'taskdir=%s' % taskdir,

-             '-e', 'taskfile=%s' % taskfile,

+             '-e', 'taskdir=%s' % self.arg_data['taskdir'],

              '-e', 'client_taskdir=%s' % config.get_config().client_taskdir,

+             '-e', 'sti_inventory=%s' % sti_inventory,

          ]

  

          if self.run_remotely:

-             cmd.extend(['--private-key=%s' % self.arg_data['ssh_privkey']])

+             if 'ssh_privkey' in self.arg_data:

+                 cmd.extend(['--private-key=%s' % self.arg_data['ssh_privkey']])

          else:

              cmd.extend(['--ask-become-pass', '--connection=local', '-e', 'local=true'])

  
@@ -135,5 +138,5 @@ 

          try:

              self._run_ansible_playbook(ipaddr)

          finally:

-             if self.task_vm is not None:

+             if self.task_vm is not None and not self.arg_data['no_destroy']:

                  self.task_vm.teardown()

file modified
+9 -1
@@ -65,7 +65,7 @@ 

          pass

  

      parser = argparse.ArgumentParser(epilog=ITEM_TYPE_DOCS, formatter_class=CustomFormatter)

-     parser.add_argument("task", help="task playbook to run")

+     parser.add_argument("taskdir", help="taskdir with STI playbook to run")

      parser.add_argument("-a", "--arch",

                          choices=["i386", "x86_64", "armhfp", "noarch"], default='noarch',

                          help="architecture specifying the item to be checked. 'noarch' value "
@@ -147,6 +147,10 @@ 

              args['machine'] = machine

              args['port'] = 22

  

+     # avoid using './libtaskotron/None' when no ssh_privkey is provided

+     if args['ssh_privkey'] == None:

+         del args['ssh_privkey']

+ 

      # set paths

      args['artifactsdir'] = os.path.join(config.get_config().artifactsdir, args['uuid'])

  
@@ -186,6 +190,10 @@ 

      executor = Executor(arg_data)

      executor.execute()

  

+     # report results

+     # test_rc = read_test_rc()

+     # resultsdb.report(subject, rc, hurr, durr)

+ 

      # finalize

      log.info('Execution finished at: %s. Task artifacts were saved in: %s',

               datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC'),

file modified
+6
@@ -18,6 +18,12 @@ 

          src: "{{ taskdir }}/"

          dest: "{{ client_taskdir }}"

  

+     - name: create artifacts dir

+       file:

+         path: "{{ artifacts }}"

+         state: directory

+       when: not local

+ 

      - name: Install required packages

        dnf:

          name: "{{ item }}"

@@ -105,10 +105,7 @@ 

          call_data = call[2]

  

          # the log url depends on the arg_data, so construct it here

-         ref_builder, ref_jobid = self.ref_arg_data['jobid'].split('/')

-         ref_log_url = '%s/builders/%s/builds/%s/steps/%s/logs/stdio' %\

-                       (self.conf.taskotron_master, ref_builder, ref_jobid,

-                        self.conf.buildbot_task_step)

+         ref_log_url = '%s/all/%s' % (self.conf.artifacts_baseurl, self.ref_arg_data['uuid'])

          ref_testcase_name = '%s.%s' % (self.ref_arg_data['namespace'],

                                         self.ref_arg_data['checkname'])

  

@@ -153,10 +153,7 @@ 

          call_data = call[2]

  

          # the log url depends on the arg_data, so construct it here

-         ref_builder, ref_jobid = self.ref_arg_data['jobid'].split('/')

-         ref_log_url = '%s/builders/%s/builds/%s/steps/%s/logs/stdio' %\

-                       (self.conf.taskotron_master, ref_builder, ref_jobid,

-                        self.conf.buildbot_task_step)

+         ref_log_url = '%s/all/%s' % (self.conf.artifacts_baseurl, self.ref_arg_data['uuid'])

          ref_testcase_name = '%s.%s' % (self.ref_arg_data['namespace'],

                                         self.ref_arg_data['checkname'])

  

testplan:
git clone https://pagure.io/task-rpmlint-ansible
runtask -d -i gzip-1.8-1.fc25 -t koji_build --libvirt --no-destroy -a x86_64 task-rpmlint-ansible/run_tests.yml

fyi:
modification of runner.yml is not related ,just to wipe off warning in the log
TASK [create artifacts dir]


[WARNING]: Consider using file module with state=directory rather than running mkdir

Please submit clean differential request. This mashes up all kinds of different changes, most of them absolutely unrelated to what is in the PR's subject/description.

Also it seems you wanted to submit this against the feature/ansiblize branch, not develop.

Please submit clean differential request. This mashes up all kinds of different changes, most of > them absolutely unrelated to what is in the PR's subject/description.

ah,gonna to resubmit. Your commit makes me noticed that I forgot to git pull before changing the code,and the unrelated changes from last friday's new commit,which I failed to see.

Also it seems you wanted to submit this against the feature/ansiblize branch, not develop.

yeah,forgot to change the default

Pull-Request has been closed by jskladan

5 years ago