Skip to content

Commit

Permalink
[master] Auto-update dependencies (#3941)
Browse files Browse the repository at this point in the history
Produced via:
  `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh`
/assign grantr matzew n3wscott
/cc grantr matzew n3wscott
  • Loading branch information
mattmoor authored Aug 31, 2020
1 parent c91c4ff commit 8523245
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 114 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ require (
k8s.io/apiserver v0.17.6
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451
knative.dev/pkg v0.0.0-20200826013506-2465d13e7242
knative.dev/test-infra v0.0.0-20200825232706-38c3cb5eb5a2
knative.dev/pkg v0.0.0-20200831094608-e9da10bc8a18
knative.dev/test-infra v0.0.0-20200828211307-9d4372c9b1c7
sigs.k8s.io/yaml v1.2.0
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1848,17 +1848,17 @@ knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaC
knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY=
knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA=
knative.dev/pkg v0.0.0-20200711004937-22502028e31a/go.mod h1:AqAJV6rYi8IGikDjJ/9ZQd9qKdkXVlesVnVjwx62YB8=
knative.dev/pkg v0.0.0-20200826013506-2465d13e7242 h1:uH1anWp6Dns2zMvsj/4svLCh+whjaW0rUD+U99lSP78=
knative.dev/pkg v0.0.0-20200826013506-2465d13e7242/go.mod h1:vOVUMtkIWK+hq1+KwlLYBSYVjz5SNIP1vMj3/5SNGZw=
knative.dev/pkg v0.0.0-20200831094608-e9da10bc8a18 h1:BJTbbN0/J0BY76tzHE6/oko4lw6GEeahMrZUfigySyc=
knative.dev/pkg v0.0.0-20200831094608-e9da10bc8a18/go.mod h1:vOVUMtkIWK+hq1+KwlLYBSYVjz5SNIP1vMj3/5SNGZw=
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE=
knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs=
knative.dev/test-infra v0.0.0-20200825022047-cb4bb218c5e5 h1:iqbpe5rccMW2r1Mu1Prw4gJ9xi7yqahmtxzckTUHBeI=
knative.dev/test-infra v0.0.0-20200825022047-cb4bb218c5e5/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
knative.dev/test-infra v0.0.0-20200825232706-38c3cb5eb5a2 h1:Va45O2eQXiIRhg8iccyK9iftcQJJAvhK7FKGieafWWE=
knative.dev/test-infra v0.0.0-20200825232706-38c3cb5eb5a2/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
knative.dev/test-infra v0.0.0-20200828211307-9d4372c9b1c7 h1:yIzao6i9Hu51SCdpyqBEnhpt7G12FqFrxHK6ZnQnu8o=
knative.dev/test-infra v0.0.0-20200828211307-9d4372c9b1c7/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
Expand Down
41 changes: 35 additions & 6 deletions vendor/knative.dev/pkg/injection/sharedmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,39 @@ func GetLeaderElectionConfig(ctx context.Context) (*leaderelection.Config, error
return leaderelection.NewConfigFromConfigMap(leaderElectionConfigMap)
}

// EnableInjectionOrDie enables Knative Injection and starts the informers.
// Both Context and Config are optional.
func EnableInjectionOrDie(ctx context.Context, cfg *rest.Config) context.Context {
if ctx == nil {
ctx = signals.NewContext()
}
if cfg == nil {
cfg = ParseAndGetConfigOrDie()
}

// Respect user provided settings, but if omitted customize the default behavior.
if cfg.QPS == 0 {
cfg.QPS = rest.DefaultQPS
}
if cfg.Burst == 0 {
cfg.Burst = rest.DefaultBurst
}
ctx = injection.WithConfig(ctx, cfg)

ctx, informers := injection.Default.SetupInformers(ctx, cfg)

// Start the injection clients and informers.
logging.FromContext(ctx).Info("Starting informers...")
go func(ctx context.Context) {
if err := controller.StartInformers(ctx.Done(), informers...); err != nil {
logging.FromContext(ctx).Fatalw("Failed to start informers", zap.Error(err))
}
<-ctx.Done()
}(ctx)

return ctx
}

// Main runs the generic main flow with a new context.
// If any of the contructed controllers are AdmissionControllers or Conversion webhooks,
// then a webhook is started to serve them.
Expand Down Expand Up @@ -190,9 +223,8 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto
if cfg.Burst == 0 {
cfg.Burst = len(ctors) * rest.DefaultBurst
}
ctx = injection.WithConfig(ctx, cfg)

ctx, informers := injection.Default.SetupInformers(ctx, cfg)
ctx = EnableInjectionOrDie(ctx, cfg)

logger, atomicLevel := SetupLoggerOrDie(ctx, component)
defer flush(logger)
Expand Down Expand Up @@ -246,10 +278,7 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto
})
}

logger.Info("Starting informers...")
if err := controller.StartInformers(ctx.Done(), informers...); err != nil {
logger.Fatalw("Failed to start informers", zap.Error(err))
}
// Wait for webhook informers to sync.
if wh != nil {
wh.InformersHaveSynced()
}
Expand Down
10 changes: 1 addition & 9 deletions vendor/knative.dev/pkg/leaderelection/chaosduck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
kubeclient "knative.dev/pkg/client/injection/kube/client"
"knative.dev/pkg/controller"
"knative.dev/pkg/injection"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/kflag"
"knative.dev/pkg/signals"
"knative.dev/pkg/system"
)

Expand Down Expand Up @@ -118,13 +115,8 @@ func quack(ctx context.Context, kc kubernetes.Interface, component string, leade
}

func main() {
ctx := signals.NewContext()
ctx := sharedmain.EnableInjectionOrDie(nil, nil)

// We don't expect informers to be set up, but we do expect the client to get attached to ctx.
ctx, informers := injection.Default.SetupInformers(ctx, sharedmain.ParseAndGetConfigOrDie())
if err := controller.StartInformers(ctx.Done(), informers...); err != nil {
log.Fatalf("Failed to start informers %v", err)
}
kc := kubeclient.Get(ctx)

// Until we are shutdown, build up an index of components and kill
Expand Down
12 changes: 12 additions & 0 deletions vendor/knative.dev/pkg/leaderelection/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ type ComponentConfig struct {
LeaseDuration time.Duration
RenewDeadline time.Duration
RetryPeriod time.Duration
// LeaseName is a function to customize the lease name given the index i.
// If not present, a name in format {Component}.{queue-name}.{i}-of-{Buckets}
// will be use.
// Autoscaler need to know the Lease names to filter out Leases which are not
// used for Autoscaler. Instead of exposing the names from leadelection package,
// we let Autoscaler to pass them in.
LeaseName func(i uint32) string `json:"-"`
// Identity is the unique string identifying a resource lock holder across
// all participants in an election. If not present, a new unique string will
// be generated to be used as identity for each BuildElector call.
// Autoscaler uses the pod IP as identity.
Identity string
}

// statefulSetID is a envconfig Decodable controller ordinal and name.
Expand Down
18 changes: 14 additions & 4 deletions vendor/knative.dev/pkg/leaderelection/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ func (b *standardBuilder) buildElector(ctx context.Context, la reconciler.Leader
queueName string, enq func(reconciler.Bucket, types.NamespacedName)) (Elector, error) {
logger := logging.FromContext(ctx)

id, err := UniqueID()
if err != nil {
return nil, err
id := b.lec.Identity
if id == "" {
uid, err := UniqueID()
if err != nil {
return nil, err
}
id = uid
}

bkts := newStandardBuckets(queueName, b.lec)
Expand Down Expand Up @@ -169,9 +173,15 @@ func (b *standardBuilder) buildElector(ctx context.Context, la reconciler.Leader
}

func newStandardBuckets(queueName string, cc ComponentConfig) []reconciler.Bucket {
ln := cc.LeaseName
if ln == nil {
ln = func(i uint32) string {
return standardBucketName(i, queueName, cc)
}
}
names := make(sets.String, cc.Buckets)
for i := uint32(0); i < cc.Buckets; i++ {
names.Insert(standardBucketName(i, queueName, cc))
names.Insert(ln(i))
}

return hash.NewBucketSet(names).Buckets()
Expand Down
4 changes: 0 additions & 4 deletions vendor/knative.dev/pkg/logging/testing/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ func TestLogger(t zaptest.TestingT) *zap.SugaredLogger {
return zaptest.NewLogger(t, opts).Sugar()
}

// ClearAll removes all the testing loggers.
// TODO(taragu) remove this after removing all ClearAll() calls from serving and eventing
func ClearAll() {}

// TestContextWithLogger returns a context with a logger to be used in tests
func TestContextWithLogger(t zaptest.TestingT) context.Context {
return logging.WithLogger(context.Background(), TestLogger(t))
Expand Down
3 changes: 3 additions & 0 deletions vendor/knative.dev/pkg/system/testing/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ import (
)

func init() {
if ns := os.Getenv(system.NamespaceEnvKey); ns != "" {
return
}
os.Setenv(system.NamespaceEnvKey, "knative-testing")
}
25 changes: 10 additions & 15 deletions vendor/knative.dev/test-infra/scripts/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,26 @@ function setup_test_cluster() {
set -o errexit
set -o pipefail

header "Test cluster setup"
kubectl get nodes

header "Setting up test cluster"

kubectl get nodes
# Set the actual project the test cluster resides in
# It will be a project assigned by Boskos if test is running on Prow,
# otherwise will be ${E2E_GCP_PROJECT_ID} set up by user.
E2E_PROJECT_ID="$(gcloud config get-value project)"
export E2E_PROJECT_ID
readonly E2E_PROJECT_ID

local k8s_user
k8s_user=$(gcloud config get-value core/account)
local k8s_cluster
k8s_cluster=$(kubectl config current-context)

is_protected_cluster "${k8s_cluster}" && \
abort "kubeconfig context set to ${k8s_cluster}, which is forbidden"

# If cluster admin role isn't set, this is a brand new cluster
# Setup the admin role and also KO_DOCKER_REPO if it is a GKE cluster
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" && "${k8s_cluster}" =~ ^gke_.* ]]; then
acquire_cluster_admin_role "${k8s_user}" "${E2E_CLUSTER_NAME}" "${E2E_GKE_CLUSTER_REGION}" "${E2E_GKE_CLUSTER_ZONE}"
# Incorporate an element of randomness to ensure that each run properly publishes images.
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${REPO_NAME}-e2e-img/${RANDOM}
fi
# Acquire cluster admin role for the current user.
acquire_cluster_admin_role "${k8s_cluster}"

# Setup KO_DOCKER_REPO if it is a GKE cluster. Incorporate an element of randomness to ensure that each run properly publishes images.
[[ "${k8s_cluster}" =~ ^gke_.* ]] && export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${REPO_NAME}-e2e-img/${RANDOM}

# Safety checks
is_protected_gcr "${KO_DOCKER_REPO}" && \
Expand All @@ -92,7 +85,7 @@ function setup_test_cluster() {
export KO_DATA_PATH="${REPO_ROOT_DIR}/.git"

# Do not run teardowns if we explicitly want to skip them.
(( ! SKIP_TEARDOWNS )) && trap teardown_test_resources EXIT
(( ! SKIP_TEARDOWNS )) && add_trap teardown_test_resources EXIT

# Handle failures ourselves, so we can dump useful info.
set +o errexit
Expand Down Expand Up @@ -130,6 +123,7 @@ function fail_test() {
SKIP_TEARDOWNS=0
SKIP_ISTIO_ADDON=0
E2E_SCRIPT=""
CLOUD_PROVIDER="gke"

# Parse flags and initialize the test cluster.
function initialize() {
Expand Down Expand Up @@ -166,6 +160,7 @@ function initialize() {
[[ $# -ge 2 ]] || abort "missing parameter after $1"
shift
case ${parameter} in
--cloud-provider) CLOUD_PROVIDER="$1" ;;
--kubetest2-flag) extra_kubetest2_flags+=("$1") ;;
--cluster-creation-flag) extra_cluster_creation_flags+=("$1") ;;
*) abort "unknown option ${parameter}" ;;
Expand All @@ -186,7 +181,7 @@ function initialize() {
readonly SKIP_TEARDOWNS

if (( ! run_tests )); then
create_gke_test_cluster extra_kubetest2_flags extra_cluster_creation_flags e2e_script_command
create_test_cluster "${CLOUD_PROVIDER}" extra_kubetest2_flags extra_cluster_creation_flags e2e_script_command
else
setup_test_cluster
fi
Expand Down
Loading

0 comments on commit 8523245

Please sign in to comment.