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: inconsistent vendoring #47575

Closed
sergevonage opened this issue Aug 6, 2021 · 6 comments
Closed

cmd/go: inconsistent vendoring #47575

sergevonage opened this issue Aug 6, 2021 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@sergevonage
Copy link

sergevonage commented Aug 6, 2021

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

$ go version
go1.16.7

Does this issue reproduce with the latest release?

Yes, it does

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
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.16.7"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/go/src/submission/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3601998646=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I run docker build with Kaniko on kubernetes.

My dockerfile:


ARG PROJECT
# builder image
FROM golang:1.16.7-alpine3.14 as builder

ARG PROJECT
# use ENV to make value accessible on every stage
ENV PROJECT=$PROJECT

WORKDIR /go/src/$PROJECT

COPY $PROJECT/ ./
RUN go env
# moves for make compilation happy
RUN GO111MODULE=on CGO_ENABLED=0 go build -mod vendor --ldflags "-s -w" -o app .



FROM gcr.io/distroless/static

ARG PROJECT

# Add executable into image
COPY --from=builder  /go/src/$PROJECT/app  /

# execute command when docker launches / run
CMD ["./app"]

go.mod
module handler/function

go 1.16

require (
	github.com/caarlos0/env/v6 v6.5.0
	github.com/gin-gonic/gin v1.6.3
	github.com/google/go-cmp v0.5.5 // indirect
	github.com/nats-io/nats-streaming-server v0.21.0 // indirect
	github.com/nats-io/nats.go v1.10.0
	github.com/nats-io/stan.go v0.8.3
	github.com/pkg/errors v0.9.1
	github.com/prometheus/client_golang v1.7.1
	github.com/rs/zerolog v1.20.0
	github.com/satori/go.uuid v1.2.0
	github.com/stretchr/testify v1.7.0
	golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
)
vendor/modules.txt
# github.com/beorn7/perks v1.0.1
github.com/beorn7/perks/quantile
# github.com/caarlos0/env/v6 v6.5.0
## explicit
github.com/caarlos0/env/v6
# github.com/cespare/xxhash/v2 v2.1.1
github.com/cespare/xxhash/v2
# github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew/spew
# github.com/gin-contrib/sse v0.1.0
github.com/gin-contrib/sse
# github.com/gin-gonic/gin v1.6.3
## explicit
github.com/gin-gonic/gin
github.com/gin-gonic/gin/binding
github.com/gin-gonic/gin/internal/bytesconv
github.com/gin-gonic/gin/internal/json
github.com/gin-gonic/gin/render
# github.com/go-playground/locales v0.13.0
github.com/go-playground/locales
github.com/go-playground/locales/currency
# github.com/go-playground/universal-translator v0.17.0
github.com/go-playground/universal-translator
# github.com/go-playground/validator/v10 v10.4.1
github.com/go-playground/validator/v10
# github.com/gogo/protobuf v1.3.2
github.com/gogo/protobuf/gogoproto
github.com/gogo/protobuf/proto
github.com/gogo/protobuf/protoc-gen-gogo/descriptor
# github.com/golang/protobuf v1.4.3
github.com/golang/protobuf/proto
github.com/golang/protobuf/ptypes
github.com/golang/protobuf/ptypes/any
github.com/golang/protobuf/ptypes/duration
github.com/golang/protobuf/ptypes/timestamp
# github.com/google/go-cmp v0.5.5
## explicit
# github.com/json-iterator/go v1.1.10
github.com/json-iterator/go
# github.com/leodido/go-urn v1.2.0
github.com/leodido/go-urn
# github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-isatty
# github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/matttproud/golang_protobuf_extensions/pbutil
# github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/modern-go/concurrent
# github.com/modern-go/reflect2 v1.0.1
github.com/modern-go/reflect2
# github.com/nats-io/jwt v1.1.0
github.com/nats-io/jwt
# github.com/nats-io/nats-streaming-server v0.21.0
## explicit
# github.com/nats-io/nats.go v1.10.0
## explicit
github.com/nats-io/nats.go
github.com/nats-io/nats.go/encoders/builtin
github.com/nats-io/nats.go/util
# github.com/nats-io/nkeys v0.1.4
github.com/nats-io/nkeys
# github.com/nats-io/nuid v1.0.1
github.com/nats-io/nuid
# github.com/nats-io/stan.go v0.8.3
## explicit
github.com/nats-io/stan.go
github.com/nats-io/stan.go/pb
# github.com/nexmoinc/neru-runtimelib v0.0.15
## explicit
# github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e
github.com/opentracing/opentracing-go
github.com/opentracing/opentracing-go/ext
github.com/opentracing/opentracing-go/log
# github.com/pkg/errors v0.9.1
## explicit
github.com/pkg/errors
# github.com/pmezard/go-difflib v1.0.0
github.com/pmezard/go-difflib/difflib
# github.com/prometheus/client_golang v1.7.1
## explicit
github.com/prometheus/client_golang/prometheus
github.com/prometheus/client_golang/prometheus/internal
github.com/prometheus/client_golang/prometheus/promhttp
# github.com/prometheus/client_model v0.2.0
github.com/prometheus/client_model/go
# github.com/prometheus/common v0.10.0
github.com/prometheus/common/expfmt
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/common/model
# github.com/prometheus/procfs v0.6.0
github.com/prometheus/procfs
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
# github.com/rs/zerolog v1.20.0
## explicit
github.com/rs/zerolog
github.com/rs/zerolog/internal/cbor
github.com/rs/zerolog/internal/json
# github.com/satori/go.uuid v1.2.0
## explicit
github.com/satori/go.uuid
# github.com/stretchr/testify v1.7.0
## explicit
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
# github.com/uber/jaeger-client-go v2.25.0+incompatible
github.com/uber/jaeger-client-go
github.com/uber/jaeger-client-go/config
github.com/uber/jaeger-client-go/internal/baggage
github.com/uber/jaeger-client-go/internal/baggage/remote
github.com/uber/jaeger-client-go/internal/reporterstats
github.com/uber/jaeger-client-go/internal/spanlog
github.com/uber/jaeger-client-go/internal/throttler
github.com/uber/jaeger-client-go/internal/throttler/remote
github.com/uber/jaeger-client-go/log
github.com/uber/jaeger-client-go/rpcmetrics
github.com/uber/jaeger-client-go/thrift
github.com/uber/jaeger-client-go/thrift-gen/agent
github.com/uber/jaeger-client-go/thrift-gen/baggage
github.com/uber/jaeger-client-go/thrift-gen/jaeger
github.com/uber/jaeger-client-go/thrift-gen/sampling
github.com/uber/jaeger-client-go/thrift-gen/zipkincore
github.com/uber/jaeger-client-go/transport
github.com/uber/jaeger-client-go/utils
# github.com/uber/jaeger-lib v2.4.0+incompatible
github.com/uber/jaeger-lib/metrics
# github.com/ugorji/go/codec v1.1.13
github.com/ugorji/go/codec
# go.uber.org/atomic v1.7.0
go.uber.org/atomic
# golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/crypto/ed25519
golang.org/x/crypto/ed25519/internal/edwards25519
golang.org/x/crypto/sha3
# golang.org/x/sys v0.0.0-20210510120138-977fb7262007
## explicit
golang.org/x/sys/cpu
golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix
golang.org/x/sys/windows
# google.golang.org/protobuf v1.25.0
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/encoding/protowire
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/detrand
google.golang.org/protobuf/internal/encoding/defval
google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/internal/fieldsort
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/internal/impl
google.golang.org/protobuf/internal/mapsort
google.golang.org/protobuf/internal/pragma
google.golang.org/protobuf/internal/set
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/version
google.golang.org/protobuf/proto
google.golang.org/protobuf/reflect/protoreflect
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/runtime/protoimpl
google.golang.org/protobuf/types/known/anypb
google.golang.org/protobuf/types/known/durationpb
google.golang.org/protobuf/types/known/timestamppb
# gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v2
# gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
gopkg.in/yaml.v3
When I run it build locally on my machine or in docker itself it works fine. It fails only during Kaniko build

What did you expect to see?

Build is success

What did you see instead?

github.com/caarlos0/env/v6@v6.5.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
...
To ignore the vendor directory, use -mod=readonly or -mod=mod.
To sync the vendor directory, run:
go mod vendor

@seankhliao seankhliao changed the title go: inconsistent vendoring cmd/go: inconsistent vendoring Aug 7, 2021
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 7, 2021
@seankhliao
Copy link
Member

what changes if you run go mod vendor during a kaniko build?

@hitzhangjie
Copy link
Contributor

hitzhangjie commented Aug 7, 2021

You should run go mod vendor to update vendor/modules.txt to explicitly require the module.

This just add line '## explicitly' before the required module in vendor/modules.txt.

@sergevonage
Copy link
Author

sergevonage commented Aug 9, 2021

@seankhliao if I add go mod vendor it tries to pull dependencies

@sergevonage
Copy link
Author

@hitzhangjie how I do it:

  • run locally go mod vendor and it makes for me /vendor/**
  • run docker build - success
  • run kaniko build - failure

what do you suggest to do differently?

@bcmills
Copy link
Contributor

bcmills commented Aug 9, 2021

github.com/caarlos0/env/v6@v6.5.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

That error message is not consistent with the vendor/modules.txt content you posted, which does have github.com/caarlos0/env/v6 v6.5.0 marked as explicit.

Is it possible that your kaniko build is seeing a different vendor/modules.txt from what you have locally?

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 9, 2021
@seankhliao
Copy link
Member

can you provide a diff of vendor/modules.txt after you run go mod vendor within kaniko?

@golang golang locked and limited conversation to collaborators Aug 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants