Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions pkg/steps/release/create_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package release

import (
"context"
"encoding/json"
"fmt"
"github.com/openshift/ci-tools/pkg/results"
"github.com/openshift/ci-tools/pkg/steps/utils"
Expand Down Expand Up @@ -175,6 +176,21 @@ func (s *assembleReleaseStep) run(ctx context.Context) error {
return results.ForReason("missing_release").WithError(err).Errorf("could not resolve imagestream %s: %v", streamName, err)
}

// we want to expose the release payload as a CI version that looks just like
// the release versions for nightlies and CI release candidates
prefix := "0.0.1-0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, now the prefix would be 0.0.1-0 instead of 4. ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for the cases where we cannot determine the version, it's a fallback.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, somehow I missed that. Thanks!

if raw, ok := stable.ObjectMeta.Annotations[releaseConfigAnnotation]; ok {
var releaseConfig struct {
Name string `json:"name"`
}
if err := json.Unmarshal([]byte(raw), &releaseConfig); err != nil {
return results.ForReason("invalid_release").WithError(err).Errorf("could not resolve release configuration on imagestream %s: %v", streamName, err)
}
prefix = releaseConfig.Name
}
now := time.Now().UTC().Truncate(time.Second)
version := fmt.Sprintf("%s.test-%s-%s", prefix, now.Format("2006-01-02-150405"), s.jobSpec.Namespace())

destination := fmt.Sprintf("%s:%s", releaseImageStreamRepo, s.name)
log.Printf("Create release image %s", destination)
podConfig := steps.PodStepConfiguration{
Expand All @@ -190,9 +206,9 @@ func (s *assembleReleaseStep) run(ctx context.Context) error {
set -euo pipefail
export HOME=/tmp
oc registry login
oc adm release new --max-per-registry=32 -n %q --from-image-stream %q --to-image-base %q --to-image %q
oc adm release new --max-per-registry=32 -n %q --from-image-stream %q --to-image-base %q --to-image %q --name %q
oc adm release extract --from=%q --to=/tmp/artifacts/release-payload-%s
`, s.jobSpec.Namespace(), streamName, cvo, destination, destination, s.name),
`, s.jobSpec.Namespace(), streamName, cvo, destination, version, destination, s.name),
}

// set an explicit default for release-latest resources, but allow customization if necessary
Expand Down
8 changes: 7 additions & 1 deletion pkg/steps/release/release_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/openshift/ci-tools/pkg/util"
)

const releaseConfigAnnotation = "release.openshift.io/config"

// stableImagesTagStep is used when no release configuration is necessary
type stableImagesTagStep struct {
jobSpec *api.JobSpec
Expand Down Expand Up @@ -120,14 +122,18 @@ func (s *releaseImagesTagStep) run(ctx context.Context) error {
is.UID = ""
newIS := &imageapi.ImageStream{
ObjectMeta: meta.ObjectMeta{
Name: api.StableStreamFor(api.LatestStableName),
Name: api.StableStreamFor(api.LatestStableName),
Annotations: map[string]string{},
},
Spec: imageapi.ImageStreamSpec{
LookupPolicy: imageapi.ImageLookupPolicy{
Local: true,
},
},
}
if raw, ok := is.ObjectMeta.Annotations[releaseConfigAnnotation]; ok {
newIS.ObjectMeta.Annotations[releaseConfigAnnotation] = raw
}
for _, tag := range is.Spec.Tags {
if valid, _ := utils.FindStatusTag(is, tag.Name); valid != nil {
newIS.Spec.Tags = append(newIS.Spec.Tags, imageapi.TagReference{
Expand Down