]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
packaging: use major version for Pulp `distro_version` label packaging-rocky-version 2226/head
authorVaibhav Mahajan <vamahaja@redhat.com>
Mon, 22 Jun 2026 13:19:50 +0000 (18:49 +0530)
committerVaibhav Mahajan <vamahaja@redhat.com>
Wed, 24 Jun 2026 11:37:36 +0000 (17:07 +0530)
`PulpProject._search()` was sending the full `os_version` in the `distro_version`
Pulp label, while repo paths and Shaman use the major version. Derive
`distro_version` from `_get_distro()` so RPM distros search by major release
and deb distros still use codename.

Signed-off-by: Vaibhav Mahajan <vamahaja@redhat.com>
tests/test_packaging.py
teuthology/packaging.py

index 046105e87a6918e94a8926621025fe04ad1bd647..378e9924b238526f9a8c4b9b357571d541447d26 100644 (file)
@@ -922,6 +922,28 @@ class TestPulpProject(TestBuilderProject):
         assert 'branch=jewel' in labels
         assert 'sha1=sha1' not in labels
 
+    @pytest.mark.parametrize(
+        'os_type,os_version,codename,expected',
+        [
+            ('rocky', '9.7', None, 'distro_version=9'),
+            ('rocky', '10.1', None, 'distro_version=10'),
+            ('alma', '9.7', None, 'distro_version=9'),
+            ('centos', '8.1', None, 'distro_version=8'),
+            ('rhel', '7.0', None, 'distro_version=7'),
+            ('ubuntu', '20.04', 'focal', 'distro_version=focal'),
+        ],
+    )
+    def test_search_uses_major_distro_version(
+            self, os_type, os_version, codename, expected):
+        config = dict(os_type=os_type, os_version=os_version)
+        if codename:
+            config['codename'] = codename
+        gp = self.klass('ceph', config)
+        gp._search()
+        labels = self.m_get.call_args[1]['params']['pulp_label_select']
+        assert expected in labels
+        assert f'distro_version={os_version},' not in labels
+
     def test_get_package_version_found(self):
         resp = Mock()
         resp.ok = True
index e319039115f35ddc9f12f5062df882336d700619..cbeb6d13d52e9efb4f16ff6973fac521f98a33dd 100644 (file)
@@ -1164,7 +1164,12 @@ class PulpProject(GitbuilderProject):
         labels = f'project={self.project},'
         labels += f'flavors={self.flavor},'
         labels += f'distro={self.os_type},'
-        labels += f'distro_version={self.os_version},'
+        distro_version = self._get_distro(
+            distro=self.os_type,
+            version=self.os_version,
+            codename=self.codename,
+        ).split('/', 1)[1]
+        labels += f'distro_version={distro_version},'
 
         # Add the architecture to the search parameters.
         arch = 'noarch' if self.force_noarch else self.arch