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

[main] Upgrade to latest dependencies #817

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ require (
k8s.io/apiserver v0.19.7
k8s.io/client-go v0.19.7
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009
knative.dev/eventing v0.22.1-0.20210415222903-e74573361fe6
knative.dev/eventing v0.22.1-0.20210419064100-97c0d30fa90a
knative.dev/hack v0.0.0-20210325223819-b6ab329907d3
knative.dev/pkg v0.0.0-20210412173742-b51994e3b312
knative.dev/pkg v0.0.0-20210416161310-b80a1926251c
knative.dev/reconciler-test v0.0.0-20210414181401-b0c3de288f3b
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1259,13 +1259,15 @@ k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H
k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 h1:0T5IaWHO3sJTEmCP6mUlBvMukxPKUQWqiI/YuiBNMiQ=
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
knative.dev/eventing v0.22.1-0.20210415222903-e74573361fe6 h1:QV9Mq16vtbpTZ7bIGbGvjgg8wsact3EYTxGNgZDDicA=
knative.dev/eventing v0.22.1-0.20210415222903-e74573361fe6/go.mod h1:KqUTtrLHpU6Aql7xQSL8xdhTJsR0ehv88fYAjhHQLok=
knative.dev/eventing v0.22.1-0.20210419064100-97c0d30fa90a h1:z/n1bMEbd7IFDAE2O3j5DxdXjw/cPh/bW5TIBJzAuHg=
knative.dev/eventing v0.22.1-0.20210419064100-97c0d30fa90a/go.mod h1:Q5UkkH0ZmBmHBmm0liOT7kVEhtP1WGvlMpUc6OpXwlI=
knative.dev/hack v0.0.0-20210325223819-b6ab329907d3 h1:km0Rrh0T9/wA2pivQm1hqSPVwgNgGCHC2WNn3GakZmE=
knative.dev/hack v0.0.0-20210325223819-b6ab329907d3/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack/schema v0.0.0-20210325223819-b6ab329907d3/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0=
knative.dev/pkg v0.0.0-20210412173742-b51994e3b312 h1:tE80vxKw9ENrLRe+U9BvLAcJ5UYpDc40r5hFoRFUXh0=
knative.dev/pkg v0.0.0-20210412173742-b51994e3b312/go.mod h1:V/yjYpwRpIoUCavOoF8plCw72kF7rMjWPms5v2QqxA4=
knative.dev/pkg v0.0.0-20210416161310-b80a1926251c h1:WB+7bcRo5SadPzEQx+eqC6dlRySlnfh6o5bW16UjsjY=
knative.dev/pkg v0.0.0-20210416161310-b80a1926251c/go.mod h1:V/yjYpwRpIoUCavOoF8plCw72kF7rMjWPms5v2QqxA4=
knative.dev/reconciler-test v0.0.0-20210414181401-b0c3de288f3b h1:7doQCjkEY0Zg7H5Wa5Bqt0azIL4tjlvJK6qoKRjWjFc=
knative.dev/reconciler-test v0.0.0-20210414181401-b0c3de288f3b/go.mod h1:lo1LZBzDHGKn2KXxEbZfmrmEH03RkC4uC9nBlMvwyz4=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
Expand Down
88 changes: 66 additions & 22 deletions vendor/knative.dev/pkg/test/kube_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
"strings"
"time"

"k8s.io/client-go/kubernetes"

"github.com/davecgh/go-spew/spew"
"github.com/google/go-cmp/cmp"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
k8styped "k8s.io/client-go/kubernetes/typed/core/v1"
"knative.dev/pkg/test/logging"
)
Expand All @@ -51,14 +51,20 @@ func WaitForDeploymentState(ctx context.Context, client kubernetes.Interface, na
d := client.AppsV1().Deployments(namespace)
span := logging.GetEmitableSpan(ctx, fmt.Sprintf("WaitForDeploymentState/%s/%s", name, desc))
defer span.End()

return wait.PollImmediate(interval, timeout, func() (bool, error) {
d, err := d.Get(ctx, name, metav1.GetOptions{})
var lastState *appsv1.Deployment
waitErr := wait.PollImmediate(interval, timeout, func() (bool, error) {
var err error
lastState, err = d.Get(ctx, name, metav1.GetOptions{})
if err != nil {
return true, err
}
return inState(d)
return inState(lastState)
})

if waitErr != nil {
return fmt.Errorf("deployment %q is not in desired state, got: %s: %w", name, spew.Sprint(lastState), waitErr)
}
return nil
}

// WaitForPodListState polls the status of the PodList
Expand All @@ -70,13 +76,20 @@ func WaitForPodListState(ctx context.Context, client kubernetes.Interface, inSta
span := logging.GetEmitableSpan(ctx, "WaitForPodListState/"+desc)
defer span.End()

return wait.PollImmediate(interval, podTimeout, func() (bool, error) {
p, err := p.List(ctx, metav1.ListOptions{})
var lastState *corev1.PodList
waitErr := wait.PollImmediate(interval, podTimeout, func() (bool, error) {
var err error
lastState, err = p.List(ctx, metav1.ListOptions{})
if err != nil {
return true, err
}
return inState(p)
return inState(lastState)
})

if waitErr != nil {
return fmt.Errorf("pod list is not in desired state, got: %s: %w", spew.Sprint(lastState), waitErr)
}
return nil
}

// WaitForPodState polls the status of the specified Pod
Expand All @@ -88,13 +101,20 @@ func WaitForPodState(ctx context.Context, client kubernetes.Interface, inState f
span := logging.GetEmitableSpan(ctx, "WaitForPodState/"+name)
defer span.End()

return wait.PollImmediate(interval, podTimeout, func() (bool, error) {
p, err := p.Get(ctx, name, metav1.GetOptions{})
var lastState *corev1.Pod
waitErr := wait.PollImmediate(interval, podTimeout, func() (bool, error) {
var err error
lastState, err = p.Get(ctx, name, metav1.GetOptions{})
if err != nil {
return false, err
}
return inState(p)
return inState(lastState)
})

if waitErr != nil {
return fmt.Errorf("pod %q is not in desired state, got: %s: %w", name, spew.Sprint(lastState), waitErr)
}
return nil
}

// WaitForPodDeleted waits for the given pod to disappear from the given namespace.
Expand All @@ -117,14 +137,20 @@ func WaitForServiceEndpoints(ctx context.Context, client kubernetes.Interface, s
span := logging.GetEmitableSpan(ctx, "WaitForServiceHasAtLeastOneEndpoint/"+svcName)
defer span.End()

return wait.PollImmediate(interval, podTimeout, func() (bool, error) {
endpoint, err := endpointsService.Get(ctx, svcName, metav1.GetOptions{})
var endpoints *corev1.Endpoints
waitErr := wait.PollImmediate(interval, podTimeout, func() (bool, error) {
var err error
endpoints, err = endpointsService.Get(ctx, svcName, metav1.GetOptions{})
if err != nil {
return false, err
}

return countEndpointsNum(endpoint) == numOfEndpoints, nil
return countEndpointsNum(endpoints) == numOfEndpoints, nil
})
if waitErr != nil {
return fmt.Errorf("did not reach the desired number of endpoints, got: %d: %w", countEndpointsNum(endpoints), waitErr)
}
return nil
}

func countEndpointsNum(e *corev1.Endpoints) int {
Expand Down Expand Up @@ -155,10 +181,16 @@ func GetEndpointAddresses(ctx context.Context, client kubernetes.Interface, svcN

// WaitForChangedEndpoints waits until the endpoints for the given service differ from origEndpoints.
func WaitForChangedEndpoints(ctx context.Context, client kubernetes.Interface, svcName, svcNamespace string, origEndpoints []string) error {
return wait.PollImmediate(1*time.Second, 2*time.Minute, func() (bool, error) {
newEndpoints, err := GetEndpointAddresses(ctx, client, svcName, svcNamespace)
var newEndpoints []string
waitErr := wait.PollImmediate(1*time.Second, 2*time.Minute, func() (bool, error) {
var err error
newEndpoints, err = GetEndpointAddresses(ctx, client, svcName, svcNamespace)
return !cmp.Equal(origEndpoints, newEndpoints), err
})
if waitErr != nil {
return fmt.Errorf("new endpoints are not different from the original ones, got %q: %w", newEndpoints, waitErr)
}
return nil
}

// GetConfigMap gets the configmaps for a given namespace
Expand All @@ -176,13 +208,19 @@ func DeploymentScaledToZeroFunc() func(d *appsv1.Deployment) (bool, error) {
// WaitForLogContent waits until logs for given Pod/Container include the given content.
// If the content is not present within timeout it returns error.
func WaitForLogContent(ctx context.Context, client *KubeClient, podName, containerName, namespace, content string) error {
return wait.PollImmediate(interval, logTimeout, func() (bool, error) {
logs, err := client.PodLogs(ctx, podName, containerName, namespace)
var logs []byte
waitErr := wait.PollImmediate(interval, logTimeout, func() (bool, error) {
var err error
logs, err = client.PodLogs(ctx, podName, containerName, namespace)
if err != nil {
return true, err
}
return strings.Contains(string(logs), content), nil
})
if waitErr != nil {
return fmt.Errorf("logs do not contain the desired content %q, got %q: %w", content, logs, waitErr)
}
return nil
}

// WaitForAllPodsRunning waits for all the pods to be in running state
Expand All @@ -192,14 +230,20 @@ func WaitForAllPodsRunning(ctx context.Context, client kubernetes.Interface, nam

// WaitForPodRunning waits for the given pod to be in running state
func WaitForPodRunning(ctx context.Context, client kubernetes.Interface, name string, namespace string) error {
p := client.CoreV1().Pods(namespace)
return wait.PollImmediate(interval, podTimeout, func() (bool, error) {
p, err := p.Get(ctx, name, metav1.GetOptions{})
var p *corev1.Pod
pods := client.CoreV1().Pods(namespace)
waitErr := wait.PollImmediate(interval, podTimeout, func() (bool, error) {
var err error
p, err = pods.Get(ctx, name, metav1.GetOptions{})
if err != nil {
return true, err
}
return podRunning(p), nil
})
if waitErr != nil {
return fmt.Errorf("pod %q did not reach the running state, got %+v: %w", name, p.Status.Phase, waitErr)
}
return nil
}

// podsRunning will check the status conditions of the pod list and return true all pods are Running
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ k8s.io/utils/buffer
k8s.io/utils/integer
k8s.io/utils/pointer
k8s.io/utils/trace
# knative.dev/eventing v0.22.1-0.20210415222903-e74573361fe6
# knative.dev/eventing v0.22.1-0.20210419064100-97c0d30fa90a
## explicit
knative.dev/eventing/pkg/apis/config
knative.dev/eventing/pkg/apis/duck
Expand Down Expand Up @@ -1128,7 +1128,7 @@ knative.dev/eventing/test/test_images/request-sender
# knative.dev/hack v0.0.0-20210325223819-b6ab329907d3
## explicit
knative.dev/hack
# knative.dev/pkg v0.0.0-20210412173742-b51994e3b312
# knative.dev/pkg v0.0.0-20210416161310-b80a1926251c
## explicit
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
Expand Down