Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: grpc/grpc-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.41.0
Choose a base ref
...
head repository: grpc/grpc-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.41.1
Choose a head ref
  • 6 commits
  • 9 files changed
  • 4 contributors

Commits on Sep 24, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    davidboden David Boden
    Copy the full SHA
    13302c5 View commit details

Commits on Oct 4, 2021

  1. Copy the full SHA
    02bba03 View commit details

Commits on Oct 14, 2021

  1. Copy the full SHA
    8e3899e View commit details

Commits on Nov 16, 2021

  1. Copy the full SHA
    afe6556 View commit details

Commits on Dec 1, 2021

  1. backport PRs to v1.41.x (#5018)

    - creds/google: add NewDefaultCredentialsWithOptions() to support custom per-RPC creds (#4767, #4830)
    - pickfirst: check b.sc before calling Connect (#4971)
    menghanl authored Dec 1, 2021
    Copy the full SHA
    b42316f View commit details
  2. Copy the full SHA
    78ebe1c View commit details
68 changes: 37 additions & 31 deletions credentials/google/google.go
Original file line number Diff line number Diff line change
@@ -35,57 +35,63 @@ const tokenRequestTimeout = 30 * time.Second

var logger = grpclog.Component("credentials")

// NewDefaultCredentials returns a credentials bundle that is configured to work
// with google services.
// DefaultCredentialsOptions constructs options to build DefaultCredentials.
type DefaultCredentialsOptions struct {
// PerRPCCreds is a per RPC credentials that is passed to a bundle.
PerRPCCreds credentials.PerRPCCredentials
}

// NewDefaultCredentialsWithOptions returns a credentials bundle that is
// configured to work with google services.
//
// This API is experimental.
func NewDefaultCredentials() credentials.Bundle {
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
ctx, cancel := context.WithTimeout(context.Background(), tokenRequestTimeout)
defer cancel()
perRPCCreds, err := oauth.NewApplicationDefault(ctx)
if err != nil {
logger.Warningf("google default creds: failed to create application oauth: %v", err)
}
return perRPCCreds
},
func NewDefaultCredentialsWithOptions(opts DefaultCredentialsOptions) credentials.Bundle {
if opts.PerRPCCreds == nil {
ctx, cancel := context.WithTimeout(context.Background(), tokenRequestTimeout)
defer cancel()
var err error
opts.PerRPCCreds, err = oauth.NewApplicationDefault(ctx)
if err != nil {
logger.Warningf("NewDefaultCredentialsWithOptions: failed to create application oauth: %v", err)
}
}
c := &creds{opts: opts}
bundle, err := c.NewWithMode(internal.CredsBundleModeFallback)
if err != nil {
logger.Warningf("google default creds: failed to create new creds: %v", err)
logger.Warningf("NewDefaultCredentialsWithOptions: failed to create new creds: %v", err)
}
return bundle
}

// NewDefaultCredentials returns a credentials bundle that is configured to work
// with google services.
//
// This API is experimental.
func NewDefaultCredentials() credentials.Bundle {
return NewDefaultCredentialsWithOptions(DefaultCredentialsOptions{})
}

// NewComputeEngineCredentials returns a credentials bundle that is configured to work
// with google services. This API must only be used when running on GCE. Authentication configured
// by this API represents the GCE VM's default service account.
//
// This API is experimental.
func NewComputeEngineCredentials() credentials.Bundle {
c := &creds{
newPerRPCCreds: func() credentials.PerRPCCredentials {
return oauth.NewComputeEngine()
},
}
bundle, err := c.NewWithMode(internal.CredsBundleModeFallback)
if err != nil {
logger.Warningf("compute engine creds: failed to create new creds: %v", err)
}
return bundle
return NewDefaultCredentialsWithOptions(DefaultCredentialsOptions{
PerRPCCreds: oauth.NewComputeEngine(),
})
}

// creds implements credentials.Bundle.
type creds struct {
opts DefaultCredentialsOptions

// Supported modes are defined in internal/internal.go.
mode string
// The transport credentials associated with this bundle.
// The active transport credentials associated with this bundle.
transportCreds credentials.TransportCredentials
// The per RPC credentials associated with this bundle.
// The active per RPC credentials associated with this bundle.
perRPCCreds credentials.PerRPCCredentials
// Creates new per RPC credentials
newPerRPCCreds func() credentials.PerRPCCredentials
}

func (c *creds) TransportCredentials() credentials.TransportCredentials {
@@ -112,8 +118,8 @@ var (
// existing Bundle may cause races.
func (c *creds) NewWithMode(mode string) (credentials.Bundle, error) {
newCreds := &creds{
mode: mode,
newPerRPCCreds: c.newPerRPCCreds,
opts: c.opts,
mode: mode,
}

// Create transport credentials.
@@ -129,7 +135,7 @@ func (c *creds) NewWithMode(mode string) (credentials.Bundle, error) {
}

if mode == internal.CredsBundleModeFallback || mode == internal.CredsBundleModeBackendFromBalancer {
newCreds.perRPCCreds = newCreds.newPerRPCCreds()
newCreds.perRPCCreds = newCreds.opts.PerRPCCreds
}

return newCreds, nil
5 changes: 3 additions & 2 deletions credentials/google/google_test.go
Original file line number Diff line number Diff line change
@@ -76,8 +76,9 @@ func overrideNewCredsFuncs() func() {
func TestClientHandshakeBasedOnClusterName(t *testing.T) {
defer overrideNewCredsFuncs()()
for bundleTyp, tc := range map[string]credentials.Bundle{
"defaultCreds": NewDefaultCredentials(),
"computeCreds": NewComputeEngineCredentials(),
"defaultCredsWithOptions": NewDefaultCredentialsWithOptions(DefaultCredentialsOptions{}),
"defaultCreds": NewDefaultCredentials(),
"computeCreds": NewComputeEngineCredentials(),
} {
tests := []struct {
name string
2 changes: 1 addition & 1 deletion pickfirst.go
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ func (b *pickfirstBalancer) Close() {
}

func (b *pickfirstBalancer) ExitIdle() {
if b.state == connectivity.Idle {
if b.sc != nil && b.state == connectivity.Idle {
b.sc.Connect()
}
}
2 changes: 1 addition & 1 deletion test/kokoro/xds_k8s.cfg → test/kokoro/psm-security.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Config file for internal CI

# Location of the continuous shell script in repository.
build_file: "grpc-go/test/kokoro/xds_k8s.sh"
build_file: "grpc-go/test/kokoro/psm-security.sh"
timeout_mins: 120

action {
13 changes: 8 additions & 5 deletions test/kokoro/xds_k8s.sh → test/kokoro/psm-security.sh
Original file line number Diff line number Diff line change
@@ -17,9 +17,7 @@ set -eo pipefail

# Constants
readonly GITHUB_REPOSITORY_NAME="grpc-go"
# GKE Cluster
readonly GKE_CLUSTER_NAME="interop-test-psm-sec-v2-us-central1-a"
readonly GKE_CLUSTER_ZONE="us-central1-a"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/grpc/${TEST_DRIVER_BRANCH:-master}/tools/internal_ci/linux/grpc_xds_k8s_install_test_driver.sh"
## xDS test server/client Docker images
readonly SERVER_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/go-server"
readonly CLIENT_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/go-client"
@@ -134,8 +132,13 @@ run_test() {
main() {
local script_dir
script_dir="$(dirname "$0")"
# shellcheck source=test/kokoro/xds_k8s_install_test_driver.sh
source "${script_dir}/xds_k8s_install_test_driver.sh"

# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"

activate_gke_cluster GKE_CLUSTER_PSM_SECURITY

set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
6 changes: 6 additions & 0 deletions test/kokoro/xds.sh
Original file line number Diff line number Diff line change
@@ -3,6 +3,12 @@
set -exu -o pipefail
[[ -f /VERSION ]] && cat /VERSION


echo "Remove the expired letsencrypt.org cert and update the CA certificates"
sudo apt-get install -y ca-certificates
sudo rm /usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt
sudo update-ca-certificates

cd github

export GOPATH="${HOME}/gopath"
380 changes: 0 additions & 380 deletions test/kokoro/xds_k8s_install_test_driver.sh

This file was deleted.

13 changes: 8 additions & 5 deletions test/kokoro/xds_url_map.sh
Original file line number Diff line number Diff line change
@@ -17,9 +17,7 @@ set -eo pipefail

# Constants
readonly GITHUB_REPOSITORY_NAME="grpc-go"
# GKE Cluster
readonly GKE_CLUSTER_NAME="interop-test-psm-basic"
readonly GKE_CLUSTER_ZONE="us-central1-c"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/grpc/${TEST_DRIVER_BRANCH:-master}/tools/internal_ci/linux/grpc_xds_k8s_install_test_driver.sh"
## xDS test client Docker images
readonly CLIENT_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/go-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
@@ -118,8 +116,13 @@ run_test() {
main() {
local script_dir
script_dir="$(dirname "$0")"
# shellcheck source=test/kokoro/xds_k8s_install_test_driver.sh
source "${script_dir}/xds_k8s_install_test_driver.sh"

# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"

activate_gke_cluster GKE_CLUSTER_PSM_BASIC

set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -19,4 +19,4 @@
package grpc

// Version is the current grpc version.
const Version = "1.41.0"
const Version = "1.41.1"