Skip to content

Commit

Permalink
ci-operator: expose ephemeral cluster versions based on parents
Browse files Browse the repository at this point in the history
When we import a release from a stream that's configured to have a name
and be released in some way, we can piggy-back off of that name to
create a name for our release that clearly labels us as a derivative
while also uniquely identifying the test configuration that is running.
All of this is best-effort and will no-op if no release config is
present, allowing us to still mark the cluster version as one udner test
but not identifying the parent release.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Aug 11, 2020
1 parent fdb2112 commit bee450b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
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"
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

0 comments on commit bee450b

Please sign in to comment.