14
14
15
15
# Build the node-problem-detector image.
16
16
17
- .PHONY : all build-container build-tar build push-container push-tar push \
18
- clean vet fmt version \
19
- Dockerfile build-binaries docker-builder build-in-docker
17
+ .PHONY : all \
18
+ vet fmt version test e2e-test \
19
+ build-binaries build-container build-tar build \
20
+ docker-builder build-in-docker push-container push-tar push clean
20
21
21
22
all : build
22
23
24
+ # PLATFORMS is the set of OS_ARCH that NPD can build against.
25
+ PLATFORMS =linux_amd64 windows_amd64
26
+
23
27
# VERSION is the version of the binary.
24
28
VERSION? =$(shell if [ -d .git ]; then echo `git describe --tags --dirty`; else echo "UNKNOWN"; fi)
25
29
48
52
# PARALLEL specifies the number of parallel test nodes to run for e2e tests.
49
53
PARALLEL? =3
50
54
55
+ NPD_NAME_VERSION? =node-problem-detector-$(VERSION )
51
56
# TARBALL is the name of release tar. Include binary version by default.
52
- TARBALL? =node-problem-detector- $( VERSION ) .tar.gz
57
+ TARBALL = $( NPD_NAME_VERSION ) .tar.gz
53
58
54
59
# IMAGE is the image name of the node problem detector container image.
55
60
IMAGE: =$(REGISTRY ) /node-problem-detector:$(TAG )
87
92
88
93
ifeq ($(ENABLE_JOURNALD ) , 1)
89
94
# Enable journald build tag.
90
- LINUX_BUILD_TAGS := $(BUILD_TAGS) journald
95
+ LINUX_BUILD_TAGS := journald $(BUILD_TAGS)
91
96
# Enable cgo because sdjournal needs cgo to compile. The binary will be
92
97
# dynamically linked if CGO_ENABLED is enabled. This is fine because fedora
93
98
# already has necessary dynamic library. We can not use `-extldflags "-static"`
@@ -112,23 +117,16 @@ fmt:
112
117
version :
113
118
@echo $(VERSION )
114
119
115
- WINDOWS_AMD64_BINARIES = bin/windows_amd64/node-problem-detector.exe bin/windows_amd64/health-checker.exe
116
- WINDOWS_AMD64_TEST_BINARIES = test/bin/windows_amd64/problem-maker.exe
117
- LINUX_AMD64_BINARIES = bin/linux_amd64/node-problem-detector bin/linux_amd64/health-checker
118
- LINUX_AMD64_TEST_BINARIES = test/bin/linux_amd64/problem-maker
120
+ BINARIES = bin/node-problem-detector bin/health-checker test/bin/problem-maker
121
+ BINARIES_LINUX_ONLY =
119
122
ifeq ($(ENABLE_JOURNALD ) , 1)
120
- LINUX_AMD64_BINARIES += bin/linux_amd64 /log-counter
123
+ BINARIES_LINUX_ONLY += bin/log-counter
121
124
endif
122
125
123
- WINDOWS_BINARIES = $(WINDOWS_AMD64_BINARIES ) $(WINDOWS_AMD64_TEST_BINARIES )
124
- LINUX_BINARIES = $(LINUX_AMD64_BINARIES ) $(LINUX_AMD64_TEST_BINARIES )
125
-
126
- windows-binaries : $(WINDOWS_BINARIES )
126
+ ALL_BINARIES = $(foreach binary, $(BINARIES ) $(BINARIES_LINUX_ONLY ) , ./$(binary ) ) $(foreach binary, $(BINARIES ) $(BINARIES_LINUX_ONLY ) , output/linux_amd64/$(binary ) ) $(foreach binary, $(BINARIES ) , output/windows_amd64/$(binary ) .exe)
127
+ ALL_TARBALLS = $(foreach platform, $(PLATFORMS ) , $(NPD_NAME_VERSION ) -$(platform ) .tar.gz)
127
128
128
- bin/windows_amd64/% .exe : $(PKG_SOURCES )
129
- ifeq ($(ENABLE_JOURNALD ) , 1)
130
- echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
131
- endif
129
+ output/windows_amd64/bin/% .exe : $(PKG_SOURCES )
132
130
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
133
131
-mod vendor \
134
132
-o $@ \
@@ -137,17 +135,14 @@ endif
137
135
./cmd/$(subst -,,$* )
138
136
touch $@
139
137
140
- ./test/bin/windows_amd64/% .exe : $(PKG_SOURCES )
141
- ifeq ($(ENABLE_JOURNALD ) , 1)
142
- echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
143
- endif
138
+ output/windows_amd64/test/bin/% .exe : $(PKG_SOURCES )
144
139
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
145
140
-mod vendor \
146
141
-o $@ \
147
142
-tags " $( WINDOWS_BUILD_TAGS) " \
148
143
./test/e2e/$(subst -,,$* )
149
144
150
- bin /linux_amd64/% : $(PKG_SOURCES )
145
+ output /linux_amd64/bin /% : $(PKG_SOURCES )
151
146
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
152
147
-mod vendor \
153
148
-o $@ \
@@ -156,53 +151,20 @@ bin/linux_amd64/%: $(PKG_SOURCES)
156
151
./cmd/$(subst -,,$* )
157
152
touch $@
158
153
159
- ./ test/bin/linux_amd64 /% : $(PKG_SOURCES )
154
+ output/linux_amd64/ test/bin/% : $(PKG_SOURCES )
160
155
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
161
156
-mod vendor \
162
157
-o $@ \
163
158
-tags " $( LINUX_BUILD_TAGS) " \
164
159
./test/e2e/$(subst -,,$* )
165
160
166
- ifneq ($(ENABLE_JOURNALD ) , 1)
167
- bin/linux_amd64/log-counter :
168
- echo " Warning: log-counter requires journald, skipping."
169
- endif
170
-
171
- # In the future these targets should be deprecated.
172
- ./bin/log-counter : $(PKG_SOURCES )
173
- ifeq ($(ENABLE_JOURNALD ) , 1)
174
- CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
175
- -mod vendor \
176
- -o bin/log-counter \
177
- -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
178
- -tags "$(LINUX_BUILD_TAGS)" \
179
- cmd/logcounter/log_counter.go
180
- else
181
- echo "Warning: log-counter requires journald, skipping."
182
- endif
183
-
184
- ./bin/node-problem-detector : $(PKG_SOURCES )
185
- CGO_ENABLED=$(CGO_ENABLED ) GOOS=linux GO111MODULE=on go build \
186
- -mod vendor \
187
- -o bin/node-problem-detector \
188
- -ldflags ' -X $(PKG)/pkg/version.version=$(VERSION)' \
189
- -tags " $( LINUX_BUILD_TAGS) " \
190
- ./cmd/nodeproblemdetector
161
+ ./bin/% : output/linux_amd64/bin/%
162
+ mkdir -p bin/
163
+ cp $< $@
191
164
192
- ./test/bin/problem-maker : $(PKG_SOURCES )
193
- CGO_ENABLED=$(CGO_ENABLED ) GOOS=linux GO111MODULE=on go build \
194
- -mod vendor \
195
- -o test/bin/problem-maker \
196
- -tags " $( LINUX_BUILD_TAGS) " \
197
- ./test/e2e/problemmaker/problem_maker.go
198
-
199
- ./bin/health-checker : $(PKG_SOURCES )
200
- CGO_ENABLED=$(CGO_ENABLED ) GOOS=linux GO111MODULE=on go build \
201
- -mod vendor \
202
- -o bin/health-checker \
203
- -ldflags ' -X $(PKG)/pkg/version.version=$(VERSION)' \
204
- -tags " $( LINUX_BUILD_TAGS) " \
205
- cmd/healthchecker/health_checker.go
165
+ ./test/bin/% : output/linux_amd64/test/bin/%
166
+ mkdir -p test/bin/
167
+ cp $< $@
206
168
207
169
test : vet fmt
208
170
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags " $( HOST_PLATFORM_BUILD_TAGS) " ./...
@@ -217,16 +179,25 @@ e2e-test: vet fmt build-tar
217
179
-boskos-project-type=$(BOSKOS_PROJECT_TYPE ) -job-name=$(JOB_NAME ) \
218
180
-artifacts-dir=$(ARTIFACTS )
219
181
220
- build-binaries : ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker $(WINDOWS_BINARIES ) $(LINUX_BINARIES )
182
+ $(NPD_NAME_VERSION ) -% .tar.gz : $(ALL_BINARIES ) test/e2e-install.sh
183
+ mkdir -p output/$* / output/$* /test/
184
+ cp -r config/ output/$* /
185
+ cp test/e2e-install.sh output/$* /test/e2e-install.sh
186
+ (cd output/$* / && tar -zcvf ../../$@ * )
187
+ sha512sum $@ > $@ .sha512
188
+
189
+ build-binaries : $(ALL_BINARIES )
221
190
222
191
build-container : build-binaries Dockerfile
223
192
docker build -t $(IMAGE ) --build-arg BASEIMAGE=$(BASEIMAGE ) --build-arg LOGCOUNTER=$(LOGCOUNTER ) .
224
193
225
- build-tar : ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
226
- tar -zcvf $( TARBALL ) bin/ config/ test/e2e-install.sh test/bin/problem-maker
194
+ $( TARBALL ) : $( NPD_NAME_VERSION ) -linux_amd64.tar.gz
195
+ cp $( NPD_NAME_VERSION ) -linux_amd64.tar.gz $( TARBALL )
227
196
sha1sum $(TARBALL )
228
197
md5sum $(TARBALL )
229
198
199
+ build-tar : $(TARBALL ) $(ALL_TARBALLS )
200
+
230
201
build : build-container build-tar
231
202
232
203
docker-builder :
@@ -243,13 +214,12 @@ push-container: build-container
243
214
244
215
push-tar : build-tar
245
216
gsutil cp $(TARBALL ) $(UPLOAD_PATH ) /node-problem-detector/
217
+ gsutil cp node-problem-detector-$(VERSION ) -* .tar.gz* $(UPLOAD_PATH ) /node-problem-detector/
246
218
247
219
push : push-container push-tar
248
220
249
221
clean :
250
- rm -f bin/health-checker
251
- rm -f bin/log-counter
252
- rm -f bin/node-problem-detector
253
- rm -f $(WINDOWS_AMD64_BINARIES ) $(LINUX_AMD64_BINARIES )
254
- rm -f test/bin/problem-maker
255
- rm -f node-problem-detector-* .tar.gz
222
+ rm -rf bin/
223
+ rm -rf test/bin/
224
+ rm -f node-problem-detector-* .tar.gz*
225
+ rm -rf output/
0 commit comments