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: modules seem to leave the package directory in an inconsistent state sometimes #27952

Closed
jsternberg opened this issue Oct 1, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@jsternberg
Copy link

commented Oct 1, 2018

What did you do?

I am not able to reproduce it consistently, but the company I work at has been using modules for about a week and we run into a variant of this problem fairly frequently.

Here is an aggregate of the various terminals I used when running into the problem most recently. The (pseudo-anonymized) directories are included for each command since I work in a split-screen tmux so not all of the commands were in the same terminal pane.

jsternberg:[~/g/s/g/i/myproject] $ (master=) go build
go: finding k8s.io/apimachinery/pkg/util/errors latest
go: finding k8s.io/apimachinery/pkg/util/validation latest
go: finding k8s.io/apimachinery/pkg/util/net latest
go: finding k8s.io/apimachinery/pkg/api/errors latest
go: finding k8s.io/apimachinery/pkg/types latest
go: finding k8s.io/apimachinery/pkg/apis/meta/v1/unstructured latest
go: finding k8s.io/apimachinery/pkg/util/strategicpatch latest
go: finding k8s.io/apimachinery/pkg/runtime/schema latest
go: finding k8s.io/apimachinery/pkg/runtime/serializer latest
go: finding k8s.io/apimachinery/pkg/api/resource latest
go: finding k8s.io/apimachinery/pkg/util latest
go: finding k8s.io/apimachinery/pkg/api latest
go: finding k8s.io/apimachinery/pkg latest
go: finding k8s.io/apimachinery/pkg/runtime latest
go: finding k8s.io/apimachinery latest
go: finding k8s.io/apimachinery/pkg/apis/meta latest
go: finding k8s.io/apimachinery/pkg/util/intstr latest
go: finding k8s.io/apimachinery/pkg/runtime/serializer/json latest
go: finding k8s.io/apimachinery/pkg/version latest
go: finding k8s.io/apimachinery/pkg/watch latest
go: finding k8s.io/apimachinery/pkg/api/meta latest
go: finding k8s.io/apimachinery/pkg/runtime/serializer/streaming latest
go: finding k8s.io/apimachinery/pkg/conversion latest
go: finding k8s.io/apimachinery/pkg/apis latest
go: finding k8s.io/apimachinery/pkg/fields latest
go: finding k8s.io/apimachinery/pkg/runtime/serializer/versioning latest
go: finding k8s.io/apimachinery/pkg/util/clock latest
go: finding k8s.io/apimachinery/pkg/util/sets latest
# k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1
../../../../pkg/mod/k8s.io/client-go@v8.0.0+incompatible/pkg/apis/clientauthentication/v1alpha1/zz_generated.conversion.go:39:15: scheme.AddGeneratedConversionFuncs undefined (type *runtime.Scheme has no field or method AddGeneratedConver
sionFuncs)
# k8s.io/client-go/pkg/apis/clientauthentication/v1beta1
../../../../pkg/mod/k8s.io/client-go@v8.0.0+incompatible/pkg/apis/clientauthentication/v1beta1/zz_generated.conversion.go:39:15: scheme.AddGeneratedConversionFuncs undefined (type *runtime.Scheme has no field or method AddGeneratedConvers
ionFuncs)
jsternberg:[~/g/s/g/i/myproject] $ (master *=) git st
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   go.mod
        modified:   go.sum

no changes added to commit (use "git add" and/or "git commit -a")
jsternberg:[~/g/s/g/i/myproject] $ (master *=) git diff
diff --git a/go.mod b/go.mod
index fcb7f41..7f84d2f 100644
--- a/go.mod
+++ b/go.mod
@@ -33,7 +33,7 @@ require (
        gopkg.in/inf.v0 v0.9.1 // indirect
        gopkg.in/yaml.v2 v2.2.1
        k8s.io/api v0.0.0-20180913155108-f456898a08e4
-       k8s.io/apimachinery v0.0.0-20180904193909-def12e63c512
+       k8s.io/apimachinery v0.0.0-20180927151612-c6dd271be006
        k8s.io/client-go v8.0.0+incompatible
        k8s.io/kube-openapi v0.0.0-20180731170545-e3762e86a74c // indirect
 )
diff --git a/go.sum b/go.sum
index 2bdef5c..c374a4a 100644
--- a/go.sum
+++ b/go.sum
@@ -86,6 +86,8 @@ k8s.io/api v0.0.0-20180913155108-f456898a08e4 h1:ULsewO4HnVexbLMSexmlht7KBZgsrSH
 k8s.io/api v0.0.0-20180913155108-f456898a08e4/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
 k8s.io/apimachinery v0.0.0-20180904193909-def12e63c512 h1:/Z1m/6oEN6hE2SzWP4BHW2yATeUrBRr+1GxNf1Ny58Y=
 k8s.io/apimachinery v0.0.0-20180904193909-def12e63c512/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
+k8s.io/apimachinery v0.0.0-20180927151612-c6dd271be006 h1:JXoPWp33Ak0s8bDD8KBKVHlOSXEjW7FZ4fOry7wBS2A=
+k8s.io/apimachinery v0.0.0-20180927151612-c6dd271be006/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
 k8s.io/client-go v8.0.0+incompatible h1:7Zl+OVXn0bobcsi4NEZGdoQDTE9ij1zPMfM21+yqQsM=
 k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
jsternberg:[~] $ cd go/pkg/mod/k8s.io/apimachinery@v0.0.0-20180904193909-def12e63c512/
jsternberg:[~/g/p/m/k/apimachinery@v0.0.0-20180904193909-def12e63c512] $ ls
jsternberg:[~/g/p/m/k/apimachinery@v0.0.0-20180904193909-def12e63c512] $ ls -a
.       ..      .github
jsternberg:[~/g/p/m/k/apimachinery@v0.0.0-20180904193909-def12e63c512] $ ls .github/
PULL_REQUEST_TEMPLATE.md
jsternberg:[~/g/p/m/k/apimachinery@v0.0.0-20180904193909-def12e63c512] $ ..
jsternberg:[~/g/p/m/k8s.io] $ rm -r apimachinery@v0.0.0-20180904193909-def12e63c512/
override r--r--r--  jsternberg/staff for apimachinery@v0.0.0-20180904193909-def12e63c512//.github/PULL_REQUEST_TEMPLATE.md? y
jsternberg:[~/g/p/m/k8s.io] $ pwd
/Users/jsternberg/go/pkg/mod/k8s.io
jsternberg:[~/g/s/g/i/myapp] $ (master *=) git undo
HEAD is now at a04937b fix: modify the method name in skaffold config to pass go vet
jsternberg:[~/g/s/g/i/myapp] $ (master=) go install
go: extracting k8s.io/apimachinery v0.0.0-20180904193909-def12e63c512
jsternberg:[~/g/s/g/i/myapp] $ (master=) git st
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

I attempted to compile a program that had previously used go modules and previously worked. When I built it, it went and found a new version. I thought maybe it couldn't find the older revision because I had cleared out my package cache, but it seems as if the directory it was looking for was mostly empty except for one entry and go modules is unable to recover from this state.

This isn't the first time we have experienced something like this too. I have regularly had to teach people how to clear out their package caches because you have to force all of the directories to be writeable to actually remove the entries inside and we have had compilations fail because a go file was empty or a file that should be there is missing.

I do not have an effective way of reproducing, but I suspect it may be getting caused by Ctrl+C. I have no evidence for this and have no idea if that is true. I don't remember every time I interrupt a command from my terminal, but it seems like it could be plausible.

I have also had it successfully compile once and record the wrong hash inside of the go.sum file.

What did you expect to see?

I expected it to compile without issues and to not look for a new version. If there was a problem with the version that was specified, I expected it to loudly fail and tell me that the hash was wrong rather than to silently upgrade the version I was using.

What did you see instead?

It upgraded the version I was using to an incompatible copy and it did not tell me my local cache state was bad nor did it attempt to fix the cache state by redownloading or reextracting the zip file.

System details

go version go1.11 darwin/amd64
GOARCH="amd64"
GOBIN="/Users/jsternberg/go/pkg/bin/github.com/influxdata/kubone"
GOCACHE="/Users/jsternberg/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jsternberg/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jsternberg/go/src/github.com/influxdata/kubone/go.mod"
GOROOT/bin/go version: go version go1.11 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.11
uname -v: Darwin Kernel Version 17.7.0: Fri Jul  6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G2307
lldb --version: lldb-1000.11.37.1
  Swift-4.2

@agnivade agnivade changed the title go modules: seems to leave the package directory in an inconsistent state sometimes cmd/go: modules seem to leave the package directory in an inconsistent state sometimes Oct 1, 2018

@agnivade agnivade added this to the Go1.12 milestone Oct 1, 2018

@lyondhill

This comment has been minimized.

Copy link

commented Oct 12, 2018

I ran into this same issue. I was getting an error message vendor/github.com/google/go-github/github/github.go:757:8: undefined: Timestamp

I cleaned up my local go-github:

find ~/go/pkg/mod/github.com/google -type d | xargs chmod +w
rm -rf ~/go/pkg/mod/github.com/google

and ran go mod vendor and the missing files appeared:

 Untracked files:
  (use "git add <file>..." to include in what will be committed)

	vendor/github.com/google/go-github/github/search.go
	vendor/github.com/google/go-github/github/strings.go
	vendor/github.com/google/go-github/github/teams.go
	vendor/github.com/google/go-github/github/teams_discussion_comments.go
	vendor/github.com/google/go-github/github/teams_discussions.go
	vendor/github.com/google/go-github/github/teams_members.go
	vendor/github.com/google/go-github/github/timestamp.go
	vendor/github.com/google/go-github/github/users.go
	vendor/github.com/google/go-github/github/users_administration.go
	vendor/github.com/google/go-github/github/users_blocking.go
	vendor/github.com/google/go-github/github/users_emails.go
	vendor/github.com/google/go-github/github/users_followers.go
	vendor/github.com/google/go-github/github/users_gpg_keys.go
	vendor/github.com/google/go-github/github/users_keys.go
	vendor/github.com/google/go-github/github/with_appengine.go
	vendor/github.com/google/go-github/github/without_appengine.go
@bcmills

This comment has been minimized.

Copy link
Member

commented Nov 15, 2018

Without concrete repro steps, my best guess is that this is a duplicate of #26794. Please file a new issue if you see module-cache corruption after the fix for that lands.

@bcmills bcmills closed this Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.