Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 23dc8ae

Browse files
uniemimutogashidm
authored andcommitted
add vendoring support to gpu aware scheduling
As a container build speedup, this adds vendoring support for GAS. go-licenses is forcibly vendored due to being a container build time dependency. It is not built in executables. If you do "go mod vendor", then container builds are sped up as no source code downloads are done during them. Depending on network and cpu speeds the build time improvement varies, but it can reduce significantly, in the order of 1/2, or more. Further, pre-building of licenses is also added. If one does "make licenses" before building the image, the licenses are simply copied from the local folder. Together with "go mod vendor", the image build time can be cut down to 1/3 of original, or more. A release-image target is added to the makefile, which cleans up first and does a proper downloading build with the licenses recreated. Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
1 parent fcf69ea commit 23dc8ae

File tree

5 files changed

+249
-7
lines changed

5 files changed

+249
-7
lines changed

gpu-aware-scheduling/Makefile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ ifneq ($(TAG),)
22
IMAGE_TAG=:$(TAG)
33
endif
44

5-
.PHONY: test all build gpu-extender images format clean
5+
GOLICENSES_IN_GO_MOD=@$(shell grep "github.com/google/go-licenses" go.mod | cut -b 32-)
6+
ifneq ("$(wildcard vendor/)","")
7+
GOLICENCES_PREFIX=./vendor/
8+
else
9+
GOLICENSES_VERSION=$(GOLICENSES_IN_GO_MOD)
10+
endif
11+
12+
ifneq ("$(wildcard licenses/)","")
13+
LOCAL_LICENSES=TRUE
14+
endif
15+
16+
.PHONY: test all build image release-image format clean licenses mock e2e
617

718
test:
819
go test ./... -v *_test.go
@@ -12,14 +23,26 @@ all: format build
1223
build:
1324
CGO_ENABLED=0 GO111MODULE=on go build -ldflags="-s -w" -o ./bin/extender ./cmd/gas-scheduler-extender
1425

15-
image: gpu-extender
16-
docker build -f deploy/images/Dockerfile_gpu-extender ../ -t $(IMAGE_PATH)gpu-extender$(IMAGE_TAG)
26+
#note: you can speed up subsequent docker builds by doing "go mod vendor"
27+
#note: you can further speed up subsequent docker builds by doing "make licenses"
28+
image:
29+
docker build --build-arg GOLICENSES_PREFIX=$(GOLICENCES_PREFIX) --build-arg GOLICENSES_VERSION=$(GOLICENSES_VERSION) \
30+
--build-arg LOCAL_LICENSES=$(LOCAL_LICENSES) -f deploy/images/Dockerfile_gpu-extender ../ -t $(IMAGE_PATH)gpu-extender$(IMAGE_TAG)
31+
32+
release-image: clean
33+
docker build --build-arg GOLICENSES_VERSION=$(GOLICENSES_IN_GO_MOD) -f deploy/images/Dockerfile_gpu-extender ../ \
34+
-t $(IMAGE_PATH)gpu-extender$(IMAGE_TAG)
1735

1836
format:
1937
gofmt -w -s .
2038

2139
clean:
2240
rm -f ./bin/*
41+
rm -rf vendor licenses
42+
43+
licenses:
44+
GO111MODULE=on go run ${GOLICENSES_PREFIX}github.com/google/go-licenses${GOLICENSES_VERSION} \
45+
save "./cmd/gas-scheduler-extender" --save_path licenses
2346

2447
mock:
2548
mockery --name=CacheAPI --dir=pkg/gpuscheduler --inpkg --note="+build !validation\nre-generate with 'make mock'"

gpu-aware-scheduling/deploy/images/Dockerfile_gpu-extender

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
FROM golang:1.18 as builder
4+
ARG GOLICENSES_PREFIX
5+
ARG GOLICENSES_VERSION
6+
ARG LOCAL_LICENSES
47
COPY . /src_root
58
WORKDIR /src_root/gpu-aware-scheduling
69
RUN mkdir -p /install_root/etc && adduser --disabled-password --quiet --gecos "" -u 10001 gas && tail -1 /etc/passwd > /install_root/etc/passwd \
710
&& CGO_ENABLED=0 GO111MODULE=on go build -ldflags="-s -w" -o /install_root/extender ./cmd/gas-scheduler-extender \
8-
&& GO111MODULE=on go run github.com/google/go-licenses@v1.2.0 save "./cmd/gas-scheduler-extender" --save_path /install_root/licenses
11+
&& if [ -z "$LOCAL_LICENSES" ] ; then \
12+
GO111MODULE=on go run ${GOLICENSES_PREFIX}github.com/google/go-licenses${GOLICENSES_VERSION} save "./cmd/gas-scheduler-extender" --save_path /install_root/licenses ; \
13+
else cp -r licenses /install_root/ ; fi
914

1015
FROM scratch
1116
WORKDIR /

gpu-aware-scheduling/go.mod

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ require (
1212
k8s.io/klog/v2 v2.60.1
1313
)
1414

15+
require (
16+
github.com/Microsoft/go-winio v0.5.0 // indirect
17+
github.com/emirpasic/gods v1.18.1 // indirect
18+
github.com/golang/glog v1.0.0 // indirect
19+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
20+
github.com/google/licenseclassifier v0.0.0-20210722185704-3043a050f148 // indirect
21+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
22+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
23+
github.com/kevinburke/ssh_config v1.2.0 // indirect
24+
github.com/mitchellh/go-homedir v1.1.0 // indirect
25+
github.com/otiai10/copy v1.7.0 // indirect
26+
github.com/sergi/go-diff v1.2.0 // indirect
27+
github.com/spf13/cobra v1.4.0 // indirect
28+
github.com/src-d/gcfg v1.4.0 // indirect
29+
github.com/xanzy/ssh-agent v0.3.1 // indirect
30+
go.opencensus.io v0.23.0 // indirect
31+
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 // indirect
32+
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
33+
golang.org/x/tools v0.1.10 // indirect
34+
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
35+
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
36+
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
37+
gopkg.in/warnings.v0 v0.1.2 // indirect
38+
)
39+
1540
require (
1641
github.com/davecgh/go-spew v1.1.1 // indirect
1742
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
@@ -24,6 +49,7 @@ require (
2449
github.com/golang/protobuf v1.5.2 // indirect
2550
github.com/google/gnostic v0.6.9 // indirect
2651
github.com/google/go-cmp v0.5.8 // indirect
52+
github.com/google/go-licenses v1.2.0
2753
github.com/google/gofuzz v1.2.0 // indirect
2854
github.com/gopherjs/gopherjs v1.17.2 // indirect
2955
github.com/imdario/mergo v0.3.12 // indirect
@@ -56,5 +82,3 @@ require (
5682
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
5783
sigs.k8s.io/yaml v1.3.0 // indirect
5884
)
59-
60-
replace github.com/intel/platform-aware-scheduling/gpu-aware-scheduling => ../gpu-aware-scheduling

0 commit comments

Comments
 (0)