worker/osbuild: consolidate Koji target options values meaning
When the Koji target support was added to the osbuild job, based on the osbuild-koji job, the meaning of target option values got messed up. The side effect of the issue is that when Koji composes are submitted via Cloud API the resulting image is currently always uploaded back to the worker server. `OsBuildKoji` job ----------------- - `OSBuildKojiJob.ImageName` is set to the filename of the image as exported by osbuild. - `OSBuildKojiJob.KojiFilename` is set to the desired filename which should be used when uploading the image to Koji. `OsBuild` job + `KojiTargetOptions` before ------------------------------------------ - `OSBuildJob.ImageName` is set to the filename of the image as exported by osbuild. This is done only by the Cloud API code for Koji composes. Cloud API does not set this for regular composes and any other target. The variable is set in common case only by Weldr API code with the same meaning and it is used by the `OsBuild` job implementation as an indication that the image should be uploaded back to the worker server. - `Target.ImageName` is not set at all. Other targets use it for the desired filename which should be used when uploading the image to the target environment. - `KojiTargetOptions.Filename` is set to the desired filename which should be used when uploading the image to Koji. All other target types use `Filename` variable in their options for the filename of the image as exported by osbuild. `OsBuild` job + `KojiTargetOptions` after ----------------------------------------- - `OSBuildJob.ImageName` is still set to the filename of the image as exported by osbuild. This is kept for a backward compatibility of new composer with older workers. - `Target.ImageName` is set to the desired filename which should be used when uploading the image to Koji. - `KojiTargetOptions.Filename` is set to the filename of the image as exported by osbuild. This change is backward incompatible, meaning that old worker won't be able to handle Koji compose requests submitted via Cloud API using a new composer and also a new worker won't be able to handle Koji compose requests submitted by a new composer. This is intentional, because after discussion with Ondrej Budai, the Cloud API Koji integration is currently not used anywhere in production.
This commit is contained in:
parent
1ae0a5f469
commit
fd82174469
4 changed files with 22 additions and 14 deletions
|
|
@ -748,7 +748,8 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Warnf("[Koji] logout failed: %v", err)
|
||||
}
|
||||
}()
|
||||
file, err := os.Open(path.Join(outputDirectory, exportPath, args.ImageName))
|
||||
|
||||
file, err := os.Open(path.Join(outputDirectory, exportPath, options.Filename))
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiBuild, fmt.Sprintf("failed to open the image for reading: %v", err))
|
||||
return nil
|
||||
|
|
@ -756,7 +757,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
defer file.Close()
|
||||
|
||||
logWithId.Info("[Koji] ⬆ Uploading the image")
|
||||
imageHash, imageSize, err := kojiAPI.Upload(file, options.UploadDirectory, options.Filename)
|
||||
imageHash, imageSize, err := kojiAPI.Upload(file, options.UploadDirectory, args.Targets[0].ImageName)
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue