From 5edb71cb760d9d85ccde77abe8816278ff390d50 Mon Sep 17 00:00:00 2001 From: Christian Glombek Date: Sat, 19 Jun 2021 00:19:32 +0200 Subject: [PATCH 1/3] containers.bzl: Update git image to v20210618-1017135 (incl. arm64) This commit updates the `git-base` to tag `v20210618-1017135`, and also adds a `git-base-arm64` image from the same manifest. --- containers.bzl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/containers.bzl b/containers.bzl index 4b46d8e27819..09cfe33a0ffa 100644 --- a/containers.bzl +++ b/containers.bzl @@ -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( From ca0cf8fbb4f51a79b18bfb5fe6ab74ca70b81be3 Mon Sep 17 00:00:00 2001 From: Christian Glombek Date: Tue, 6 Jul 2021 18:28:51 +0200 Subject: [PATCH 2/3] prow: Add ability to build arm64 images to prow_image macro --- def/image.bzl | 9 +++++++++ prow/def.bzl | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/def/image.bzl b/def/image.bzl index 38501915d696..5f6dbb773c25 100644 --- a/def/image.bzl +++ b/def/image.bzl @@ -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 diff --git a/prow/def.bzl b/prow/def.bzl index a7f22663936a..43697e7904f8 100644 --- a/prow/def.bzl +++ b/prow/def.bzl @@ -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, @@ -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, @@ -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} @@ -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, @@ -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 From 88208819f6164fab2512557df0acbde75dd91173 Mon Sep 17 00:00:00 2001 From: Christian Glombek Date: Tue, 6 Jul 2021 18:29:27 +0200 Subject: [PATCH 3/3] prow: Build minimal arm64 payload The arm64 payload only contains the following four images which are the minimal requirements for scheduling Prow builds on an arm64 build farm: - clonerefs - entrypoint - initupload - sidecar The arm64 images will be tagged with an additional `-arm64` suffix. --- prow/BUILD.bazel | 108 +++++++++++++++++--------------- prow/cmd/clonerefs/BUILD.bazel | 2 + prow/cmd/entrypoint/BUILD.bazel | 2 + prow/cmd/initupload/BUILD.bazel | 2 + prow/cmd/sidecar/BUILD.bazel | 2 + 5 files changed, 67 insertions(+), 49 deletions(-) diff --git a/prow/BUILD.bazel b/prow/BUILD.bazel index e6f27c249dd5..82f1fc27b118 100644 --- a/prow/BUILD.bazel +++ b/prow/BUILD.bazel @@ -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", + ], + ), ), ) diff --git a/prow/cmd/clonerefs/BUILD.bazel b/prow/cmd/clonerefs/BUILD.bazel index 19ed73ba19e2..f6796a4cfc83 100644 --- a/prow/cmd/clonerefs/BUILD.bazel +++ b/prow/cmd/clonerefs/BUILD.bazel @@ -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", diff --git a/prow/cmd/entrypoint/BUILD.bazel b/prow/cmd/entrypoint/BUILD.bazel index 44d136f5dc8c..24c28d1870bb 100644 --- a/prow/cmd/entrypoint/BUILD.bazel +++ b/prow/cmd/entrypoint/BUILD.bazel @@ -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"], diff --git a/prow/cmd/initupload/BUILD.bazel b/prow/cmd/initupload/BUILD.bazel index 314dbf649493..923ce728d4a2 100644 --- a/prow/cmd/initupload/BUILD.bazel +++ b/prow/cmd/initupload/BUILD.bazel @@ -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"], diff --git a/prow/cmd/sidecar/BUILD.bazel b/prow/cmd/sidecar/BUILD.bazel index fc3968957672..8b1f9a723ecb 100644 --- a/prow/cmd/sidecar/BUILD.bazel +++ b/prow/cmd/sidecar/BUILD.bazel @@ -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"],