From bc714cd8aeaa4f1a59e055b5a6411a04b17fd319 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Thu, 30 Jul 2020 16:15:35 -0700 Subject: [PATCH] Remove Go 1.9 / AppEngine support; assume go1.12 build tag (#3767) --- .travis.yml | 4 - CONTRIBUTING.md | 1 - Makefile | 8 -- balancer/rls/internal/balancer.go | 2 - balancer/rls/internal/balancer_test.go | 2 - balancer/rls/internal/builder.go | 2 - balancer/rls/internal/client_test.go | 2 - balancer/rls/internal/config.go | 2 - balancer/rls/internal/config_test.go | 2 - balancer/rls/internal/keys/builder.go | 2 - balancer/rls/internal/keys/builder_test.go | 2 - balancer/rls/internal/picker.go | 2 - balancer/rls/internal/picker_test.go | 2 - channelz/service/func_linux.go | 2 - channelz/service/func_nonlinux.go | 2 +- channelz/service/service_sktopt_test.go | 2 +- channelz/service/service_test.go | 2 +- channelz/service/util_sktopt_386_test.go | 2 +- channelz/service/util_sktopt_amd64_test.go | 2 +- credentials/go12.go | 30 ----- credentials/internal/syscallconn.go | 2 - credentials/internal/syscallconn_appengine.go | 30 ----- credentials/internal/syscallconn_test.go | 2 - credentials/tls.go | 4 + examples/features/xds/client/main.go | 2 - examples/features/xds/server/main.go | 2 - install_gae.sh | 6 - internal/channelz/types_linux.go | 2 - internal/channelz/types_nonlinux.go | 4 +- internal/channelz/util_linux.go | 2 +- internal/channelz/util_nonlinux.go | 2 +- internal/channelz/util_test.go | 2 +- internal/credentials/gobefore110.go | 31 ----- internal/credentials/{go110.go => spiffe.go} | 2 - .../{go110_test.go => spiffe_test.go} | 2 - internal/profiling/buffer/buffer.go | 2 - internal/profiling/buffer/buffer_appengine.go | 43 ------- internal/profiling/buffer/buffer_test.go | 2 - internal/profiling/profiling_test.go | 2 - internal/syscall/syscall_linux.go | 4 +- internal/syscall/syscall_nonlinux.go | 16 +-- interop/grpclb_fallback/client.go | 2 - security/advancedtls/{sni_110.go => sni.go} | 2 - security/advancedtls/sni_before_110.go | 41 ------- security/advancedtls/sni_test_before_110.go | 108 ------------------ .../{sni_test_110.go => sni_test_disabled.go} | 2 - test/channelz_linux_go110_test.go | 2 +- test/go_vet/vet.go | 53 --------- vet.sh | 4 - .../client/bootstrap/bootstrap_test.go | 2 - 50 files changed, 24 insertions(+), 431 deletions(-) delete mode 100644 credentials/go12.go delete mode 100644 credentials/internal/syscallconn_appengine.go delete mode 100755 install_gae.sh delete mode 100644 internal/credentials/gobefore110.go rename internal/credentials/{go110.go => spiffe.go} (99%) rename internal/credentials/{go110_test.go => spiffe_test.go} (99%) delete mode 100644 internal/profiling/buffer/buffer_appengine.go rename security/advancedtls/{sni_110.go => sni.go} (98%) delete mode 100644 security/advancedtls/sni_before_110.go delete mode 100644 security/advancedtls/sni_test_before_110.go rename security/advancedtls/{sni_test_110.go => sni_test_disabled.go} (99%) delete mode 100644 test/go_vet/vet.go diff --git a/.travis.yml b/.travis.yml index 0e24e59f0567..00287d666a5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ matrix: env: GO111MODULE=on - go: 1.12.x env: GO111MODULE=on - - go: 1.9.x - env: GAE=1 go_import_path: google.golang.org/grpc @@ -30,13 +28,11 @@ before_install: install: - try3() { eval "$*" || eval "$*" || eval "$*"; } - try3 'if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi' - - if [[ -n "${GAE}" ]]; then source ./install_gae.sh; make testappenginedeps; fi - if [[ -n "${VET}" ]]; then ./vet.sh -install; fi script: - set -e - if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; make testsubmodule; exit 0; fi - if [[ -n "${VET}" ]]; then ./vet.sh; fi - - if [[ -n "${GAE}" ]]; then make testappengine; exit 0; fi - if [[ -n "${RACE}" ]]; then make testrace; exit 0; fi - make test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f1567e2f95e..cd03f8c76888 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,5 @@ How to get your contributions merged smoothly and quickly. - `make vet` to catch vet errors - `make test` to run the tests - `make testrace` to run tests in race mode - - optional `make testappengine` to run tests with appengine - Exceptions to the rules can be made if there's a compelling reason for doing so. diff --git a/Makefile b/Makefile index 410f7d56d4c2..bd892e592490 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,6 @@ test: testdeps testsubmodule: testdeps cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/... -testappengine: testappenginedeps - goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/... - -testappenginedeps: - goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/... - testdeps: go get -d -v -t google.golang.org/grpc/... @@ -53,8 +47,6 @@ vetdeps: deps \ proto \ test \ - testappengine \ - testappenginedeps \ testdeps \ testrace \ updatedeps \ diff --git a/balancer/rls/internal/balancer.go b/balancer/rls/internal/balancer.go index aeb509aa894b..7af97b76faf1 100644 --- a/balancer/rls/internal/balancer.go +++ b/balancer/rls/internal/balancer.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/balancer_test.go b/balancer/rls/internal/balancer_test.go index 9df769c2a8c3..973f5e0cd608 100644 --- a/balancer/rls/internal/balancer_test.go +++ b/balancer/rls/internal/balancer_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/builder.go b/balancer/rls/internal/builder.go index c38babff4d3d..7c29caef4047 100644 --- a/balancer/rls/internal/builder.go +++ b/balancer/rls/internal/builder.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/client_test.go b/balancer/rls/internal/client_test.go index 1a1a75d1be98..a45850dce11e 100644 --- a/balancer/rls/internal/client_test.go +++ b/balancer/rls/internal/client_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/config.go b/balancer/rls/internal/config.go index 0a8d2d91fa82..94ed3c5ee70b 100644 --- a/balancer/rls/internal/config.go +++ b/balancer/rls/internal/config.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/config_test.go b/balancer/rls/internal/config_test.go index 9200a29d8a3c..fa22e15a6501 100644 --- a/balancer/rls/internal/config_test.go +++ b/balancer/rls/internal/config_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/keys/builder.go b/balancer/rls/internal/keys/builder.go index abc076ab4da3..5ce5a9da508a 100644 --- a/balancer/rls/internal/keys/builder.go +++ b/balancer/rls/internal/keys/builder.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/keys/builder_test.go b/balancer/rls/internal/keys/builder_test.go index f5e03ac51dd7..a5cad29e0c93 100644 --- a/balancer/rls/internal/keys/builder_test.go +++ b/balancer/rls/internal/keys/builder_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/picker.go b/balancer/rls/internal/picker.go index 698185b1595b..ce7100536d95 100644 --- a/balancer/rls/internal/picker.go +++ b/balancer/rls/internal/picker.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/picker_test.go b/balancer/rls/internal/picker_test.go index b14a9fad340a..fc5f935d6929 100644 --- a/balancer/rls/internal/picker_test.go +++ b/balancer/rls/internal/picker_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/channelz/service/func_linux.go b/channelz/service/func_linux.go index cfa457a6a8b1..ce38a921b974 100644 --- a/channelz/service/func_linux.go +++ b/channelz/service/func_linux.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/channelz/service/func_nonlinux.go b/channelz/service/func_nonlinux.go index eb53334ed0d1..64ecea947de0 100644 --- a/channelz/service/func_nonlinux.go +++ b/channelz/service/func_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * diff --git a/channelz/service/service_sktopt_test.go b/channelz/service/service_sktopt_test.go index 1a12ed0ed3cc..e2d024f83652 100644 --- a/channelz/service/service_sktopt_test.go +++ b/channelz/service/service_sktopt_test.go @@ -1,4 +1,4 @@ -// +build linux,!appengine +// +build linux // +build 386 amd64 /* diff --git a/channelz/service/service_test.go b/channelz/service/service_test.go index e6a7d8eba3be..41f4f31a5b94 100644 --- a/channelz/service/service_test.go +++ b/channelz/service/service_test.go @@ -58,7 +58,7 @@ type protoToSocketOptFunc func([]*channelzpb.SocketOption) *channelz.SocketOptio // protoToSocketOpt is used in function socketProtoToStruct to extract socket option // data from unmarshaled proto message. -// It is only defined under linux, non-appengine environment on x86 architecture. +// It is only defined under linux environment on x86 architecture. var protoToSocketOpt protoToSocketOptFunc // emptyTime is used for detecting unset value of time.Time type. diff --git a/channelz/service/util_sktopt_386_test.go b/channelz/service/util_sktopt_386_test.go index cdc2fda4028d..d9c981271361 100644 --- a/channelz/service/util_sktopt_386_test.go +++ b/channelz/service/util_sktopt_386_test.go @@ -1,4 +1,4 @@ -// +build 386,linux,!appengine +// +build 386,linux /* * diff --git a/channelz/service/util_sktopt_amd64_test.go b/channelz/service/util_sktopt_amd64_test.go index 7ebe9c70eb68..0ff06d128330 100644 --- a/channelz/service/util_sktopt_amd64_test.go +++ b/channelz/service/util_sktopt_amd64_test.go @@ -1,4 +1,4 @@ -// +build amd64,linux,!appengine +// +build amd64,linux /* * diff --git a/credentials/go12.go b/credentials/go12.go deleted file mode 100644 index ccbf35b33125..000000000000 --- a/credentials/go12.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build go1.12 - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import "crypto/tls" - -// This init function adds cipher suite constants only defined in Go 1.12. -func init() { - cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256" - cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384" - cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256" -} diff --git a/credentials/internal/syscallconn.go b/credentials/internal/syscallconn.go index 2f4472becc7c..264c7298085a 100644 --- a/credentials/internal/syscallconn.go +++ b/credentials/internal/syscallconn.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/credentials/internal/syscallconn_appengine.go b/credentials/internal/syscallconn_appengine.go deleted file mode 100644 index d4346e9eabe6..000000000000 --- a/credentials/internal/syscallconn_appengine.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build appengine - -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package internal - -import ( - "net" -) - -// WrapSyscallConn returns newConn on appengine. -func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn { - return newConn -} diff --git a/credentials/internal/syscallconn_test.go b/credentials/internal/syscallconn_test.go index a5a7d72689e6..6700e7546853 100644 --- a/credentials/internal/syscallconn_test.go +++ b/credentials/internal/syscallconn_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/credentials/tls.go b/credentials/tls.go index 1ba6f3a6b8f8..dfc4bfe06047 100644 --- a/credentials/tls.go +++ b/credentials/tls.go @@ -241,6 +241,10 @@ var cipherSuiteLookup = map[uint16]string{ tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", + // Go 1.12 + tls.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256", + tls.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384", + tls.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256", } // cloneTLSConfig returns a shallow clone of the exported diff --git a/examples/features/xds/client/main.go b/examples/features/xds/client/main.go index 9a67aabc3764..b1daa1cae9c8 100644 --- a/examples/features/xds/client/main.go +++ b/examples/features/xds/client/main.go @@ -1,5 +1,3 @@ -// +build go1.11 - /* * * Copyright 2020 gRPC authors. diff --git a/examples/features/xds/server/main.go b/examples/features/xds/server/main.go index 512c4839711a..7e0815645e5a 100644 --- a/examples/features/xds/server/main.go +++ b/examples/features/xds/server/main.go @@ -1,5 +1,3 @@ -// +build go1.11 - /* * * Copyright 2020 gRPC authors. diff --git a/install_gae.sh b/install_gae.sh deleted file mode 100755 index 7c7bcada5044..000000000000 --- a/install_gae.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -TMP=$(mktemp -d /tmp/sdk.XXX) \ -&& curl -o $TMP.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.68.zip" \ -&& unzip -q $TMP.zip -d $TMP \ -&& export PATH="$PATH:$TMP/go_appengine" diff --git a/internal/channelz/types_linux.go b/internal/channelz/types_linux.go index 692dd6181778..1b1c4cce34a9 100644 --- a/internal/channelz/types_linux.go +++ b/internal/channelz/types_linux.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/internal/channelz/types_nonlinux.go b/internal/channelz/types_nonlinux.go index 19c2fc521dcf..501770791524 100644 --- a/internal/channelz/types_nonlinux.go +++ b/internal/channelz/types_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * @@ -37,6 +37,6 @@ type SocketOptionData struct { // Windows OS doesn't support Socket Option func (s *SocketOptionData) Getsockopt(fd uintptr) { once.Do(func() { - logger.Warning("Channelz: socket options are not supported on non-linux os and appengine.") + logger.Warning("Channelz: socket options are not supported on non-linux os.") }) } diff --git a/internal/channelz/util_linux.go b/internal/channelz/util_linux.go index fdf409d55de3..49432bebf5f4 100644 --- a/internal/channelz/util_linux.go +++ b/internal/channelz/util_linux.go @@ -1,4 +1,4 @@ -// +build linux,!appengine +// +build linux /* * diff --git a/internal/channelz/util_nonlinux.go b/internal/channelz/util_nonlinux.go index 8864a0811164..d600417fb8c2 100644 --- a/internal/channelz/util_nonlinux.go +++ b/internal/channelz/util_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * diff --git a/internal/channelz/util_test.go b/internal/channelz/util_test.go index 9efe3873924c..2621e7410d61 100644 --- a/internal/channelz/util_test.go +++ b/internal/channelz/util_test.go @@ -1,4 +1,4 @@ -// +build linux,go1.10,!appengine +// +build linux /* * diff --git a/internal/credentials/gobefore110.go b/internal/credentials/gobefore110.go deleted file mode 100644 index 743713e19f8d..000000000000 --- a/internal/credentials/gobefore110.go +++ /dev/null @@ -1,31 +0,0 @@ -// +build !go1.10 - -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import ( - "crypto/tls" - "net/url" -) - -//TODO(ZhenLian): delete this file when we remove Go 1.9 tests. -func SPIFFEIDFromState(state tls.ConnectionState) *url.URL { - return nil -} diff --git a/internal/credentials/go110.go b/internal/credentials/spiffe.go similarity index 99% rename from internal/credentials/go110.go rename to internal/credentials/spiffe.go index d55b5203626e..c86813061ef5 100644 --- a/internal/credentials/go110.go +++ b/internal/credentials/spiffe.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/internal/credentials/go110_test.go b/internal/credentials/spiffe_test.go similarity index 99% rename from internal/credentials/go110_test.go rename to internal/credentials/spiffe_test.go index 19266cced492..324874e6e396 100644 --- a/internal/credentials/go110_test.go +++ b/internal/credentials/spiffe_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/internal/profiling/buffer/buffer.go b/internal/profiling/buffer/buffer.go index 45745cd09197..f4cd4201de11 100644 --- a/internal/profiling/buffer/buffer.go +++ b/internal/profiling/buffer/buffer.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors. diff --git a/internal/profiling/buffer/buffer_appengine.go b/internal/profiling/buffer/buffer_appengine.go deleted file mode 100644 index c92599e5b9c0..000000000000 --- a/internal/profiling/buffer/buffer_appengine.go +++ /dev/null @@ -1,43 +0,0 @@ -// +build appengine - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package buffer - -// CircularBuffer is a no-op implementation for appengine builds. -// -// Appengine does not support stats because of lack of the support for unsafe -// pointers, which are necessary to efficiently store and retrieve things into -// and from a circular buffer. As a result, Push does not do anything and Drain -// returns an empty slice. -type CircularBuffer struct{} - -// NewCircularBuffer returns a no-op for appengine builds. -func NewCircularBuffer(size uint32) (*CircularBuffer, error) { - return nil, nil -} - -// Push returns a no-op for appengine builds. -func (cb *CircularBuffer) Push(x interface{}) { -} - -// Drain returns a no-op for appengine builds. -func (cb *CircularBuffer) Drain() []interface{} { - return nil -} diff --git a/internal/profiling/buffer/buffer_test.go b/internal/profiling/buffer/buffer_test.go index 86bd77d4a2e6..a7f3b61e4afa 100644 --- a/internal/profiling/buffer/buffer_test.go +++ b/internal/profiling/buffer/buffer_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors. diff --git a/internal/profiling/profiling_test.go b/internal/profiling/profiling_test.go index f20654492693..a6184a16bb4f 100644 --- a/internal/profiling/profiling_test.go +++ b/internal/profiling/profiling_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors. diff --git a/internal/syscall/syscall_linux.go b/internal/syscall/syscall_linux.go index c50468a0fc89..3743bd45afbc 100644 --- a/internal/syscall/syscall_linux.go +++ b/internal/syscall/syscall_linux.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. @@ -43,7 +41,7 @@ func GetCPUTime() int64 { return ts.Nano() } -// Rusage is an alias for syscall.Rusage under linux non-appengine environment. +// Rusage is an alias for syscall.Rusage under linux environment. type Rusage syscall.Rusage // GetRusage returns the resource usage of current process. diff --git a/internal/syscall/syscall_nonlinux.go b/internal/syscall/syscall_nonlinux.go index adae60d65188..95b713437489 100644 --- a/internal/syscall/syscall_nonlinux.go +++ b/internal/syscall/syscall_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * @@ -35,40 +35,40 @@ var logger = grpclog.Component("core") func log() { once.Do(func() { - logger.Info("CPU time info is unavailable on non-linux or appengine environment.") + logger.Info("CPU time info is unavailable on non-linux environment.") }) } // GetCPUTime returns the how much CPU time has passed since the start of this process. -// It always returns 0 under non-linux or appengine environment. +// It always returns 0 under non-linux environment. func GetCPUTime() int64 { log() return 0 } -// Rusage is an empty struct under non-linux or appengine environment. +// Rusage is an empty struct under non-linux environment. type Rusage struct{} -// GetRusage is a no-op function under non-linux or appengine environment. +// GetRusage is a no-op function under non-linux environment. func GetRusage() (rusage *Rusage) { log() return nil } // CPUTimeDiff returns the differences of user CPU time and system CPU time used -// between two Rusage structs. It a no-op function for non-linux or appengine environment. +// between two Rusage structs. It a no-op function for non-linux environment. func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { log() return 0, 0 } -// SetTCPUserTimeout is a no-op function under non-linux or appengine environments +// SetTCPUserTimeout is a no-op function under non-linux environments func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { log() return nil } -// GetTCPUserTimeout is a no-op function under non-linux or appengine environments +// GetTCPUserTimeout is a no-op function under non-linux environments // a negative return value indicates the operation is not supported func GetTCPUserTimeout(conn net.Conn) (int, error) { log() diff --git a/interop/grpclb_fallback/client.go b/interop/grpclb_fallback/client.go index ce7cc8e66cde..853c9a4353f1 100644 --- a/interop/grpclb_fallback/client.go +++ b/interop/grpclb_fallback/client.go @@ -1,6 +1,4 @@ // +build linux -// +build !appengine -// +build go1.11 /* * diff --git a/security/advancedtls/sni_110.go b/security/advancedtls/sni.go similarity index 98% rename from security/advancedtls/sni_110.go rename to security/advancedtls/sni.go index 5c9a6ae13a0f..00e551fac296 100644 --- a/security/advancedtls/sni_110.go +++ b/security/advancedtls/sni.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/security/advancedtls/sni_before_110.go b/security/advancedtls/sni_before_110.go deleted file mode 100644 index 180e3a05d494..000000000000 --- a/security/advancedtls/sni_before_110.go +++ /dev/null @@ -1,41 +0,0 @@ -// +build !go1.10 - -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package advancedtls - -import ( - "crypto/tls" - "fmt" -) - -// buildGetCertificates returns the first element of o.GetCertificates. -func buildGetCertificates(clientHello *tls.ClientHelloInfo, o *ServerOptions) (*tls.Certificate, error) { - if o.GetCertificates == nil { - return nil, fmt.Errorf("function GetCertificates must be specified") - } - certificates, err := o.GetCertificates(clientHello) - if err != nil { - return nil, err - } - if len(certificates) == 0 { - return nil, fmt.Errorf("no certificates configured") - } - return certificates[0], nil -} diff --git a/security/advancedtls/sni_test_before_110.go b/security/advancedtls/sni_test_before_110.go deleted file mode 100644 index e31e2e6ee759..000000000000 --- a/security/advancedtls/sni_test_before_110.go +++ /dev/null @@ -1,108 +0,0 @@ -// +build !go1.10 - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package advancedtls - -import ( - "crypto/tls" - "testing" - - "github.com/google/go-cmp/cmp" - "google.golang.org/grpc/security/advancedtls/testdata" -) - -// TestGetCertificatesSNI tests SNI logic for go1.9. -func TestGetCertificatesSNI(t *testing.T) { - // Load server certificates for setting the serverGetCert callback function. - serverCert1, err := tls.LoadX509KeyPair(testdata.Path("server_cert_1.pem"), testdata.Path("server_key_1.pem")) - if err != nil { - t.Fatalf("tls.LoadX509KeyPair(server_cert_1.pem, server_key_1.pem) failed: %v", err) - } - serverCert2, err := tls.LoadX509KeyPair(testdata.Path("server_cert_2.pem"), testdata.Path("server_key_2.pem")) - if err != nil { - t.Fatalf("tls.LoadX509KeyPair(server_cert_2.pem, server_key_2.pem) failed: %v", err) - } - serverCert3, err := tls.LoadX509KeyPair(testdata.Path("server_cert_3.pem"), testdata.Path("server_key_3.pem")) - if err != nil { - t.Fatalf("tls.LoadX509KeyPair(server_cert_3.pem, server_key_3.pem) failed: %v", err) - } - - tests := []struct { - desc string - serverGetCert func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) - serverName string - wantCert tls.Certificate - }{ - { - desc: "Select serverCert1", - serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { - return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil - }, - // "foo.bar.com" is the common name on server certificate server_cert_1.pem. - serverName: "foo.bar.com", - wantCert: serverCert1, - }, - { - desc: "Select serverCert2", - serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { - return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil - }, - // "foo.bar.server2.com" is the common name on server certificate server_cert_2.pem. - serverName: "foo.bar.server2.com", - wantCert: serverCert1, - }, - { - desc: "Select serverCert3", - serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { - return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil - }, - // "google.com" is one of the DNS names on server certificate server_cert_3.pem. - serverName: "google.com", - wantCert: serverCert1, - }, - } - for _, test := range tests { - test := test - t.Run(test.desc, func(t *testing.T) { - serverOptions := &ServerOptions{ - GetCertificates: test.serverGetCert, - } - serverConfig, err := serverOptions.config() - if err != nil { - t.Fatalf("serverOptions.config() failed: %v", err) - } - pointFormatUncompressed := uint8(0) - clientHello := &tls.ClientHelloInfo{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA}, - ServerName: test.serverName, - SupportedCurves: []tls.CurveID{tls.CurveP256}, - SupportedPoints: []uint8{pointFormatUncompressed}, - SupportedVersions: []uint16{tls.VersionTLS10}, - } - gotCertificate, err := serverConfig.GetCertificate(clientHello) - if err != nil { - t.Fatalf("serverConfig.GetCertificate(clientHello) failed: %v", err) - } - if !cmp.Equal(gotCertificate, test.wantCert, cmp.AllowUnexported(tls.Certificate{})) { - t.Errorf("GetCertificates() = %v, want %v", gotCertificate, test.wantCert) - } - }) - } -} diff --git a/security/advancedtls/sni_test_110.go b/security/advancedtls/sni_test_disabled.go similarity index 99% rename from security/advancedtls/sni_test_110.go rename to security/advancedtls/sni_test_disabled.go index 130ccde59050..3e9e19c11be9 100644 --- a/security/advancedtls/sni_test_110.go +++ b/security/advancedtls/sni_test_disabled.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2019 gRPC authors. diff --git a/test/channelz_linux_go110_test.go b/test/channelz_linux_go110_test.go index ede329ad6297..dea374bfc08b 100644 --- a/test/channelz_linux_go110_test.go +++ b/test/channelz_linux_go110_test.go @@ -1,4 +1,4 @@ -// +build go1.10,linux,!appengine +// +build linux /* * diff --git a/test/go_vet/vet.go b/test/go_vet/vet.go deleted file mode 100644 index 475e8d683fc3..000000000000 --- a/test/go_vet/vet.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// vet checks whether files that are supposed to be built on appengine running -// Go 1.10 or earlier import an unsupported package (e.g. "unsafe", "syscall"). -package main - -import ( - "fmt" - "go/build" - "os" -) - -func main() { - fail := false - b := build.Default - b.BuildTags = []string{"appengine", "appenginevm"} - argsWithoutProg := os.Args[1:] - for _, dir := range argsWithoutProg { - p, err := b.Import(".", dir, 0) - if _, ok := err.(*build.NoGoError); ok { - continue - } else if err != nil { - fmt.Printf("build.Import failed due to %v\n", err) - fail = true - continue - } - for _, pkg := range p.Imports { - if pkg == "syscall" || pkg == "unsafe" { - fmt.Printf("Package %s/%s importing %s package without appengine build tag is NOT ALLOWED!\n", p.Dir, p.Name, pkg) - fail = true - } - } - } - if fail { - os.Exit(1) - } -} diff --git a/vet.sh b/vet.sh index 2116d1987eef..8c14c7d3618e 100755 --- a/vet.sh +++ b/vet.sh @@ -89,10 +89,6 @@ not git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go" # - Ensure all xds proto imports are renamed to *pb or *grpc. git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' | not grep -v 'pb "\|grpc "' -# - Check imports that are illegal in appengine (until Go 1.11). -# TODO: Remove when we drop Go 1.10 support -go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go - # - gofmt, goimports, golint (with exceptions for generated code), go vet. gofmt -s -d -l . 2>&1 | fail_on_output goimports -l . 2>&1 | not grep -vE "\.pb\.go" diff --git a/xds/internal/client/bootstrap/bootstrap_test.go b/xds/internal/client/bootstrap/bootstrap_test.go index 4a825aa35d84..18c28db346be 100644 --- a/xds/internal/client/bootstrap/bootstrap_test.go +++ b/xds/internal/client/bootstrap/bootstrap_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors.