Skip to content

Commit

Permalink
koji: Change release number for NVR
Browse files Browse the repository at this point in the history
 - The release number doesn't need to be random.
It makes things difficult when we need to search for
a NVR name.
 - Let's add our "release" version number as release number to
make things easier to search for a NVR when we need to.
Example:
  Our full version number is: 413.92.202302162021.0
  The Brew version is now: 412.86.202302162021 and
the release number is: 0

Signed-off-by: Renata Ravanelli <[email protected]>
  • Loading branch information
ravanelli committed Jul 18, 2023
1 parent 0eb550a commit f33be69
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/cmd-koji-upload
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,21 @@ class Reserve(_KojiBase):
"""
log.info("Reserving a unique koji id")

release = datetime.datetime.utcnow().strftime("%H%M%S")

# The koji/brew NVR is constructed like so:
# Name = "rhcos-$arch", like `rhcos-x86_64`
# Version = Everything before `-` in RHCOS version
# Release = Everything after `-` in RHCOS version
#
# Example: RHCOS Build ID: 414.92.202307170903-0 for x86_64
# Name = rhcos-x86_64
# Version = 414.92.202307170903
# Release = 0
# NVR = rhcos-x86_64-414.92.202307170903-0
version, release = build.build_id.split('-')
data = {
"name": f"{build.build_name}-{build.basearch}",
"release": release,
"version": f"{build.build_id.replace('-', '.')}",
"version": version,
"cg": "coreos-assembler",
}

Expand Down Expand Up @@ -529,7 +538,6 @@ class Upload(_KojiBase):
self._session = None
self._tag = tag
self._image_files = None
self._release = None
self._reserve_id_file = None
self._retry_attempts = 2
self._uploaded = False
Expand Down Expand Up @@ -632,7 +640,6 @@ class Upload(_KojiBase):

now = datetime.datetime.utcnow()
stamp = now.strftime("%s")
self.release = now.strftime("%H%M%S")

"""
Koji has a couple of checks to ensure the reservation data (build_Id, release, name
Expand Down Expand Up @@ -675,6 +682,17 @@ class Upload(_KojiBase):
"meta", self.build.ckey("container-config-git"))

log.debug(f"Preparing manifest for {(len(self.image_files))} files")
# The koji/brew NVR is constructed like so:
# Name = "rhcos-$arch", like `rhcos-x86_64`
# Version = Everything before `-` in RHCOS version
# Release = Everything after `-` in RHCOS version
#
# Example: RHCOS Build ID: 414.92.202307170903-0 for x86_64
# Name = rhcos-x86_64
# Version = 414.92.202307170903
# Release = 0
# NVR = rhcos-x86_64-414.92.202307170903-0
version, release = self.build.build_id.split('-')
self._manifest = {
"metadata_version": 0,
"build": {
Expand All @@ -688,14 +706,11 @@ class Upload(_KojiBase):
}
},
"name": f"{self.build.build_name}-{self.build.basearch}",
"release": self._release,
"release": release,
"owner": self._owner,
"source": source['origin'],
"start_time": stamp,
# RHCOS wants to be semver-compatible, but Koji doesn't
# accept `-`. See
# https://github.com/openshift/oc/pull/209#issuecomment-564876535
"version": f"{self.build.build_id.replace('-', '.')}"
"version": version
},
"buildroots": [{
"id": 1,
Expand Down

0 comments on commit f33be69

Please sign in to comment.