Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for kubevirt container image pushing #860

Merged
merged 5 commits into from
May 3, 2023
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
8 changes: 7 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ s3:
acl: public-read

registry_repos:
oscontainer: quay.io/fedora/fedora-coreos
oscontainer:
repo: quay.io/fedora/fedora-coreos
tags: ["${STREAM}"]
kubevirt:
repo: quay.io/fedora/fedora-coreos-kubevirt
tags: ["${STREAM}"]

versionary_hack: true

Expand All @@ -69,6 +74,7 @@ default_artifacts:
- exoscale
- gcp
- ibmcloud
- kubevirt
- nutanix
- virtualbox
- vmware
Expand Down
41 changes: 28 additions & 13 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ streams:
- vmware
# OPTIONAL: stream-specific container repos to push to
additional_registry_repos:
oscontainer_old: registry.ci.openshift.org/rhcos-devel/machine-os-oci-content
legacy_oscontainer_old: registry.ci.openshift.org/rhcos-devel/machine-os-content
oscontainer_old:
repo: registry.ci.openshift.org/rhcos-devel/machine-os-oci-content
legacy_oscontainer_old:
repo: registry.ci.openshift.org/rhcos-devel/machine-os-content
# OPTIONAL: override default coreos-assembler image to build with
cosa_img: quay.io/coreos-assembler/coreos-assembler:stable
# OPTIONAL/TEMPORARY: Override default coreos-assembler image to use for
Expand Down Expand Up @@ -112,18 +114,31 @@ s3:

# OPTIONAL: container registry-related keys
registry_repos:
# OPTIONAL: repo to which to push oscontainer
oscontainer: quay.io/fedora/fedora-coreos
# OPTIONAL: repo and tags to which to push oscontainer
oscontainer:
# REQUIRED: repo name
repo: quay.io/fedora/fedora-coreos
# REQUIRED: list of tags to create/overwrite when pushing
# STREAM and VERSION are supported for templating
tags: ["${STREAM}"]
Copy link
Member

Choose a reason for hiding this comment

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

I know it seems obvious since we're using it in the examples, but for completeness, can we explicitly document the supported variables?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did in the first instance; didn't for the others.

Copy link
Member

Choose a reason for hiding this comment

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

We could even drop the REQUIRED comments in the following ones, but cool as is too!

# OPTIONAL/TEMPORARY: additional repo to which to push oscontainer
oscontainer_old: quay.io/coreos-assembler/fcos
# OPTIONAL: repo to which to push legacy oscontainer
legacy_oscontainer: quay.io/openshift-release-dev/rhel-coreos-dev
# OPTIONAL/TEMPORARY: additional repo to which to push oscontainer
legacy_oscontainer_old: registry.ci.openshift.org/rhcos/rhel-coreos
# OPTIONAL: repo to which to push the extensions container
extensions: quay.io/openshift-release-dev/rhel-coreos-extensions-dev
# OPTIONAL: whether to also tag images with build ID
add_build_tag: true
oscontainer_old:
repo: quay.io/coreos-assembler/fcos
# OPTIONAL: repo and tags to which to push legacy oscontainer
legacy_oscontainer:
repo: quay.io/openshift-release-dev/rhel-coreos-dev
tags: ["${STREAM}-legacy", "${VERSION}-legacy"]
# OPTIONAL/TEMPORARY: additional repo to which to push legacy oscontainer
legacy_oscontainer_old:
repo: registry.ci.openshift.org/rhcos/rhel-coreos
# OPTIONAL: repo and tags to which to push the extensions container
extensions:
repo: quay.io/openshift-release-dev/rhel-coreos-extensions-dev
tags: ["${STREAM}-extensions", "${VERSION}-extensions"]
# OPTIONAL: repo and tags to which to push kubevirt containerdisk container
kubevirt:
repo: quay.io/fedora/fedora-coreos-kubevirt
tags: ["${STREAM}"]
# OPTIONAL: whether to push in v2s2 format rather than OCI
v2s2: true

Expand Down
34 changes: 12 additions & 22 deletions jobs/release.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
}
}

def registry_repos = pipeutils.get_registry_repos(pipecfg, params.STREAM)
def registry_repos = pipeutils.get_registry_repos(
pipecfg, params.STREAM, params.VERSION)

// [config.yaml name -> [meta.json artifact name, meta.json toplevel name, tag suffix]]
// The config.yaml name is the name used in the `registry_repos` object. The
Expand All @@ -206,9 +207,10 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
// could be made configurable in the future. For now since FCOS doesn't need it and
// OCP ART doesn't actually care what the tag name is (it's just to stop GC), we
// hardcode it.
def push_containers = ['oscontainer': ['ostree', 'base-oscontainer', ''],
'extensions': ['extensions-container', 'extensions-container', '-extensions'],
'legacy_oscontainer': ['legacy-oscontainer', 'oscontainer', '-legacy']]
def push_containers = ['oscontainer': ['ostree', 'base-oscontainer'],
'kubevirt': ['kubevirt', 'kubevirt'],
'extensions': ['extensions-container', 'extensions-container'],
'legacy_oscontainer': ['legacy-oscontainer', 'oscontainer']]

// XXX: hack: on releases that don't support pushing the
// base-oscontainer, remove it from the list.
Expand Down Expand Up @@ -238,31 +240,19 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
parallel push_containers.collectEntries{configname, val -> [configname, {
withCredentials([file(variable: 'REGISTRY_SECRET',
credentialsId: 'oscontainer-push-registry-secret')]) {
def repo = registry_repos[configname]
def (artifact, metajsonname, tag_suffix) = val
if (pipecfg.hotfix) {
// this is a hotfix build; include the hotfix name
// in the tag suffix so we don't clobber official
// tags
tag_suffix += "-hotfix-${pipecfg.hotfix.name}"
}
def extra_args = basearches.collect{"--arch ${it}"}
if (registry_repos.v2s2) {
extra_args += "--v2s2"
}
def tag_args = ["--tag=${params.STREAM}${tag_suffix}"]
if (registry_repos.add_build_tag) {
tag_args += "--tag=${params.VERSION}${tag_suffix}"
}
def repo = registry_repos[configname]['repo']
def (artifact, metajsonname) = val
def tag_args = registry_repos[configname].tags.collect{"--tag=$it"}
def v2s2_arg = registry_repos.v2s2 ? "--v2s2" : ""
shwrap("""
export STORAGE_DRIVER=vfs # https://github.com/coreos/fedora-coreos-pipeline/issues/723#issuecomment-1297668507
cosa push-container-manifest --auth=\${REGISTRY_SECRET} \
--repo=${repo} ${tag_args.join(' ')} \
--artifact=${artifact} --metajsonname=${metajsonname} \
--build=${params.VERSION} ${extra_args.join(' ')}
--build=${params.VERSION} ${v2s2_arg}
""")

def old_repo = registry_repos["${configname}_old"]
def old_repo = registry_repos."${configname}_old"?.repo
if (old_repo) {
// a separate credential for the old location is optional; we support it
// being merged as part of oscontainer-push-registry-secret
Expand Down
18 changes: 0 additions & 18 deletions libcloud.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,6 @@ def upload_to_clouds(pipecfg, basearch, buildID, stream) {
}
}
}
credentials = [file(variable: "KUBEVIRT_IMAGE_UPLOAD_CONFIG",
credentialsId: "kubevirt-image-upload-config")]
if (pipecfg.clouds?.kubevirt &&
artifacts.contains("kubevirt") &&
utils.credentialsExist(credentials)) {
def creds = credentials
uploaders["☁️ ⬆️ :kubevirt"] = {
withCredentials(creds) {
utils.syncCredentialsIfInRemoteSession(["KUBEVIRT_IMAGE_UPLOAD_CONFIG"])
def c = pipecfg.clouds.kubevirt
shwrap("""coreos-assembler buildextend-kubevirt \
--upload \
--name ${c.name} \
--repository ${c.repository}
""")
}
}
}
credentials = [file(variable: "POWERVS_IMAGE_UPLOAD_CONFIG",
credentialsId: "powervs-image-upload-config")]
if (pipecfg.clouds?.powervs &&
Expand Down
22 changes: 21 additions & 1 deletion utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,30 @@ def build_artifacts(pipecfg, stream, basearch) {
utils.runParallel(parallelruns, maxRuns)
}

def get_registry_repos(pipecfg, stream) {
def get_registry_repos(pipecfg, stream, version) {
def registry_repos = pipecfg.registry_repos ?: [:]
// merge top-level registry_repos with stream-specific bits
registry_repos += pipecfg.streams[stream].additional_registry_repos ?: [:]
for (repo in (registry_repos.keySet() as List)) {
if (repo == 'v2s2') {
// this is a boolean option, not a registry repo
continue
}
if (registry_repos[repo].tags) {
def processed_tags = []
for (tag in registry_repos."${repo}".tags) {
tag = utils.substituteStr(tag, [STREAM: stream, VERSION: version])
if (pipecfg.hotfix) {
// this is a hotfix build; include the hotfix name
// in the tag suffix so we don't clobber official
// tags
tag += "-hotfix-${pipecfg.hotfix.name}"
}
processed_tags += tag
}
registry_repos[repo]['tags'] = processed_tags
}
}
return registry_repos
}

Expand Down