Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: do not produce Windows binaries with netgo build tags #4672

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Main (unreleased)

- Fix a bug which prevented the `app_agent_receiver` integration from processing traces. (@ptodev)

- Fix issue on Windows where DNS short names were unresolvable. (@rfratto)

v0.35.2 (2023-07-27)
--------------------

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) \
-X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")

DEFAULT_FLAGS := $(GO_FLAGS)
DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS)" -tags "netgo $(GO_TAGS)"
RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "netgo $(GO_TAGS)"
DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS)" -tags "$(GO_TAGS)"
RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags "$(GO_TAGS)"

ifeq ($(RELEASE_BUILD),1)
GO_FLAGS := $(DEFAULT_FLAGS) $(RELEASE_GO_FLAGS)
Expand Down Expand Up @@ -254,7 +254,7 @@ endif
# Targets for building Docker images
#

DOCKER_FLAGS := --build-arg RELEASE_BUILD=$(RELEASE_BUILD) --build-arg VERSION=$(VERSION)
DOCKER_FLAGS := --build-arg RELEASE_BUILD=$(RELEASE_BUILD) --build-arg VERSION=$(VERSION)

ifneq ($(DOCKER_PLATFORM),)
DOCKER_FLAGS += --platform=$(DOCKER_PLATFORM)
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WORKDIR /src/agent

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=${TARGETVARIANT#v} \
GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=${TARGETVARIANT#v} GO_TAGS=netgo \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
make operator

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=${TARGETVARIANT#v} \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
GO_TAGS="builtinassets promtail_journal_enabled" \
GO_TAGS="netgo builtinassets promtail_journal_enabled" \
GOEXPERIMENT=${GOEXPERIMENT} \
make agent

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS="$TARGETOS" GOARCH="$TARGETARCH" GOARM="${TARGETVARIANT#v}" \
RELEASE_BUILD="${RELEASE_BUILD}" VERSION="${VERSION}" \
GO_TAGS="promtail_journal_enabled" \
GO_TAGS="netgo promtail_journal_enabled" \
make agentctl

FROM ubuntu:lunar
Expand Down
47 changes: 26 additions & 21 deletions tools/make/packaging.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,65 @@ dist-agent-binaries: dist/grafana-agent-linux-amd64 \
dist/grafana-agent-linux-amd64-boringcrypto \
dist/grafana-agent-linux-arm64-boringcrypto

dist/grafana-agent-linux-amd64: GO_TAGS += builtinassets promtail_journal_enabled
dist/grafana-agent-linux-amd64: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist/grafana-agent-linux-amd64: GOOS := linux
dist/grafana-agent-linux-amd64: GOARCH := amd64
dist/grafana-agent-linux-amd64: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-linux-arm64: GO_TAGS += builtinassets promtail_journal_enabled
dist/grafana-agent-linux-arm64: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist/grafana-agent-linux-arm64: GOOS := linux
dist/grafana-agent-linux-arm64: GOARCH := arm64
dist/grafana-agent-linux-arm64: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-linux-ppc64le: GO_TAGS += builtinassets promtail_journal_enabled
dist/grafana-agent-linux-ppc64le: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist/grafana-agent-linux-ppc64le: GOOS := linux
dist/grafana-agent-linux-ppc64le: GOARCH := ppc64le
dist/grafana-agent-linux-ppc64le: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-linux-s390x: GO_TAGS += builtinassets promtail_journal_enabled
dist/grafana-agent-linux-s390x: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist/grafana-agent-linux-s390x: GOOS := linux
dist/grafana-agent-linux-s390x: GOARCH := s390x
dist/grafana-agent-linux-s390x: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-darwin-amd64: GO_TAGS += builtinassets
dist/grafana-agent-darwin-amd64: GO_TAGS += netgo builtinassets
dist/grafana-agent-darwin-amd64: GOOS := darwin
dist/grafana-agent-darwin-amd64: GOARCH := amd64
dist/grafana-agent-darwin-amd64: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-darwin-arm64: GO_TAGS += builtinassets
dist/grafana-agent-darwin-arm64: GO_TAGS += netgo builtinassets
dist/grafana-agent-darwin-arm64: GOOS := darwin
dist/grafana-agent-darwin-arm64: GOARCH := arm64
dist/grafana-agent-darwin-arm64: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

# NOTE(rfratto): do not use netgo when building Windows binaries, which
# prevents DNS short names from being resovable. See grafana/agent#4665.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a TODO to revert this change when the underlying Go issue is resolved?
golang/go#57757

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's the same issue, is it? I don't see any mention of the hosts file in the issue or the Prometheus issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a generic TODO comment, since I don't think this is the same issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I think you're right and it's not the same issue. But it's probably another issue which needs to be resolved before we use netgo on windows. Anyway, thank you for adding the TODO.

dist/grafana-agent-windows-amd64.exe: GO_TAGS += builtinassets
dist/grafana-agent-windows-amd64.exe: GOOS := windows
dist/grafana-agent-windows-amd64.exe: GOARCH := amd64
dist/grafana-agent-windows-amd64.exe: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-freebsd-amd64: GO_TAGS += builtinassets
dist/grafana-agent-freebsd-amd64: GO_TAGS += netgo builtinassets
dist/grafana-agent-freebsd-amd64: GOOS := freebsd
dist/grafana-agent-freebsd-amd64: GOARCH := amd64
dist/grafana-agent-freebsd-amd64: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent


dist/grafana-agent-linux-amd64-boringcrypto: GO_TAGS += builtinassets promtail_journal_enabled
dist/grafana-agent-linux-amd64-boringcrypto: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist/grafana-agent-linux-amd64-boringcrypto: GOOS := linux
dist/grafana-agent-linux-amd64-boringcrypto: GOARCH := amd64
dist/grafana-agent-linux-amd64-boringcrypto: GOEXPERIMENT := boringcrypto
dist/grafana-agent-linux-amd64-boringcrypto: generate-ui
$(PACKAGING_VARS) AGENT_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent

dist/grafana-agent-linux-arm64-boringcrypto: GO_TAGS += builtinassets promtail_journal_enabled
dist/grafana-agent-linux-arm64-boringcrypto: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist/grafana-agent-linux-arm64-boringcrypto: GOOS := linux
dist/grafana-agent-linux-arm64-boringcrypto: GOARCH := arm64
dist/grafana-agent-linux-arm64-boringcrypto: GOEXPERIMENT := boringcrypto
Expand All @@ -107,37 +109,39 @@ dist-agentctl-binaries: dist/grafana-agentctl-linux-amd64 \
dist/grafana-agentctl-windows-amd64.exe \
dist/grafana-agentctl-freebsd-amd64

dist/grafana-agentctl-linux-amd64: GO_TAGS += promtail_journal_enabled
dist/grafana-agentctl-linux-amd64: GO_TAGS += netgo promtail_journal_enabled
dist/grafana-agentctl-linux-amd64: GOOS := linux
dist/grafana-agentctl-linux-amd64: GOARCH := amd64
dist/grafana-agentctl-linux-amd64:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

dist/grafana-agentctl-linux-arm64: GO_TAGS += promtail_journal_enabled
dist/grafana-agentctl-linux-arm64: GO_TAGS += netgo promtail_journal_enabled
dist/grafana-agentctl-linux-arm64: GOOS := linux
dist/grafana-agentctl-linux-arm64: GOARCH := arm64
dist/grafana-agentctl-linux-arm64:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

dist/grafana-agentctl-linux-ppc64le: GO_TAGS += promtail_journal_enabled
dist/grafana-agentctl-linux-ppc64le: GO_TAGS += netgo promtail_journal_enabled
dist/grafana-agentctl-linux-ppc64le: GOOS := linux
dist/grafana-agentctl-linux-ppc64le: GOARCH := ppc64le
dist/grafana-agentctl-linux-ppc64le:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

dist/grafana-agentctl-linux-s390x: GO_TAGS += promtail_journal_enabled
dist/grafana-agentctl-linux-s390x: GO_TAGS += netgo promtail_journal_enabled
dist/grafana-agentctl-linux-s390x: GOOS := linux
dist/grafana-agentctl-linux-s390x: GOARCH := s390x
dist/grafana-agentctl-linux-s390x:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

dist/grafana-agentctl-darwin-amd64: GOOS := darwin
dist/grafana-agentctl-darwin-amd64: GOARCH := amd64
dist/grafana-agentctl-darwin-amd64: GO_TAGS += netgo
dist/grafana-agentctl-darwin-amd64: GOOS := darwin
dist/grafana-agentctl-darwin-amd64: GOARCH := amd64
dist/grafana-agentctl-darwin-amd64:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

dist/grafana-agentctl-darwin-arm64: GOOS := darwin
dist/grafana-agentctl-darwin-arm64: GOARCH := arm64
dist/grafana-agentctl-darwin-arm64: GO_TAGS += netgo
dist/grafana-agentctl-darwin-arm64: GOOS := darwin
dist/grafana-agentctl-darwin-arm64: GOARCH := arm64
dist/grafana-agentctl-darwin-arm64:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

Expand All @@ -146,6 +150,7 @@ dist/grafana-agentctl-windows-amd64.exe: GOARCH := amd64
dist/grafana-agentctl-windows-amd64.exe:
$(PACKAGING_VARS) AGENTCTL_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agentctl

dist/grafana-agentctl-freebsd-amd64: GO_TAGS += netgo
dist/grafana-agentctl-freebsd-amd64: GOOS := freebsd
dist/grafana-agentctl-freebsd-amd64: GOARCH := amd64
dist/grafana-agentctl-freebsd-amd64:
Expand All @@ -167,25 +172,25 @@ dist-agent-flow-binaries: dist.temp/grafana-agent-flow-linux-amd64 \
dist.temp/grafana-agent-flow-linux-s390x \
dist.temp/grafana-agent-flow-windows-amd64.exe

dist.temp/grafana-agent-flow-linux-amd64: GO_TAGS += builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-amd64: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-amd64: GOOS := linux
dist.temp/grafana-agent-flow-linux-amd64: GOARCH := amd64
dist.temp/grafana-agent-flow-linux-amd64: generate-ui
$(PACKAGING_VARS) FLOW_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent-flow

dist.temp/grafana-agent-flow-linux-arm64: GO_TAGS += builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-arm64: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-arm64: GOOS := linux
dist.temp/grafana-agent-flow-linux-arm64: GOARCH := arm64
dist.temp/grafana-agent-flow-linux-arm64: generate-ui
$(PACKAGING_VARS) FLOW_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent-flow

dist.temp/grafana-agent-flow-linux-ppc64le: GO_TAGS += builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-ppc64le: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-ppc64le: GOOS := linux
dist.temp/grafana-agent-flow-linux-ppc64le: GOARCH := ppc64le
dist.temp/grafana-agent-flow-linux-ppc64le: generate-ui
$(PACKAGING_VARS) FLOW_BINARY=$@ $(MAKE) -f $(PARENT_MAKEFILE) agent-flow

dist.temp/grafana-agent-flow-linux-s390x: GO_TAGS += builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-s390x: GO_TAGS += netgo builtinassets promtail_journal_enabled
dist.temp/grafana-agent-flow-linux-s390x: GOOS := linux
dist.temp/grafana-agent-flow-linux-s390x: GOARCH := s390x
dist.temp/grafana-agent-flow-linux-s390x: generate-ui
Expand Down