Skip to content

Commit 5e55ef8

Browse files
author
Xuewei Zhang
committed
Make log-counter respect ENABLE_JOURNALD
1 parent 3c80676 commit 5e55ef8

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

Dockerfile.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ RUN clean-install libsystemd0 bash
2121
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
2222

2323
ADD ./bin/node-problem-detector /node-problem-detector
24+
25+
# Below command depends on ENABLE_JOURNAL=1.
2426
ADD ./bin/log-counter /home/kubernetes/bin/log-counter
27+
2528
ADD config /config
2629
ENTRYPOINT ["/node-problem-detector", "--system-log-monitors=/config/kernel-monitor.json"]

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ version:
8484
@echo $(VERSION)
8585

8686
./bin/log-counter: $(PKG_SOURCES)
87+
ifeq ($(ENABLE_JOURNALD), 1)
8788
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
8889
-mod vendor \
8990
-o bin/log-counter \
9091
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
9192
-tags "$(BUILD_TAGS)" \
9293
cmd/logcounter/log_counter.go
94+
else
95+
echo "Warning: log-counter requires journald, skipping."
96+
endif
9397

9498
./bin/node-problem-detector: $(PKG_SOURCES)
9599
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
@@ -101,6 +105,11 @@ version:
101105

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

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

cmd/logcounter/log_counter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build journald
2+
13
/*
24
Copyright 2018 The Kubernetes Authors All rights reserved.
35

pkg/logcounter/log_counter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build journald
2+
13
/*
24
Copyright 2018 The Kubernetes Authors All rights reserved.
35

pkg/logcounter/log_counter_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build journald
2+
13
/*
24
Copyright 2018 The Kubernetes Authors All rights reserved.
35

0 commit comments

Comments
 (0)