Open andsens opened 3 years ago
This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
/remove-label stale
Alright, so I compiled my own version for testing purposes. Beyond what I outlined above the CGO_ENABLED=0
also needs to be removed. Here's the Makefile diff:
diff --git a/Makefile b/Makefile
index 0cddb1721..4e7a3cc14 100644
--- a/Makefile
+++ b/Makefile
@@ -60,13 +60,13 @@ APP_GO_FILES := $(shell find . $(DONT_FIND) -name .y.go -prune -o -name .pb.go -
# Build flags
VPREFIX := github.com/grafana/loki/pkg/build
GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(IMAGE_TAG) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildUser=$(shell whoami)@$(shell hostname) -X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
-GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)" -tags netgo $(MOD_FLAG)
-DYN_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags netgo $(MOD_FLAG)
+GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)" $(MOD_FLAG)
+DYN_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" $(MOD_FLAG)
# Per some websites I've seen to add `-gcflags "all=-N -l"`, the gcflags seem poorly if at all documented
# the best I could dig up is -N disables optimizations and -l disables inlining which should make debugging match source better.
# Also remove the -s and -w flags present in the normal build which strip the symbol table and the DWARF symbol table.
-DEBUG_GO_FLAGS := -gcflags "all=-N -l" -ldflags "-extldflags \"-static\" $(GO_LDFLAGS)" -tags netgo $(MOD_FLAG)
-DYN_DEBUG_GO_FLAGS := -gcflags "all=-N -l" -ldflags "$(GO_LDFLAGS)" -tags netgo $(MOD_FLAG)
+DEBUG_GO_FLAGS := -gcflags "all=-N -l" -ldflags "-extldflags \"-static\" $(GO_LDFLAGS)" $(MOD_FLAG)
+DYN_DEBUG_GO_FLAGS := -gcflags "all=-N -l" -ldflags "$(GO_LDFLAGS)" $(MOD_FLAG)
# Docker mount flag, ignored on native docker host. see (https://docs.docker.com/docker-for-mac/osxfs-caching/#delegated)
MOUNT_FLAGS := :delegated
@@ -157,8 +157,7 @@ logcli-image:
$(SUDO) docker build -t $(IMAGE_PREFIX)/logcli:$(IMAGE_TAG) -f cmd/logcli/Dockerfile .
cmd/logcli/logcli: $(APP_GO_FILES) cmd/logcli/main.go
- CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
- $(NETGO_CHECK)
+ go build $(GO_FLAGS) -o $@ ./$(@D)
########
# Loki #
The results are as expected, resolving mDNS addresses now works.
Hi! This issue has been automatically marked as stale because it has not had any activity in the past 30 days.
We use a stalebot among other tools to help manage the state of issues in this project. A stalebot can be very useful in closing issues in a number of cases; the most common is closing issues or PRs where the original reporter has not responded.
Stalebots are also emotionless and cruel and can close issues which are still very relevant.
If this issue is important to you, please add a comment to keep it open. More importantly, please add a thumbs-up to the original issue entry.
We regularly sort for closed issues which have a stale
label sorted by thumbs up.
We may also:
revivable
if we think it's a valid issue but isn't something we are likely
to prioritize in the future (the issue will still remain closed).keepalive
label to silence the stalebot if the issue is very common/popular/important.We are doing our best to respond, organize, and prioritize all issues but it can be a challenging task, our sincere apologies if you find yourself at the mercy of the stalebot.
/remove-lifecycle stale
Hi! This issue has been automatically marked as stale because it has not had any activity in the past 30 days.
We use a stalebot among other tools to help manage the state of issues in this project. A stalebot can be very useful in closing issues in a number of cases; the most common is closing issues or PRs where the original reporter has not responded.
Stalebots are also emotionless and cruel and can close issues which are still very relevant.
If this issue is important to you, please add a comment to keep it open. More importantly, please add a thumbs-up to the original issue entry.
We regularly sort for closed issues which have a stale
label sorted by thumbs up.
We may also:
revivable
if we think it's a valid issue but isn't something we are likely
to prioritize in the future (the issue will still remain closed).keepalive
label to silence the stalebot if the issue is very common/popular/important.We are doing our best to respond, organize, and prioritize all issues but it can be a challenging task, our sincere apologies if you find yourself at the mercy of the stalebot.
hmm if CGO_ENABLED=0 has to be removed it means it should use CGO_ENABLED. Isn't that potentially a breaking change to Loki users?
With changes to in 1.20.x I've been getting best results on mac with CGO_ENABLED=0 and let the new code call libc for resolution.
I am running a local Loki
2.1.0
install on my dev box.logcli
fails to resolve the loki endpoint address with the following error:I'm fairly certain that the issue here is that I am using an mDNS address (
loki-aim.local
) for my loki endpoint while logcli is compiled with thenetgo
tag, preventing the internal resolver from falling back to the cgo resolver.You can read more about it here:
Using mDNS in dev is super useful if one doesn't want to setup all kinds of dns resolution hacks. I am unable to work around the problem with e.g.
LOKI_ADDR="https://$(avahi-resolve -n loki-aim.local | cut -f2)"
because my reverse-proxy in front of loki requires TLS with SNI.As far as I can see, removing
-tag netgo
here https://github.com/grafana/loki/blob/4a8f62ba00bcf6d338833eb506f91789c9ed584e/Makefile#L60-L69 should do the trick.There's also this check: https://github.com/grafana/loki/blob/4a8f62ba00bcf6d338833eb506f91789c9ed584e/Makefile#L73-L80
Blaming the lines doesn't reveal much, it's been there since the beginning. It seems like it's supposed to make sure that the pure go resolver is included, but instead just makes sure that the cgo one is excluded. As far as I understand there's no issue in both being present, so changing that check to make sure the pure go resolver is included would seem to be the way to go.