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

move/rename experiment/nursery to greenhouse, document, enable for test-infra #6879

Merged
merged 2 commits into from
Feb 17, 2018
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
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ filegroup(
"//gcsweb/cmd/gcsweb:all-srcs",
"//gcsweb/pkg/version:all-srcs",
"//ghclient:all-srcs",
"//greenhouse:all-srcs",
"//hack:all-srcs",
"//images/bootstrap/barnacle:all-srcs",
"//jenkins:all-srcs",
Expand Down
1 change: 0 additions & 1 deletion experiment/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ filegroup(
"//experiment/cherrypicker:all-srcs",
"//experiment/coverage:all-srcs",
"//experiment/manual-trigger:all-srcs",
"//experiment/nursery:all-srcs",
"//experiment/refresh:all-srcs",
"//experiment/tracer:all-srcs",
],
Expand Down
14 changes: 0 additions & 14 deletions experiment/nursery/README.md

This file was deleted.

18 changes: 12 additions & 6 deletions experiment/nursery/BUILD.bazel → greenhouse/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "k8s.io/test-infra/experiment/nursery",
importpath = "k8s.io/test-infra/greenhouse",
visibility = ["//visibility:private"],
deps = [
"//experiment/nursery/diskcache:go_default_library",
"//experiment/nursery/diskutil:go_default_library",
"//greenhouse/diskcache:go_default_library",
"//greenhouse/diskutil:go_default_library",
"//prow/logrusutil:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
Expand All @@ -32,8 +32,8 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//experiment/nursery/diskcache:all-srcs",
"//experiment/nursery/diskutil:all-srcs",
"//greenhouse/diskcache:all-srcs",
"//greenhouse/diskutil:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
Expand All @@ -50,8 +50,14 @@ k8s_object(
name = "production",
cluster = "{STABLE_BUILD_CLUSTER}",
images = {
"gcr.io/k8s-testimages/nursery:latest": ":image",
"gcr.io/k8s-testimages/greenhouse:latest": ":image",
},
kind = "deployment",
template = ":deployment.yaml",
)

go_binary(
name = "greenhouse",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
29 changes: 29 additions & 0 deletions greenhouse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Greenhouse

Greenhouse is our bazel [bazel remote caching](https://docs.bazel.build/versions/master/remote-caching.html) setup.
We use this to provide faster build & test presubmits with a Globally shared cache (per repo).

Most Bazel users should probably visit [the official docs](https://docs.bazel.build/versions/master/remote-caching.html) and select one of the options outlined there, with Prow/Kubernetes we are using a custom setup to explore:

- better support for multiple repos / cache invalidation by changing the cache URL suffix
(see also: `images/bootstrap/create_bazel_cache_rcs.sh`)
- customized cache eviction logic
- integration with our logging and metrics stacks [WIP]

# Setup (on a Kubernetes Cluster)
We use this with [Prow](./../prow), to set it up we do the following:

- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) and [bazel](https://bazel.build/) and Point `KUBECONFIG` at your cluster.
- for k8s.io use `make -C prow get-build-cluster-credentials`
- Create a dedicated node. We use a GKE node-pool with a single node. Tag this node with label `dedicated=bazel-cache` and taint `dedicated=bazel-cache:NoSchedule` so your other tasks don't schedule on it.
- for k8s.io this is:
```
gcloud beta container node-pools create bazel-cache --cluster=prow --project=k8s-prow-builds --zone=us-central1-f --node-taints dedicated=bazel-cache:NoSchedule --machine-type=n1-standard-8 --num-nodes=1 --local-ssd-count=1
kubectl label nodes $(kubectl get no | grep cache | cut -d" " -f1) dedicated=bazel-cache
kubectl taint nodes $(kubectl get no | grep cache | cut -d" " -f1) dedicated=bazel-cache:NoSchedule
```
- Create the Kubernetes service so jobs can talk to it conveniently: `kubectl apply -f greenhouse/service.yaml`
- Finally build, push, and deploy with `bazel run //greenhouse:production.apply --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64`
<!--TODO(bentheelder): make this easier to consume by other users?-->
- NOTE: other uses will likely need to tweak this step to their needs

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
spec:
containers:
- name: bazel-cache
image: gcr.io/k8s-testimages/nursery:latest
image: gcr.io/k8s-testimages/greenhouse:latest
imagePullPolicy: Always
ports:
- name: cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["cache.go"],
importpath = "k8s.io/test-infra/experiment/nursery/diskcache",
importpath = "k8s.io/test-infra/greenhouse/diskcache",
visibility = ["//visibility:public"],
deps = [
"//experiment/nursery/diskutil:go_default_library",
"//greenhouse/diskutil:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package diskcache implements disk backed cache storage for use in nursery
// Package diskcache implements disk backed cache storage for use in greenhouse
package diskcache

import (
Expand All @@ -29,7 +29,7 @@ import (
"strings"
"time"

"k8s.io/test-infra/experiment/nursery/diskutil"
"k8s.io/test-infra/greenhouse/diskutil"

"github.com/sirupsen/logrus"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["diskutil.go"],
importpath = "k8s.io/test-infra/experiment/nursery/diskutil",
importpath = "k8s.io/test-infra/greenhouse/diskutil",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/djherbis/atime:go_default_library",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package diskutil implements disk related utilities for nursery
// Package diskutil implements disk related utilities for greenhouse
package diskutil

import (
Expand Down
8 changes: 4 additions & 4 deletions experiment/nursery/main.go → greenhouse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// nursery implements a bazel remote cache service [1]
// greenhouse implements a bazel remote cache service [1]
// supporting arbitrarily many workspaces stored within the same
// top level directory.
//
Expand All @@ -37,8 +37,8 @@ import (
"strings"
"time"

"k8s.io/test-infra/experiment/nursery/diskcache"
"k8s.io/test-infra/experiment/nursery/diskutil"
"k8s.io/test-infra/greenhouse/diskcache"
"k8s.io/test-infra/greenhouse/diskutil"
"k8s.io/test-infra/prow/logrusutil"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -67,7 +67,7 @@ var remount = flag.Bool("remount", false,

func init() {
logrus.SetFormatter(
logrusutil.NewDefaultFieldsFormatter(nil, logrus.Fields{"component": "nursery"}),
logrusutil.NewDefaultFieldsFormatter(nil, logrus.Fields{"component": "greenhouse"}),
)
logrus.SetOutput(os.Stdout)
}
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions prow/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4760,6 +4760,8 @@ presubmits:
- "--test=//..."
- "--test-args=--test_output=errors"
env:
- name: BAZEL_REMOTE_CACHE_ENABLED
value: "true"
- name: TEST_TMPDIR
value: /root/.cache/bazel
# Bazel needs privileged mode in order to sandbox builds.
Expand Down