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

cmd/go: go mod get unexpected EOF even though can git clone #52396

Closed
NhokCrazy199 opened this issue Apr 18, 2022 · 3 comments
Closed

cmd/go: go mod get unexpected EOF even though can git clone #52396

NhokCrazy199 opened this issue Apr 18, 2022 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@NhokCrazy199
Copy link

Thank you for visiting here.

First of all, I apologize for my bad English, maybe a little wrong, hope you can help me.

Then I had a little problem when deploying a new CI/CD system on k8s platform (v1.23.5+1) with Gitlab runner (14.9.0) and dind (docker:dind)

When deploying CI to Golang apps with private repositories at https://gitlab.domain.com, (I did the go env -w GOPRIVATE configuration), I had a problem with the go mod tidy command. Specifically getting the unexpected EOF error. I've tried go mod tidy -v but it doesn't seem to give any more info.

I did a lot of work to figure out the problem. Specifically, I have done wget and git clone commands with my private repository and they are still able to download successfully. I tried adding a private repository at https://gitlab.com in go.mod, they can still be retrieved without any errors.
And actually, without using my new runner, I can still git clone and go mod tidy in another vps.
All of this leaves me wondering where am I actually getting the error? Is it my gitlab or my k8s gitlab runner

This is runner output:

go: downloading gitlab.domain.com/nood/fountain v0.0.12
get "gitlab.domain.com/nood/fountain": found meta tag vcs.metaImport{Prefix:"gitlab.domain.com/nood/fountain", VCS:"git", RepoRoot:"https://gitlab.domain.com/nood/fountain.git"} at //gitlab.domain.com/nood/fountain?go-get=1
unexpected EOF
Cleaning up project directory and file based variables
ERROR: Job failed: command terminated with exit code 1

This is my .gitlab-ci.yml

image: docker:latest

stages:
  - build
  - deploy

variables:
  GTV_ECR_REPOSITORY_URL: repo.domain.com
  PROJECT: nood
  APP_NAME: backend-super-system
  APP_NAME_ECR: backend-super-system
  IMAGE_TAG: $GTV_ECR_REPOSITORY_URL/$PROJECT/$APP_NAME_ECR
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""

services:
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh", "--tls=false"]

build:
  stage: build
  allow_failure: false
  script:
    - echo "Building image."
    - docker pull $IMAGE_TAG || echo "Building runtime from scratch"
    - >
      docker build
      --cache-from $IMAGE_TAG
      -t $IMAGE_TAG --network host .
    - docker push $IMAGE_TAG

Dockerfile

FROM golang:alpine3.15

LABEL maintainer="NoodExe <nood.pr@gmail.com>"

WORKDIR /app

ENV BIN_DIR=/app/bin

RUN apk add --no-cache gcc build-base git

ADD . .

RUN chmod +x scripts/env.sh scripts/build.sh \
	&& ./scripts/env.sh \
	&& ./scripts/build.sh

# stage 2
FROM alpine:latest

WORKDIR /app

ENV BIN_DIR=/app/bin
ENV SCRIPTS_DIR=/app/scripts
ENV DATA_DIR=/app/data

# Build Args
ARG LOG_DIR=/var/log/nood

# Create log directory
RUN mkdir -p ${BIN_DIR} \
	mkdir -p ${SCRIPTS_DIR} \
    mkdir -p ${DATA_DIR} \
	mkdir -p ${LOG_DIR} \
    && apk update \
	&& addgroup -S nood \
	&& adduser -S nood -G nood \
	&& chown nood:nood /app \
	&& chown nood:nood ${LOG_DIR}

USER nood

COPY --chown=nood:nood --from=0 ${BIN_DIR} /app
COPY --chown=nood:nood --from=0 ${DATA_DIR} ${DATA_DIR}
COPY --chown=nood:nood --from=0 ${SCRIPTS_DIR} ${SCRIPTS_DIR}

RUN chmod +x  ${SCRIPTS_DIR}/startup.sh

ENTRYPOINT ["/app/scripts/startup.sh"]

scripts/env.sh

```shell #!/bin/sh

go env -w GOPRIVATE=gitlab.domain.com/*
git config --global --add url."https://nood_deploy:rvbsosecret_Hizt97zQSn@gitlab.domain.com".insteadOf "https://gitlab.domain.com"

</details>

`scripts/build.sh`
<details>
```shell
#!/bin/sh

grep -v "replace\s.*=>.*" go.mod > tmpfile && mv tmpfile go.mod

go mod tidy

set -e

BIN_DIR=${BIN_DIR:-/app/bin}
mkdir -p "$BIN_DIR"

files=`ls *.go`

echo "****************************************"
echo "******** building applications **********"
echo "****************************************"

for file in $files; do
	echo building $file
	go build -o "$BIN_DIR"/${file%.go} $file
done

Thank you for still being here :3

What version of Go are you using (go version)?

k8s platform (v1.23.5+1) with Gitlab runner (14.9.0) and dind (docker:dind) with golang:alpine3.15 image

What operating system and processor architecture are you using (go env)?

go env Output in my golang:alpine3.15 image
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY="gitlab.domain.com/*"
GONOSUMDB="gitlab.domain.com/*"
GOOS="linux"
GOPATH="/go"
GOPRIVATE="gitlab.domain.com/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/app/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2577457332=/tmp/go-build -gno-record-gcc-switches"
@NhokCrazy199 NhokCrazy199 changed the title affected/package: affected/package: Go mod get unexpected EOF even though can git clone Apr 18, 2022
@thanm thanm changed the title affected/package: Go mod get unexpected EOF even though can git clone cmd/go: go mod get unexpected EOF even though can git clone Apr 18, 2022
@thanm thanm added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 18, 2022
@thanm
Copy link
Contributor

thanm commented Apr 18, 2022

It would be helpful if you could post the exact "go" commands that are triggering the problem (as opposed to referencing build scripts). E.g. I did "go xxx ..." followed by "go yyy ..." and this eventually produced the error. Thanks.

@seankhliao
Copy link
Member

Is the repo using gitlab's subgroups?

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants