Skip to content

Commit

Permalink
Merge pull request kubernetes#390 from xueweiz/make
Browse files Browse the repository at this point in the history
Fix build tags manipulation in Makefile
  • Loading branch information
k8s-ci-robot authored Nov 26, 2019
2 parents ef30a1f + 5e55ef8 commit d000c1b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ script:
- BUILD_TAGS="disable_system_stats_monitor" make test
- make clean && BUILD_TAGS="disable_stackdriver_exporter" make
- BUILD_TAGS="disable_stackdriver_exporter" make test
- make clean && ENABLE_JOURNALD=0 make
- ENABLE_JOURNALD=0 make test
3 changes: 3 additions & 0 deletions Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ RUN clean-install libsystemd0 bash
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true

ADD ./bin/node-problem-detector /node-problem-detector

# Below command depends on ENABLE_JOURNAL=1.
ADD ./bin/log-counter /home/kubernetes/bin/log-counter

ADD config /config
ENTRYPOINT ["/node-problem-detector", "--system-log-monitors=/config/kernel-monitor.json"]
26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ BASEIMAGE:=k8s.gcr.io/debian-base-amd64:v1.0.0
CGO_ENABLED:=0

# Construct the "-tags" parameter used by "go build".
BUILD_TAGS?=""
BUILD_TAGS?=
ifeq ($(ENABLE_JOURNALD), 1)
# Enable journald build tag.
BUILD_TAGS:=$(BUILD_TAGS) journald
Expand All @@ -71,14 +71,11 @@ ifeq ($(ENABLE_JOURNALD), 1)
# statically linked application.
CGO_ENABLED:=1
endif
ifneq ($(BUILD_TAGS), "")
BUILD_TAGS:=-tags "$(BUILD_TAGS)"
endif

vet:
GO111MODULE=on go list -mod vendor $(BUILD_TAGS) ./... | \
GO111MODULE=on go list -mod vendor -tags "$(BUILD_TAGS)" ./... | \
grep -v "./vendor/*" | \
GO111MODULE=on xargs go vet -mod vendor $(BUILD_TAGS)
GO111MODULE=on xargs go vet -mod vendor -tags "$(BUILD_TAGS)"

fmt:
find . -type f -name "*.go" | grep -v "./vendor/*" | xargs gofmt -s -w -l
Expand All @@ -87,29 +84,38 @@ version:
@echo $(VERSION)

./bin/log-counter: $(PKG_SOURCES)
ifeq ($(ENABLE_JOURNALD), 1)
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
-mod vendor \
-o bin/log-counter \
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
$(BUILD_TAGS) \
-tags "$(BUILD_TAGS)" \
cmd/logcounter/log_counter.go
else
echo "Warning: log-counter requires journald, skipping."
endif

./bin/node-problem-detector: $(PKG_SOURCES)
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
-mod vendor \
-o bin/node-problem-detector \
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
$(BUILD_TAGS) \
-tags "$(BUILD_TAGS)" \
./cmd/nodeproblemdetector

Dockerfile: Dockerfile.in
sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@
ifneq ($(ENABLE_JOURNALD), 1)
sed -i '/Below command depends on ENABLE_JOURNAL=1/,+2d' $@
echo "Warning: log-counter requires journald, skipping."
endif


test: vet fmt
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short $(BUILD_TAGS) ./...
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(BUILD_TAGS)" ./...

e2e-test: vet fmt build-tar
GO111MODULE=on go test -mod vendor -timeout=10m -v $(BUILD_TAGS) \
GO111MODULE=on go test -mod vendor -timeout=10m -v -tags "$(BUILD_TAGS)" \
./test/e2e/metriconly/... \
-project=$(PROJECT) -zone=$(ZONE) \
-image=$(VM_IMAGE) -image-family=$(IMAGE_FAMILY) -image-project=$(IMAGE_PROJECT) \
Expand Down
2 changes: 2 additions & 0 deletions cmd/logcounter/log_counter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build journald

/*
Copyright 2018 The Kubernetes Authors All rights reserved.
Expand Down
2 changes: 2 additions & 0 deletions pkg/logcounter/log_counter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build journald

/*
Copyright 2018 The Kubernetes Authors All rights reserved.
Expand Down
2 changes: 2 additions & 0 deletions pkg/logcounter/log_counter_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build journald

/*
Copyright 2018 The Kubernetes Authors All rights reserved.
Expand Down

0 comments on commit d000c1b

Please sign in to comment.