Skip to content

Commit

Permalink
upgrade to latest dependencies (#3245)
Browse files Browse the repository at this point in the history
bumping knative.dev/eventing 034bec9...76982bf:
  > 76982bf [release-1.10] Function CopySecretWithName for creating secrets with specific name (# 7094)
  > e9544dd [release-1.10] Upgrade to latest dependencies (# 6976)
  > a0537ac [release-1.10] Use random names in Channel tests (# 6972)
bumping knative.dev/reconciler-test 6c21623...ca17404:
  > ca17404 Add name to port (# 554)
  > f5d5aaa [release-1.10] Remove resources when terminating the environment (# 531)
  > c0a7883 [release-1.10] Remove dependency on prow (# 521)

Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation authored Jul 28, 2023
1 parent 6e2c394 commit e1b49ad
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 35 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ require (
require (
github.com/google/gofuzz v1.2.0
github.com/kedacore/keda/v2 v2.8.1
knative.dev/eventing v0.37.0
knative.dev/eventing v0.37.2
knative.dev/hack v0.0.0-20230417170854-f591fea109b3
knative.dev/pkg v0.0.0-20230418073056-dfad48eaa5d0
knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555
knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede
sigs.k8s.io/controller-runtime v0.12.3
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1524,14 +1524,14 @@ k8s.io/utils v0.0.0-20200912215256-4140de9c8800/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 h1:GfD9OzL11kvZN5iArC6oTS7RTj7oJOIfnislxYlqTj8=
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/eventing v0.37.0 h1:OtX8B9nvUSTNcbbpoNFDyeGaGU/5+aetj94i6oATpQU=
knative.dev/eventing v0.37.0/go.mod h1:62baPXiw5GPpPyV3f0GF64X7tOjc5x9cg64RAh1gjs4=
knative.dev/eventing v0.37.2 h1:izwz+ikc8S/eBlxnUX5qrWVRio7R3OJJtJnlZ3tw2OM=
knative.dev/eventing v0.37.2/go.mod h1:gLS1T97U6RCbDcDmQoDIyptJ+JntPoDnX9bhtwAG6bY=
knative.dev/hack v0.0.0-20230417170854-f591fea109b3 h1:+W4WBOq83tfGXKhtv8OB/uJeYqze3zh69GKiz1ucuqk=
knative.dev/hack v0.0.0-20230417170854-f591fea109b3/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/pkg v0.0.0-20230418073056-dfad48eaa5d0 h1:EFQcoUo8I4bc+U3y6tR1B3ONYZSHWUdAfI7Vh7dae8g=
knative.dev/pkg v0.0.0-20230418073056-dfad48eaa5d0/go.mod h1:2qWPP9Gjh9Q7ETti+WRHnBnGCSCq+6q7m3p/nmUQviE=
knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555 h1:DpYnNF7NiSKgPIh64nwSCAsr+6a48R9DhK9nE8X/+ps=
knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555/go.mod h1:vZihHUKPh+sMzzx2lHgkM2tKr+f/lZqMJ9O7Jw0DaYs=
knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede h1:m+oZ4iW4V2ILrTkkq1wxQYfyiiM5SopYedw8R1lm/iU=
knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede/go.mod h1:By7fsbkjKWbTmxwAs9lL1itxZI1otbhiEsAZmprEtvI=
pgregory.net/rapid v0.3.3 h1:jCjBsY4ln4Atz78QoBWxUEvAHaFyNDQg9+WU62aCn1U=
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
19 changes: 15 additions & 4 deletions vendor/knative.dev/eventing/pkg/utils/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ import (
// It'll either return a pointer to the new Secret or and error indicating
// why it couldn't do it.
func CopySecret(corev1Input clientcorev1.CoreV1Interface, srcNS string, srcSecretName string, tgtNS string, svcAccount string) (*corev1.Secret, error) {
return CopySecretWithName(corev1Input,
srcNS,
srcSecretName,
tgtNS,
srcSecretName, /* Use same target name as source by default */
svcAccount)
}

// CopySecretWithName will copy a secret from one namespace into another.
// Allows for specifying target secret name.
func CopySecretWithName(corev1Input clientcorev1.CoreV1Interface, srcNS, srcSecretName, tgtNS, tgtSecretName, svcAccount string) (*corev1.Secret, error) {
tgtNamespaceSvcAcct := corev1Input.ServiceAccounts(tgtNS)
srcSecrets := corev1Input.Secrets(srcNS)
tgtNamespaceSecrets := corev1Input.Secrets(tgtNS)
Expand All @@ -54,7 +65,7 @@ func CopySecret(corev1Input clientcorev1.CoreV1Interface, srcNS string, srcSecre
context.Background(),
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: srcSecretName,
Name: tgtSecretName,
},
Data: srcSecret.Data,
Type: srcSecret.Type,
Expand All @@ -72,14 +83,14 @@ func CopySecret(corev1Input clientcorev1.CoreV1Interface, srcNS string, srcSecre
}

for _, secret := range tgtSvcAccount.ImagePullSecrets {
if secret.Name == srcSecretName {
if secret.Name == tgtSecretName {
return newSecret, nil
}
}
// Prevent overwriting existing imagePullSecrets
patch := `[{"op":"add","path":"/imagePullSecrets/-","value":{"name":"` + srcSecretName + `"}}]`
patch := `[{"op":"add","path":"/imagePullSecrets/-","value":{"name":"` + tgtSecretName + `"}}]`
if len(tgtSvcAccount.ImagePullSecrets) == 0 {
patch = `[{"op":"add","path":"/imagePullSecrets","value":[{"name":"` + srcSecretName + `"}]}]`
patch = `[{"op":"add","path":"/imagePullSecrets","value":[{"name":"` + tgtSecretName + `"}]}]`
}
_, err = tgtNamespaceSvcAcct.Patch(context.Background(), svcAccount, types.JSONPatchType,
[]byte(patch), metav1.PatchOptions{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
"github.com/google/uuid"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/reconciler-test/pkg/eventshub"
"knative.dev/reconciler-test/pkg/eventshub/assert"
"knative.dev/reconciler-test/pkg/feature"
"knative.dev/reconciler-test/pkg/manifest"
"knative.dev/reconciler-test/pkg/resources/service"

"knative.dev/reconciler-test/pkg/eventshub/assert"

eventasssert "knative.dev/reconciler-test/pkg/eventshub/assert"

"knative.dev/eventing/test/rekt/resources/channel"
Expand Down Expand Up @@ -88,7 +89,7 @@ func ChannelChain(length int, createSubscriberFn func(ref *duckv1.KReference, ur
func DeadLetterSink(createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) *feature.Feature {
f := feature.NewFeature()
sink := feature.MakeRandomK8sName("sink")
failer := feature.MakeK8sNamePrefix("failer")
failer := feature.MakeRandomK8sName("failer")
cs := feature.MakeRandomK8sName("containersource")
name := feature.MakeRandomK8sName("channel")
sub := feature.MakeRandomK8sName("subscription")
Expand Down Expand Up @@ -118,7 +119,7 @@ func DeadLetterSink(createSubscriberFn func(ref *duckv1.KReference, uri string)
func DeadLetterSinkGenericChannel(createSubscriberFn func(ref *duckv1.KReference, uri string) manifest.CfgFn) *feature.Feature {
f := feature.NewFeature()
sink := feature.MakeRandomK8sName("sink")
failer := feature.MakeK8sNamePrefix("failer")
failer := feature.MakeRandomK8sName("failer")
cs := feature.MakeRandomK8sName("containersource")
name := feature.MakeRandomK8sName("channel")
sub := feature.MakeRandomK8sName("subscription")
Expand Down
5 changes: 5 additions & 0 deletions vendor/knative.dev/reconciler-test/pkg/environment/magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ func (mr *MagicEnvironment) Finish() {
var result milestone.Result = unknownResult{}
if mr.managedT != nil {
result = mr.managedT
if !result.Failed() {
if err := feature.DeleteResources(mr.c, mr.managedT, mr.References()); err != nil {
mr.managedT.Fatal(err)
}
}
}
if mr.milestones != nil {
mr.milestones.Finished(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ spec:
app: eventshub-{{ .name }}
ports:
- protocol: TCP
name: http
port: 80
targetPort: 8080
32 changes: 14 additions & 18 deletions vendor/knative.dev/reconciler-test/pkg/feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,21 @@ func (f *Feature) References() []corev1.ObjectReference {
// DeleteResources delete all known resources to the Feature registered
// via `Reference`.
//
// It doesn't fail when a referenced resource couldn't be deleted.
// Use References to get the undeleted resources.
//
// Expected to be used as a StepFn.
func (f *Feature) DeleteResources(ctx context.Context, t T) {
if err := DeleteResources(ctx, t, f.References()); err != nil {
t.Fatal(err)
}
}

func DeleteResources(ctx context.Context, t T, refs []corev1.ObjectReference) error {
dc := dynamicclient.Get(ctx)
for _, ref := range f.References() {

for _, ref := range refs {

gv, err := schema.ParseGroupVersion(ref.APIVersion)
if err != nil {
t.Fatalf("Could not parse GroupVersion for %+v", ref.APIVersion)
return fmt.Errorf("could not parse GroupVersion for %+v", ref.APIVersion)
}

resource := apis.KindToResource(gv.WithKind(ref.Kind))
Expand All @@ -223,15 +227,11 @@ func (f *Feature) DeleteResources(ctx context.Context, t T) {
}
}

// refFailedDeletion keeps the failed to delete resources.
var refFailedDeletion []corev1.ObjectReference

err := wait.Poll(time.Second, 4*time.Minute, func() (bool, error) {
refFailedDeletion = nil // Reset failed deletion.
for _, ref := range f.References() {
for _, ref := range refs {
gv, err := schema.ParseGroupVersion(ref.APIVersion)
if err != nil {
t.Fatalf("Could not parse GroupVersion for %+v", ref.APIVersion)
return false, fmt.Errorf("could not parse GroupVersion for %+v", ref.APIVersion)
}

resource := apis.KindToResource(gv.WithKind(ref.Kind))
Expand All @@ -244,7 +244,7 @@ func (f *Feature) DeleteResources(ctx context.Context, t T) {
continue
}
if err != nil {
refFailedDeletion = append(refFailedDeletion, ref)
LogReferences(ref)(ctx, t)
return false, fmt.Errorf("failed to get resource %+v %s/%s: %w", resource, ref.Namespace, ref.Name, err)
}

Expand All @@ -255,14 +255,10 @@ func (f *Feature) DeleteResources(ctx context.Context, t T) {
return true, nil
})
if err != nil {
LogReferences(refFailedDeletion...)(ctx, t)
t.Fatalf("failed to wait for resources to be deleted: %v", err)
return fmt.Errorf("failed to wait for resources to be deleted: %v", err)
}

f.refsMu.Lock()
defer f.refsMu.Unlock()

f.refs = refFailedDeletion
return nil
}

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
Expand All @@ -29,8 +30,8 @@ import (
kubeclient "knative.dev/pkg/client/injection/kube/client"
"knative.dev/pkg/logging"
"knative.dev/pkg/test/helpers"
"knative.dev/pkg/test/prow"
"knative.dev/pkg/test/zipkin"

"knative.dev/reconciler-test/pkg/feature"
)

Expand Down Expand Up @@ -111,7 +112,7 @@ func (e tracingEmitter) getTracesForNamespace(ns string) ([]byte, error) {
}

func (e tracingEmitter) exportTrace(trace []byte, fileName string) error {
tracesDir := filepath.Join(prow.GetLocalArtifactsDir(), "traces")
tracesDir := filepath.Join(getLocalArtifactsDir(), "traces")
if err := helpers.CreateDir(tracesDir); err != nil {
return fmt.Errorf("error creating directory %q: %w", tracesDir, err)
}
Expand All @@ -129,6 +130,17 @@ func (e tracingEmitter) exportTrace(trace []byte, fileName string) error {
return nil
}

// getLocalArtifactsDir gets the artifacts directory where prow looks for artifacts.
// By default, it will look at the env var ARTIFACTS.
func getLocalArtifactsDir() string {
dir := os.Getenv("ARTIFACTS")
if dir == "" {
dir = "artifacts"
log.Printf("Env variable ARTIFACTS not set. Using %s instead.", dir)
}
return dir
}

// findTrace fetches tracing endpoint and retrieves Zipkin traces matching the annotation query.
func (e tracingEmitter) findTrace(annotationQuery string) ([]byte, error) {
trace := []byte("{}")
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ k8s.io/utils/net
k8s.io/utils/pointer
k8s.io/utils/strings/slices
k8s.io/utils/trace
# knative.dev/eventing v0.37.0
# knative.dev/eventing v0.37.2
## explicit; go 1.19
knative.dev/eventing/cmd/event_display
knative.dev/eventing/cmd/heartbeats
Expand Down Expand Up @@ -1494,7 +1494,7 @@ knative.dev/pkg/webhook/json
knative.dev/pkg/webhook/resourcesemantics
knative.dev/pkg/webhook/resourcesemantics/defaulting
knative.dev/pkg/webhook/resourcesemantics/validation
# knative.dev/reconciler-test v0.0.0-20230420091239-6c21623d2555
# knative.dev/reconciler-test v0.0.0-20230728072509-ca174046aede
## explicit; go 1.18
knative.dev/reconciler-test/cmd/eventshub
knative.dev/reconciler-test/pkg/environment
Expand Down

0 comments on commit e1b49ad

Please sign in to comment.