<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15140</bug_id>
          
          <creation_ts>2023-06-08 21:10:06 +0000</creation_ts>
          <short_desc>AB-INT: yocto-testresults tagging failure, tag already exists</short_desc>
          <delta_ts>2023-10-12 07:05:26 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>5</classification_id>
          <classification>Infrastructure</classification>
          <product>AutoBuilder</product>
          <component>autobuilder</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>AB-INT</status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.3 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alexandre Belloni">alexandre.belloni</reporter>
          <assigned_to name="Alexis Lothoré">alexis.lothore</assigned_to>
          <cc>alexandre.belloni</cc>
    
    <cc>infras.ab.watcher</cc>
    
    <cc>Infras.watcher</cc>
    
    <cc>pidge</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>tgamblin</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>95680</commentid>
    <comment_count>0</comment_count>
    <who name="Alexandre Belloni">alexandre.belloni</who>
    <bug_when>2023-06-08 21:10:06 +0000</bug_when>
    <thetext>Cloning into &apos;/tmp/sendqaemail.pvwa2qqi&apos;...
2d08981fb294a94aa1fff6f535372528b261e5fa
INFO: Reading files from /srv/autobuilder/autobuilder.yocto.io/pub/non-release/20230525-2/testresults
INFO: Found 1 revisions to store
INFO: Storing test result into git repository /tmp/sendqaemail.pvwa2qqi
INFO: Committing data into to branch master
INFO: Updating /tmp/sendqaemail.pvwa2qqi HEAD to latest commit
INFO: Creating tag master/70345-g9e3be6c905e717c3d6d00e75ff78fc2edd0e02e8/2
To push.yoctoproject.org:yocto-testresults
   2d08981..baf0f04  master -&gt; master
To push.yoctoproject.org:yocto-testresults
 ! [rejected]        master/70345-g9e3be6c905e717c3d6d00e75ff78fc2edd0e02e8/2 -&gt; master/70345-g9e3be6c905e717c3d6d00e75ff78fc2edd0e02e8/2 (already exists)
error: failed to push some refs to &apos;push.yoctoproject.org:yocto-testresults&apos;
hint: Updates were rejected because the tag already exists in the remote.
Working off ssh://git@push.yoctoproject.org/poky:master
Traceback (most recent call last):
  File &quot;/home/pokybuild/yocto-worker/a-quick/yocto-autobuilder-helper/scripts/send-qa-email&quot;, line 216, in &lt;module&gt;
    send_qa_email()
  File &quot;/home/pokybuild/yocto-worker/a-quick/yocto-autobuilder-helper/scripts/send-qa-email&quot;, line 156, in send_qa_email
    subprocess.check_call([&quot;git&quot;, &quot;push&quot;, &quot;--tags&quot;], cwd=tempdir)
  File &quot;/usr/lib64/python3.11/subprocess.py&quot;, line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command &apos;[&apos;git&apos;, &apos;push&apos;, &apos;--tags&apos;]&apos; returned non-zero exit status 1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95681</commentid>
    <comment_count>1</comment_count>
    <who name="Alexandre Belloni">alexandre.belloni</who>
    <bug_when>2023-06-08 21:10:36 +0000</bug_when>
    <thetext>https://autobuilder.yoctoproject.org/typhoon/#/builders/85/builds/2143/steps/29/logs/stdio</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96224</commentid>
    <comment_count>2</comment_count>
    <who name="Alexandre Belloni">alexandre.belloni</who>
    <bug_when>2023-08-10 14:29:20 +0000</bug_when>
    <thetext>https://autobuilder.yoctoproject.org/typhoon/#/builders/85/builds/2209/steps/29/logs/stdio</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96240</commentid>
    <comment_count>3</comment_count>
    <who name="Alexis Lothoré">alexis.lothore</who>
    <bug_when>2023-08-10 18:56:41 +0000</bug_when>
    <thetext>I think I _theoretically_ found out what happens here.
Diving into tag generation code in resulttool, I observe that the tag number (the &quot;tag_number}&quot; in &quot;{branch}/{commit_count}-g{commit}/{tag_number}&quot; is always computed based on existing tags. This tag number is here to allow to store multiple test results regarding a single poky revision. I eventually reach a &quot;git tag&quot; command to list existing tags. Passed repository is the test results repository cloned by send-qa-email.

The twist is that this clone is in fact a shallow clone, so only recent tags are known. Since recently, my guess is that we had &quot;luck&quot; because if two builds targeting the same poky revision happened, they were timely close enough so the shallow clone was still aware of previous tags on the same poky revision, and tag number was incremented then pushed correctly.
BUT: one of my recent development (2c0d9e19771a4fc8365a40d553b4be19c491785f in yocto-autobuilder-helper) made the clone even more shallow (depth=1). So whenever a build targets a revision which has already been tested, but other tests have been pushed since then, send-qa-email fails to detect the existing tag, so it uses 0 (as first tag number since it thinks it is running tests on this specific version for the first time), creates a tag that does not exist locally but exists remotely, and fails to push.

The proper fix should be to use git ls-remote instead of git tag to make sure to get all remote tags. Quickly checking gitarchive.py (which is called to generate the tag), I see only two places that need the fix. I will come up with something and send a patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96243</commentid>
    <comment_count>4</comment_count>
    <who name="Alexandre Belloni">alexandre.belloni</who>
    <bug_when>2023-08-11 08:19:54 +0000</bug_when>
    <thetext>I guess you are right, I got this today:

2023-08-10 22:28:27,720 - oe-selftest - INFO -  ... FAIL
Stderr:
2023-08-10 21:02:03,493 - oe-selftest - INFO - Adding: &quot;include selftest.inc&quot; in /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-3253880/conf/local.conf
2023-08-10 21:02:03,493 - oe-selftest - INFO - Adding: &quot;include bblayers.inc&quot; in bblayers.conf
INFO: Shallow-cloning testresults in /tmp/yocto-testresults-query.pj8tcxbc
Cloning into &apos;/tmp/yocto-testresults-query.pj8tcxbc&apos;...
fatal: ambiguous argument &apos;yocto-4.0&apos;: unknown revision or path not in the working tree.
Use &apos;--&apos; to separate paths from revisions, like this:
&apos;git &lt;command&gt; [&lt;revision&gt;...] -- [&lt;file&gt;...]&apos;
ERROR: Can not find SHA-1 for yocto-4.0 in /home/pokybuild/yocto-worker/oe-selftest-centos/build
2023-08-10 22:28:27,721 - oe-selftest - INFO - 4: 45/46 388/533 (0.18s) (0 failed) (yoctotestresultsquerytests.TestResultsQueryTests.test_get_sha1)
2023-08-10 22:28:27,721 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File &quot;/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/selftest/cases/yoctotestresultsquerytests.py&quot;, line 27, in test_get_sha1
    self.assertEqual(
  File &quot;/usr/lib64/python3.9/unittest/case.py&quot;, line 837, in assertEqual
    assertion_func(first, second, msg=msg)
  File &quot;/usr/lib64/python3.9/unittest/case.py&quot;, line 830, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: None != &apos;00cfdde791a0176c134f31e5a09eff725e75b905&apos;
Stderr:
2023-08-10 21:02:03,493 - oe-selftest - INFO - Adding: &quot;include selftest.inc&quot; in /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-3253880/conf/local.conf
2023-08-10 21:02:03,493 - oe-selftest - INFO - Adding: &quot;include bblayers.inc&quot; in bblayers.conf
INFO: Shallow-cloning testresults in /tmp/yocto-testresults-query.pj8tcxbc
Cloning into &apos;/tmp/yocto-testresults-query.pj8tcxbc&apos;...
fatal: ambiguous argument &apos;yocto-4.0&apos;: unknown revision or path not in the working tree.
Use &apos;--&apos; to separate paths from revisions, like this:
&apos;git &lt;command&gt; [&lt;revision&gt;...] -- [&lt;file&gt;...]&apos;
ERROR: Can not find SHA-1 for yocto-4.0 in /home/pokybuild/yocto-worker/oe-selftest-centos/build</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96417</commentid>
    <comment_count>5</comment_count>
    <who name="Trevor Gamblin">tgamblin</who>
    <bug_when>2023-09-14 15:32:07 +0000</bug_when>
    <thetext>Moved to M4.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>