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

prow: build images for arm64 #22362

Merged
merged 3 commits into from
Jul 8, 2021
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
12 changes: 10 additions & 2 deletions containers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ def repositories():

container_pull(
name = "git-base",
digest = "sha256:1527341aff1003b6b27c8ed935e6f0200258bee55b6eb178ca3ef124196384fe",
digest = "sha256:a4bc91ce515c3463dcbf4ee4c47aaa887fd5f62166b90e32fe9c5f19a57c08f8",
registry = "gcr.io",
repository = "k8s-prow/git",
# tag = "v20200713-e9b3d9d",
# tag = "v20210618-1017135",
)

container_pull(
name = "git-base-arm64",
digest = "sha256:70f1aea9c4c056fb371c1cfc38c6052a49e6d9548de1c1f57810e38331dad157",
registry = "gcr.io",
repository = "k8s-prow/git",
# tag = "v20210618-1017135",
)

container_pull(
Expand Down
9 changes: 9 additions & 0 deletions def/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ def tags(targets):
outs["%s:latest-{BUILD_USER}" % img] = target
outs["%s:latest" % img] = target
return outs

def tags_arm64(targets):
outs = {}
for img, target in targets.items():
outs["%s:{DOCKER_TAG}-arm64" % img] = target
outs["%s:latest-{BUILD_USER}-arm64" % img] = target
outs["%s:latest-arm64" % img] = target
outs["%s:arm64" % img] = target
return outs
108 changes: 59 additions & 49 deletions prow/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,70 @@ package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_docker//container:bundle.bzl", "container_bundle")
load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push")
load("//prow:def.bzl", "prefix", "prow_push", "tags")
load("//prow:def.bzl", "dict_union", "prefix", "prow_push", "tags", "tags_arm64")
load("//def:image.bzl", image_tags = "tags")

prow_push(
name = "release-push",
bundle_name = "release",
images = tags(
cmds = [
"admission",
"autobump",
"branchprotector",
"checkconfig",
"clonerefs",
"config-bootstrapper",
"deck",
"entrypoint",
"exporter",
"gerrit",
"crier",
"generic-autobumper",
"grandmatriarch",
"gcsupload",
"hook",
"hmac",
"horologium",
"initupload",
"invitations-accepter",
"jenkins-operator",
"mkpj",
"mkpod",
"peribolos",
"sidecar",
"sinker",
"status-reconciler",
"sub",
"tide",
"tot",
"pipeline",
"prow-controller-manager",
],
targets = {
"needs-rebase": "//prow/external-plugins/needs-rebase:image",
"cherrypicker": "//prow/external-plugins/cherrypicker:image",
"refresh": "//prow/external-plugins/refresh:image",
"ghproxy": "//ghproxy:image",
"label_sync": "//label_sync:image",
"commenter": "//robots/commenter:image",
"pr-creator": "//robots/pr-creator:image",
"issue-creator": "//robots/issue-creator:image",
"configurator": "//testgrid/cmd/configurator:image",
"transfigure": "//testgrid/cmd/transfigure:image",
"gcsweb": "//gcsweb/cmd/gcsweb:image",
"bumpmonitoring": "//experiment/bumpmonitoring:image",
},
images = dict_union(
tags(
cmds = [
"admission",
"autobump",
"branchprotector",
"checkconfig",
"clonerefs",
"config-bootstrapper",
"deck",
"entrypoint",
"exporter",
"gerrit",
"crier",
"generic-autobumper",
"grandmatriarch",
"gcsupload",
"hook",
"hmac",
"horologium",
"initupload",
"invitations-accepter",
"jenkins-operator",
"mkpj",
"mkpod",
"peribolos",
"sidecar",
"sinker",
"status-reconciler",
"sub",
"tide",
"tot",
"pipeline",
"prow-controller-manager",
],
targets = {
"needs-rebase": "//prow/external-plugins/needs-rebase:image",
"cherrypicker": "//prow/external-plugins/cherrypicker:image",
"refresh": "//prow/external-plugins/refresh:image",
"ghproxy": "//ghproxy:image",
"label_sync": "//label_sync:image",
"commenter": "//robots/commenter:image",
"pr-creator": "//robots/pr-creator:image",
"issue-creator": "//robots/issue-creator:image",
"configurator": "//testgrid/cmd/configurator:image",
"transfigure": "//testgrid/cmd/transfigure:image",
"gcsweb": "//gcsweb/cmd/gcsweb:image",
"bumpmonitoring": "//experiment/bumpmonitoring:image",
},
),
tags_arm64(
cmds = [
"clonerefs",
"entrypoint",
"initupload",
"sidecar",
],
),
),
)

Expand Down
2 changes: 2 additions & 0 deletions prow/cmd/clonerefs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ go_binary(
prow_image(
name = "image",
base = "@git-base//image",
base_arm64 = "@git-base-arm64//image",
build_arm64 = True,
component = NAME,
files = [
"github_known_hosts",
Expand Down
2 changes: 2 additions & 0 deletions prow/cmd/entrypoint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ go_binary(
prow_image(
name = "image",
base = "@git-base//image",
base_arm64 = "@git-base-arm64//image",
build_arm64 = True,
component = NAME,
symlinks = {"/entrypoint": "/app/prow/cmd/entrypoint/app.binary"},
visibility = ["//visibility:public"],
Expand Down
2 changes: 2 additions & 0 deletions prow/cmd/initupload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ go_binary(
prow_image(
name = "image",
base = "@alpine-base//image",
base_arm64 = "@git-base-arm64//image",
build_arm64 = True,
component = NAME,
symlinks = {"/initupload": "/app/prow/cmd/initupload/app.binary"},
visibility = ["//visibility:public"],
Expand Down
2 changes: 2 additions & 0 deletions prow/cmd/sidecar/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ go_binary(
prow_image(
name = "image",
base = "@git-base//image",
base_arm64 = "@git-base-arm64//image",
build_arm64 = True,
component = NAME,
symlinks = {"/sidecar": "/app/prow/cmd/sidecar/app.binary"},
visibility = ["//visibility:public"],
Expand Down
43 changes: 42 additions & 1 deletion prow/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ load("@io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects")
load(
"//def:image.bzl",
_image_tags = "tags",
_image_tags_arm64 = "tags_arm64",
)

## prow_image is a macro for creating :app and :image targets
# prow_image is a macro for creating :app and :image targets
def prow_image(
component,
name, # use "image"
base = None,
base_arm64 = None,
stamp = True, # stamp by default, but allow overrides
app_name = "app",
build_arm64 = False,
**kwargs):
go_image(
name = app_name,
Expand All @@ -48,6 +51,25 @@ def prow_image(
**kwargs
)

if build_arm64 == True:
go_image(
name = "%s-arm64" % app_name,
base = base_arm64,
embed = [":go_default_library"],
goarch = "arm64",
goos = "linux",
pure = "on",
x_defs = {"k8s.io/test-infra/prow/version.Name": component},
)

container_image(
name = "%s-arm64" % name,
base = ":%s-arm64" % app_name,
architecture = "arm64",
stamp = stamp,
**kwargs
)

# prow_push creates a bundle of container images, and a target to push them.
def prow_push(
name,
Expand Down Expand Up @@ -90,6 +112,12 @@ def edge_prefix(cmd):
def target(cmd):
return "//prow/cmd/%s:image" % cmd

# target_arm64 returns the arm64 image target for the command.
#
# Concretely, target("foo") returns "//prow/cmd/foo:image-arm64"
def target_arm64(cmd):
return "//prow/cmd/%s:image-arm64" % cmd

# tags returns a {image: target} map for each cmd or {name: target} kwarg.
#
# In particular it will prefix the cmd image name with {STABLE_PROW_REPO} and {EDGE_PROW_REPO}
Expand Down Expand Up @@ -119,6 +147,13 @@ def tags(cmds, targets):
cmd_targets.update({edge_prefix(p): t for (p, t) in targets.items()})
return _image_tags(cmd_targets)

# tags_arm64 returns a {image: target-arm64} map for each cmd kwarg.
def tags_arm64(cmds):
cmd_targets = {prefix(cmd): target_arm64(cmd) for cmd in cmds}
if EDGE_PROW_REPO:
cmd_targets.update({edge_prefix(cmd): target_arm64(cmd) for cmd in cmds})
return _image_tags_arm64(cmd_targets)

def object(name, cluster = CORE_CLUSTER, **kwargs):
k8s_object(
name = name,
Expand Down Expand Up @@ -203,3 +238,9 @@ def release(name, *components):
name = name,
objects = objs,
)

def dict_union(x, y):
z = {}
z.update(x)
z.update(y)
return z