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

Update gorethink from v3 to v6 and rename to proper rethinkdb-go package #1537

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

cquon
Copy link
Contributor

@cquon cquon commented Mar 11, 2020

Gorethink is currently on v6 this is a bump to the v3 client to consume the latest client as well as update required dependencies by the v6 library as well.

@cquon
Copy link
Contributor Author

cquon commented Mar 11, 2020

It appears there are existing linting errors for gosec.

@justincormack
Copy link
Contributor

Ah I think gosec did some updates recently and we are not pinning the version.

@cquon cquon force-pushed the gorethink_v6 branch 3 times, most recently from d3740f3 to fcb498b Compare March 12, 2020 02:01
Copy link
Contributor

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Left some comments inline (bear with me, still trying to get used to some oddities of go modules);

Running go mod tidy, I get a diff;

git diff
diff --git a/go.sum b/go.sum
index fe661110..1e02e6e6 100644
--- a/go.sum
+++ b/go.sum
@@ -50,6 +50,7 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2V
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
 github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
 github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93 h1:jc2UWq7CbdszqeH6qu1ougXMIUBfSy8Pbh/anURYbGI=
 github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg=
 github.com/gorilla/mux v1.7.0 h1:tOSd0UKHQd6urX6ApfOn4XdBMY6Sh1MfxV3kmaazO+U=

We should probably update CI do a go mod tidy ?

On this PR, it also shows this output;

github.com/theupdateframework/notary/server imports
	github.com/prometheus/client_golang/prometheus imports
	github.com/prometheus/common/expfmt imports
	github.com/matttproud/golang_protobuf_extensions/pbutil tested by
	github.com/matttproud/golang_protobuf_extensions/pbutil.test imports
	github.com/golang/protobuf/proto/testdata: module github.com/golang/protobuf@latest (v1.3.5) found, but does not contain package github.com/golang/protobuf/proto/testdata

The testdata package was renamed from testdata to test_proto in this commit: golang/protobuf@8cc9e46

So it looks like go mod checks test files, even though they're not vendored; the vendored code only mentions the gogo/protobuf package, which still has that directory in the version that's vendored;

git grep proto/testdata

vendor/github.com/gogo/protobuf/proto/Makefile: make -C testdata
vendor/github.com/gogo/protobuf/proto/Makefile: protoc-min-version --version="3.0.0" --proto_path=.:../../../../:../protobuf --gogo_out=Mtestdata/test.proto=github.com/gogo/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. proto3_proto/proto3.proto

Looking at matttproud/golang_protobuf_extensions it indeed references that package; https://github.com/matttproud/golang_protobuf_extensions/blob/v1.0.1/pbutil/all_test.go#L23. That looks to be a bug, because its go.mod requires github.com/golang/[email protected], which does not have the testdata; https://github.com/golang/protobuf/tree/v1.2.0/proto

Ignore this, it's not referencing the package?

I don't expect this to be a problem (because we don't run those tests), but looks like we should open a PR in https://github.com/matttproud/golang_protobuf_extensions to fix.

Some things we should look at:

Separate from this PR:

Makefile Outdated
@@ -110,7 +110,7 @@ endif
# gosec - requires that the following be run first:
# go get -u github.com/securego/gosec/cmd/gosec/...
@rm -f gosec_output.csv
@gosec -fmt=csv -out=gosec_output.csv -exclude=G104,G304 ./... || (cat gosec_output.csv >&2; exit 1)
@gosec -fmt=csv -out=gosec_output.csv -exclude=G104,G304,G306 ./... || (cat gosec_output.csv >&2; exit 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

For the record;

G306: Poor file permissions used when writing to a new file

This was to suppress a linting error complaing about a file having 0644 instead of 0600.

nit: probably would've been good to describe this in the commit message, but not a blocker for me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll need to make some changes so I'll rebase and update the commit message!

Copy link
Contributor

Choose a reason for hiding this comment

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

I was trying to remove the vendor.conf and ran into the linting issue, so I carried the first commit in #1540 (and updated the commit message)

once that (and #1539) is merged, you can rebase to have just the changes related to the rethinkdb update in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you!

@@ -25,7 +25,7 @@ import (
"github.com/theupdateframework/notary/tuf/signed"
"github.com/theupdateframework/notary/utils"
"golang.org/x/net/context"
"gopkg.in/gorethink/gorethink.v3"
gorethink "gopkg.in/rethinkdb/rethinkdb-go.v6"
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious; didn't it work without the manual aliasing? (I thought anything -go was automatically handled, but perhaps that doesn't work in combination with the .vXX suffix)

No need to change, just curious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No they renamed the package name from gorethink to rethinkdb

https://gopkg.in/rethinkdb/rethinkdb-go.v3
https://gopkg.in/rethinkdb/rethinkdb-go.v6

so figured the path of least resistance was to alias it, also because there is another rethinkdb package in this code that it caused conflict with in some of the files.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh! for some reason I only saw the -go suffix 🤦‍♂️

vendor.conf Outdated
gopkg.in/rethinkdb/rethinkdb-go.v6 bbcde53c1229eece19f8df1ff58cc962e52c0c10 # v6.1.0
gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remove this file, as it should no longer be used; I noticed that just after the go mod PR was merged; I'll open a PR

Copy link
Contributor

Choose a reason for hiding this comment

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

PR is up: #1539

(but ran into the gosec linting issue as well, so carried that commit in #1540 😂)

github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b // indirect
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 // indirect
github.com/cenkalti/backoff v1.0.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why it removes this one from go.mod because the vendor directory still has this dependency vendored. Is it because it's github.com/cenkalti/backoff v2.2.1+incompatible now (no go module support in that version?)

github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93 // indirect
github.com/gorilla/mux v1.7.0
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for this (just curious); as this one is still vendored

Comment on lines -37 to -38
github.com/kr/pretty v0.0.0-20130510082846-bc9499caa0f4 // indirect
github.com/kr/text v0.0.0-20130911015532-6807e777504f // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

And these (also just curious)

Comment on lines +54 to +55
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update these to a more current version? They seem to be somewhat behind

Copy link
Contributor

Choose a reason for hiding this comment

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

can you do another PR for that?

@thaJeztah
Copy link
Contributor

Oh, ignore the mattproud testdata comment; I don't think it's referencing it (looking again)

@thaJeztah
Copy link
Contributor

Looks like that issue was fixed in v1.0.1, so updating it to v1.0.1 should address it; matttproud/golang_protobuf_extensions@v1.0.0...v1.0.1

Can you also run go mod vendor ? Because it looks like revendoring with go mod removes a number of files:

root@2f91fcfa08c9:/go/src/github.com/theupdateframework/notary# go mod vendor
root@2f91fcfa08c9:/go/src/github.com/theupdateframework/notary# git status
Refresh index: 100% (1727/1727), done.
On branch gorethink_v6
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	deleted:    vendor/github.com/google/certificate-transparency-go/x509/root_darwin_arm_gen.go
	deleted:    vendor/github.com/google/certificate-transparency-go/x509/x509_test_import.go
	deleted:    vendor/github.com/lib/pq/oid/gen.go
	deleted:    vendor/golang.org/x/sys/unix/mkasm_darwin.go
	deleted:    vendor/golang.org/x/sys/unix/mkpost.go
	deleted:    vendor/golang.org/x/sys/unix/mksyscall.go
	deleted:    vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go
	deleted:    vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go
	deleted:    vendor/golang.org/x/sys/unix/mksyscall_solaris.go
	deleted:    vendor/golang.org/x/sys/unix/mksysctl_openbsd.go
	deleted:    vendor/golang.org/x/sys/unix/mksysnum.go
	deleted:    vendor/golang.org/x/sys/unix/types_aix.go
	deleted:    vendor/golang.org/x/sys/unix/types_darwin.go
	deleted:    vendor/golang.org/x/sys/unix/types_dragonfly.go
	deleted:    vendor/golang.org/x/sys/unix/types_freebsd.go
	deleted:    vendor/golang.org/x/sys/unix/types_netbsd.go
	deleted:    vendor/golang.org/x/sys/unix/types_openbsd.go
	deleted:    vendor/golang.org/x/sys/unix/types_solaris.go
	deleted:    vendor/golang.org/x/text/unicode/bidi/gen.go
	deleted:    vendor/golang.org/x/text/unicode/bidi/gen_ranges.go
	deleted:    vendor/golang.org/x/text/unicode/bidi/gen_trieval.go
	deleted:    vendor/golang.org/x/text/unicode/norm/maketables.go
	deleted:    vendor/golang.org/x/text/unicode/norm/triegen.go
	modified:   vendor/modules.txt

@thaJeztah
Copy link
Contributor

D'oh! That may be because I ran it on Go 1.13. sigh. I hate it that they continue breaking go modules between releases.

@thaJeztah
Copy link
Contributor

Looks like it's still failing on that permission error 😞

I also noticed these errors;

find: unknown predicate `-not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**''

Could it be that we're using busybox, and that busybox's find doesn't support these?

@cquon
Copy link
Contributor Author

cquon commented Mar 18, 2020

Looks like it's still failing on that permission error 😞

I also noticed these errors;

find: unknown predicate `-not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**''

Could it be that we're using busybox, and that busybox's find doesn't support these?

This change shouldn't be affecting busybox though right?

@cquon cquon force-pushed the gorethink_v6 branch 2 times, most recently from c43a3ba to 2606549 Compare March 19, 2020 04:00
@cquon
Copy link
Contributor Author

cquon commented Mar 19, 2020

@thaJeztah I believe the buildscripts/circle-validate-vendor.sh script which invokes buildscripts/validate-vendor.sh ends up touching the go.sum file

Seems to have been a known issue: golang/go#34634 which is likely due to the fact the container is using go 1.12.5. I bumped it to go 1.13 and I saw the file permissions still became readable, but the go mod output was different so I figured it'd be best to stay on the same version of go and manually modify the permissions.

@@ -23,6 +23,8 @@ if [ -d vendor ]; then
go mod vendor
fi

chmod 644 "go.sum"
Copy link
Contributor

Choose a reason for hiding this comment

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

This must be a bug. Even if go mod ... updates the contents, it should not change file permissions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea copied the issue here: golang/go#34634 I think it's resolved in newer versions of go but this is on 1.12

Copy link
Contributor

Choose a reason for hiding this comment

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

With go 1.12 having reached EOL, should we update to go 1.13 or go 1.14 @justincormack ? I see there's some existing PRs but they appear to be outdated; #1515, #1522, #1536

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could this potentially be merged in to get get updated dependencies working for 1.12 until we can migrate to a newer version of go?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather update Go first.

@justincormack
Copy link
Contributor

Go is updated now, this needs a rebase and should fix the go.mod issue.

@cquon cquon force-pushed the gorethink_v6 branch 2 times, most recently from d478f15 to 992a3e6 Compare April 3, 2020 19:43
@cquon
Copy link
Contributor Author

cquon commented Apr 3, 2020

Go is updated now, this needs a rebase and should fix the go.mod issue.

Thanks @justincormack it did indeed 👍

Copy link
Contributor

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM (non-binding)

@thaJeztah
Copy link
Contributor

@HuKeping ptal 🤗

Copy link
Contributor

@HuKeping HuKeping left a comment

Choose a reason for hiding this comment

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

LGTM!

@HuKeping HuKeping merged commit dc18d79 into notaryproject:master Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants