cloudapi: use ComputeImageInsert() and gce image for GCP
Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
8a064cef3e
commit
13844edcdb
3 changed files with 14 additions and 17 deletions
|
|
@ -449,19 +449,10 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
|
||||
logWithId.Infof("[GCP] 📥 Importing image into Compute Engine as '%s'", args.Targets[0].ImageName)
|
||||
imageBuild, importErr := g.ComputeImageImport(ctx, options.Bucket, options.Object, args.Targets[0].ImageName, options.Os, options.Region)
|
||||
if imageBuild != nil {
|
||||
logWithId.Infof("[GCP] 📜 Image import log URL: %s", imageBuild.LogUrl)
|
||||
logWithId.Infof("[GCP] 🎉 Image import finished with status: %s", imageBuild.Status)
|
||||
|
||||
// Cleanup all resources potentially left after the image import job
|
||||
deleted, err := g.CloudbuildBuildCleanup(ctx, imageBuild.Id)
|
||||
for _, d := range deleted {
|
||||
logWithId.Infof("[GCP] 🧹 Deleted resource after image import job: %s", d)
|
||||
}
|
||||
if err != nil {
|
||||
logWithId.Errorf("[GCP] Encountered error during image import cleanup: %v", err)
|
||||
}
|
||||
_, importErr := g.ComputeImageInsert(ctx, options.Bucket, options.Object, args.Targets[0].ImageName, []string{options.Region}, gcp.GuestOsFeaturesByDistro(options.Os))
|
||||
if importErr == nil {
|
||||
logWithId.Infof("[GCP] 🎉 Image import finished successfully")
|
||||
}
|
||||
|
||||
// Cleanup storage before checking for errors
|
||||
|
|
@ -470,7 +461,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Errorf("[GCP] Encountered error while deleting object: %v", err)
|
||||
}
|
||||
|
||||
// check error from ComputeImageImport()
|
||||
// check error from ComputeImageInsert()
|
||||
if importErr != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, importErr.Error())
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -376,11 +376,12 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
share = *gcpUploadOptions.ShareWithAccounts
|
||||
}
|
||||
|
||||
object := fmt.Sprintf("composer-api-%s", uuid.New().String())
|
||||
// the uploaded object must have a valid extension
|
||||
object := fmt.Sprintf("composer-api-%s.tar.gz", uuid.New().String())
|
||||
t := target.NewGCPTarget(&target.GCPTargetOptions{
|
||||
Filename: imageType.Filename(),
|
||||
Region: gcpUploadOptions.Region,
|
||||
Os: "", // not exposed in cloudapi for now
|
||||
Os: imageType.Arch().Distro().Name(), // not exposed in cloudapi
|
||||
Bucket: gcpUploadOptions.Bucket,
|
||||
Object: object,
|
||||
ShareWithAccounts: share,
|
||||
|
|
@ -472,7 +473,7 @@ func imageTypeFromApiImageType(it ImageTypes, arch distro.Arch) string {
|
|||
case ImageTypesAwsSapRhui:
|
||||
return "ec2-sap"
|
||||
case ImageTypesGcp:
|
||||
return "vhd"
|
||||
return "gce"
|
||||
case ImageTypesAzure:
|
||||
return "vhd"
|
||||
case ImageTypesAzureRhui:
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ const (
|
|||
|
||||
// added for cloudapi tests
|
||||
TestImageTypeAmi = "ami"
|
||||
TestImageTypeGce = "gce"
|
||||
TestImageTypeVhd = "vhd"
|
||||
TestImageTypeEdgeCommit = "rhel-edge-commit"
|
||||
TestImageTypeEdgeInstaller = "rhel-edge-installer"
|
||||
|
|
@ -283,9 +284,13 @@ func newTestDistro(name, modulePlatformID, releasever string) *TestDistro {
|
|||
name: TestImageTypeVmdk,
|
||||
}
|
||||
|
||||
it10 := TestImageType{
|
||||
name: TestImageTypeGce,
|
||||
}
|
||||
|
||||
ta1.addImageTypes(it1)
|
||||
ta2.addImageTypes(it1, it2)
|
||||
ta3.addImageTypes(it3, it4, it5, it6, it7, it8, it9)
|
||||
ta3.addImageTypes(it3, it4, it5, it6, it7, it8, it9, it10)
|
||||
|
||||
td.addArches(&ta1, &ta2, &ta3)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue