diff --git a/Makefile b/Makefile index 74c0d039..4f51d9de 100644 --- a/Makefile +++ b/Makefile @@ -65,9 +65,12 @@ CGO_ENABLED:=0 # Construct the "-tags" parameter used by "go build". BUILD_TAGS?= +LINUX_BUILD_TAGS = $(BUILD_TAGS) +WINDOWS_BUILD_TAGS = $(BUILD_TAGS) + ifeq ($(ENABLE_JOURNALD), 1) # Enable journald build tag. - BUILD_TAGS:=$(BUILD_TAGS) journald + LINUX_BUILD_TAGS := $(BUILD_TAGS) journald # Enable cgo because sdjournal needs cgo to compile. The binary will be # dynamically linked if CGO_ENABLED is enabled. This is fine because fedora # already has necessary dynamic library. We can not use `-extldflags "-static"` @@ -82,9 +85,9 @@ else endif vet: - GO111MODULE=on go list -mod vendor -tags "$(BUILD_TAGS)" ./... | \ + GO111MODULE=on go list -mod vendor -tags "$(LINUX_BUILD_TAGS)" ./... | \ grep -v "./vendor/*" | \ - GO111MODULE=on xargs go vet -mod vendor -tags "$(BUILD_TAGS)" + GO111MODULE=on xargs go vet -mod vendor -tags "$(LINUX_BUILD_TAGS)" fmt: find . -type f -name "*.go" | grep -v "./vendor/*" | xargs gofmt -s -w -l @@ -110,8 +113,8 @@ endif -mod vendor \ -o $@ \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ - -tags "$(BUILD_TAGS)" \ - ./cmd/$(subst -,,$*)/$(subst -,_,$*).go + -tags "$(WINDOWS_BUILD_TAGS)" \ + ./cmd/$(subst -,,$*) touch $@ ./test/bin/windows_amd64/%.exe: $(PKG_SOURCES) @@ -121,24 +124,24 @@ endif GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \ -mod vendor \ -o $@ \ - -tags "$(BUILD_TAGS)" \ - ./test/e2e/$(subst -,,$*)/$(subst -,_,$*).go + -tags "$(WINDOWS_BUILD_TAGS)" \ + ./test/e2e/$(subst -,,$*) bin/linux_amd64/%: $(PKG_SOURCES) GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \ -mod vendor \ -o $@ \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ - -tags "$(BUILD_TAGS)" \ - ./cmd/$(subst -,,$*)/$(subst -,_,$*).go + -tags "$(LINUX_BUILD_TAGS)" \ + ./cmd/$(subst -,,$*) touch $@ ./test/bin/linux_amd64/%: $(PKG_SOURCES) GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \ -mod vendor \ -o $@ \ - -tags "$(BUILD_TAGS)" \ - ./test/e2e/$(subst -,,$*)/$(subst -,_,$*).go + -tags "$(LINUX_BUILD_TAGS)" \ + ./test/e2e/$(subst -,,$*) ifneq ($(ENABLE_JOURNALD), 1) bin/linux_amd64/log-counter: @@ -152,7 +155,7 @@ ifeq ($(ENABLE_JOURNALD), 1) -mod vendor \ -o bin/log-counter \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ - -tags "$(BUILD_TAGS)" \ + -tags "$(LINUX_BUILD_TAGS)" \ cmd/logcounter/log_counter.go else echo "Warning: log-counter requires journald, skipping." @@ -163,14 +166,14 @@ endif -mod vendor \ -o bin/node-problem-detector \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ - -tags "$(BUILD_TAGS)" \ + -tags "$(LINUX_BUILD_TAGS)" \ ./cmd/nodeproblemdetector ./test/bin/problem-maker: $(PKG_SOURCES) CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \ -mod vendor \ -o test/bin/problem-maker \ - -tags "$(BUILD_TAGS)" \ + -tags "$(LINUX_BUILD_TAGS)" \ ./test/e2e/problemmaker/problem_maker.go ./bin/health-checker: $(PKG_SOURCES) @@ -178,14 +181,14 @@ endif -mod vendor \ -o bin/health-checker \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ - -tags "$(BUILD_TAGS)" \ + -tags "$(LINUX_BUILD_TAGS)" \ cmd/healthchecker/health_checker.go test: vet fmt - GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(BUILD_TAGS)" ./... + GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(LINUX_BUILD_TAGS)" ./... e2e-test: vet fmt build-tar - GO111MODULE=on ginkgo -nodes=$(PARALLEL) -mod vendor -timeout=10m -v -tags "$(BUILD_TAGS)" -stream \ + GO111MODULE=on ginkgo -nodes=$(PARALLEL) -mod vendor -timeout=10m -v -tags "$(LINUX_BUILD_TAGS)" -stream \ ./test/e2e/metriconly/... -- \ -project=$(PROJECT) -zone=$(ZONE) \ -image=$(VM_IMAGE) -image-family=$(IMAGE_FAMILY) -image-project=$(IMAGE_PROJECT) \ diff --git a/config/windows-containerd-monitor-filelog.json b/config/windows-containerd-monitor-filelog.json new file mode 100644 index 00000000..8404c2a5 --- /dev/null +++ b/config/windows-containerd-monitor-filelog.json @@ -0,0 +1,20 @@ +{ + "plugin": "filelog", + "pluginConfig": { + "timestamp": "^time=\"(\\S*)\"", + "message": "msg=\"([^\n]*)\"", + "timestampFormat": "2006-01-02T15:04:05.999999999-07:00" + }, + "logPath": "C:\\Program Files\\containerd\\containerd.log", + "lookback": "5m", + "bufferSize": 10, + "source": "docker-monitor", + "conditions": [], + "rules": [ + { + "type": "temporary", + "reason": "BadCNIConfig", + "pattern": "failed to reload cni configuration.*" + } + ] +} diff --git a/go.mod b/go.mod index be092546..0c44f6b6 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/go-ole/go-ole v1.2.4 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/google/cadvisor v0.36.0 + github.com/hpcloud/tail v1.0.0 github.com/onsi/ginkgo v1.10.3 github.com/onsi/gomega v1.7.1 github.com/pborman/uuid v1.2.0 diff --git a/pkg/systemlogmonitor/logwatchers/filelog/log_watcher_windows.go b/pkg/systemlogmonitor/logwatchers/filelog/log_watcher_windows.go index c52c6c06..1cde8254 100644 --- a/pkg/systemlogmonitor/logwatchers/filelog/log_watcher_windows.go +++ b/pkg/systemlogmonitor/logwatchers/filelog/log_watcher_windows.go @@ -17,13 +17,13 @@ limitations under the License. package filelog import ( - "fmt" "io" + + "github.com/hpcloud/tail" ) // getLogReader returns log reader for filelog log. Note that getLogReader doesn't look back // to the rolled out logs. func getLogReader(path string) (io.ReadCloser, error) { - // TODO: Support this on windows. - return nil, fmt.Errorf("not supported on windows.") + return tail.OpenFile(path) } diff --git a/vendor/modules.txt b/vendor/modules.txt index fe5aa9b0..e16fd431 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -122,6 +122,7 @@ github.com/hashicorp/errwrap # github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 github.com/hashicorp/go-multierror # github.com/hpcloud/tail v1.0.0 +## explicit github.com/hpcloud/tail github.com/hpcloud/tail/ratelimiter github.com/hpcloud/tail/util