Skip to content

Commit

Permalink
[release-0.22] Upgrade to latest dependencies (#406)
Browse files Browse the repository at this point in the history
* upgrade to latest dependencies

bumping knative.dev/eventing 8f35d42...6aa0b41:
  > 6aa0b41 Use new label for defining a cluster-local Knative Service (# 5403)
  > 6d63984 Add podAntiAffinity labels to remaining HA control plane pods (# 5414)
  > 0d8411e Drop --strict flag on ko (# 5513)
  > 7c0b477 fix(PingSource): remove annotation based conversion logic (# 5234)
bumping knative.dev/pkg 952fdd9...983897f:
  > 983897f [release-0.22] allow unknown metadata fields (# 2257)
  > 6ea2c43 Drop redundant pointers and decoders (# 2262)

Signed-off-by: Knative Automation <[email protected]>

* bump kind and image versions

* bump ko for e2e

* pin topology operator to v0.7.0
newer versions drop v1alpha APIs

Co-authored-by: dprotaso <[email protected]>
  • Loading branch information
knative-automation and dprotaso authored Sep 8, 2021
1 parent 523393f commit 8fc5955
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 180 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/kind-conformance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
fail-fast: false # Keep running if one leg fails.
matrix:
k8s-version:
- v1.18.8
- v1.19.1
- v1.20.0
- v1.18.19
- v1.19.11
- v1.20.7

eventing-version:
- v0.21.0
Expand All @@ -37,15 +37,15 @@ jobs:
# This is attempting to make it a bit clearer what's being tested.
# See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.9.0
include:
- k8s-version: v1.18.8
kind-version: v0.9.0
kind-image-sha: sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
- k8s-version: v1.19.1
kind-version: v0.9.0
kind-image-sha: sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600
- k8s-version: v1.20.0
kind-version: v0.9.0
kind-image-sha: sha256:b40ecf8bcb188f6a0d0f5d406089c48588b75edc112c6f635d26be5de1c89040
- k8s-version: v1.18.19
kind-version: v0.11.1
kind-image-sha: sha256:7af1492e19b3192a79f606e43c35fb741e520d195f96399284515f077b3b622c
- k8s-version: v1.19.11
kind-version: v0.11.1
kind-image-sha: sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729
- k8s-version: v1.20.7
kind-version: v0.11.0
kind-image-sha: sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9
env:
GOPATH: ${{ github.workspace }}
KO_DOCKER_REPO: kind.local
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Install Dependencies
run: |
curl -L https://github.com/google/ko/releases/download/v0.7.0/ko_0.7.0_Linux_x86_64.tar.gz | tar xzf - ko
curl -L https://github.com/google/ko/releases/download/v0.8.3/ko_0.8.3_Linux_x86_64.tar.gz | tar xzf - ko
chmod +x ./ko
sudo mv ko /usr/local/bin
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
run: |
set -x
kubectl apply -f https://github.com/rabbitmq/messaging-topology-operator/releases/latest/download/messaging-topology-operator-with-certmanager.yaml
kubectl apply -f https://github.com/rabbitmq/messaging-topology-operator/releases/download/v0.7.0/messaging-topology-operator-with-certmanager.yaml
- name: Install Knative Eventing
run: |
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/kind-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
fail-fast: false # Keep running if one leg fails.
matrix:
k8s-version:
- v1.18.8
- v1.19.1
- v1.20.0
- v1.18.19
- v1.19.11
- v1.20.7

eventing-version:
- v0.19.0
Expand All @@ -35,15 +35,15 @@ jobs:
# This is attempting to make it a bit clearer what's being tested.
# See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.9.0
include:
- k8s-version: v1.18.8
kind-version: v0.9.0
kind-image-sha: sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
- k8s-version: v1.19.1
kind-version: v0.9.0
kind-image-sha: sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600
- k8s-version: v1.20.0
kind-version: v0.9.0
kind-image-sha: sha256:b40ecf8bcb188f6a0d0f5d406089c48588b75edc112c6f635d26be5de1c89040
- k8s-version: v1.18.19
kind-version: v0.11.1
kind-image-sha: sha256:7af1492e19b3192a79f606e43c35fb741e520d195f96399284515f077b3b622c
- k8s-version: v1.19.11
kind-version: v0.11.1
kind-image-sha: sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729
- k8s-version: v1.20.7
kind-version: v0.11.0
kind-image-sha: sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9
env:
GOPATH: ${{ github.workspace }}
KO_DOCKER_REPO: kind.local
Expand All @@ -68,7 +68,7 @@ jobs:

- name: Install Dependencies
run: |
curl -L https://github.com/google/ko/releases/download/v0.7.0/ko_0.7.0_Linux_x86_64.tar.gz | tar xzf - ko
curl -L https://github.com/google/ko/releases/download/v0.8.3/ko_0.8.3_Linux_x86_64.tar.gz | tar xzf - ko
chmod +x ./ko
sudo mv ko /usr/local/bin
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
run: |
set -x
kubectl apply -f https://github.com/rabbitmq/messaging-topology-operator/releases/latest/download/messaging-topology-operator-with-certmanager.yaml
kubectl apply -f https://github.com/rabbitmq/messaging-topology-operator/releases/download/v0.7.0/messaging-topology-operator-with-certmanager.yaml
- name: Install Knative Eventing
run: |
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ require (
k8s.io/client-go v0.20.5
k8s.io/code-generator v0.20.5
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
knative.dev/eventing v0.22.0
knative.dev/eventing v0.22.2
knative.dev/hack v0.0.0-20210325223819-b6ab329907d3
knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0
knative.dev/pkg v0.0.0-20210902173607-983897f9e37f
knative.dev/reconciler-test v0.0.0-20210331073522-b09f3669345a
)

Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1435,15 +1435,16 @@ k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/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.0 h1:esDaddfSmiVhLKDnUCVVunSdNeHklVEz0fsqs3NupuQ=
knative.dev/eventing v0.22.0/go.mod h1:LOG7bh0eZQkbYANcnORwke6Yy6aUu62o8GeByaOFfRQ=
knative.dev/eventing v0.22.2 h1:O/qCAnMXJ4oL0Rs/aiXIfY68upl7NRkwD9RoUpKi/kU=
knative.dev/eventing v0.22.2/go.mod h1:LOG7bh0eZQkbYANcnORwke6Yy6aUu62o8GeByaOFfRQ=
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-20210329065222-9d92ea16c0d3/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg=
knative.dev/pkg v0.0.0-20210331062321-6317ec6066f4/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg=
knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 h1:z05hcB4br0qz7JdwIoUSTXLTF+7ThuJ+R6NFfXd1Y4Q=
knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg=
knative.dev/pkg v0.0.0-20210902173607-983897f9e37f h1:5XjG0xQQYN/Bw+7vUhLENcDOBQPCVns6v3vJcJ1SXZM=
knative.dev/pkg v0.0.0-20210902173607-983897f9e37f/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg=
knative.dev/reconciler-test v0.0.0-20210329214021-2a67496462a4/go.mod h1:qLfJMHc0i9ENTSet/SUp/FcQm4QVfNTX8ZC//aVQN0M=
knative.dev/reconciler-test v0.0.0-20210331073522-b09f3669345a h1:lT3F7ppaQfBxvJvD++B1s6nGk3x/scYN404+qPLMKm4=
knative.dev/reconciler-test v0.0.0-20210331073522-b09f3669345a/go.mod h1:/+nBvBQ+/CJxGjpPzgKPLQc0feF9dzhcVFfhcTDtNyo=
Expand Down
131 changes: 15 additions & 116 deletions vendor/knative.dev/eventing/pkg/apis/sources/v1beta1/ping_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,13 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"

cloudevents "github.com/cloudevents/sdk-go/v2"

"knative.dev/eventing/pkg/apis/sources/v1beta2"
"knative.dev/pkg/apis"
)

const (
// V1B1SpecAnnotationKey is used to indicate that a v1beta2 object is converted from v1beta1
// also it can be used to downgrade such object to v1beta1
V1B1SpecAnnotationKey = "pingsources.sources.knative.dev/v1beta1-spec"

// V1B2SpecAnnotationKey is used to indicate that a v1beta1 object is converted from v1beta2
// also it can be used to convert the v1beta1 object back to v1beta2, considering that v1beta2 introduces more features.
V1B2SpecAnnotationKey = "pingsources.sources.knative.dev/v1beta2-spec"
)

type message struct {
Body string `json:"body"`
}
Expand All @@ -61,35 +50,21 @@ func (source *PingSource) ConvertTo(ctx context.Context, obj apis.Convertible) e
sink.Status = v1beta2.PingSourceStatus{
SourceStatus: source.Status.SourceStatus,
}

// deep copy annotations to avoid mutation on source.ObjectMeta.Annotations
annotations := make(map[string]string)
for key, value := range source.GetAnnotations() {
annotations[key] = value
sink.Spec = v1beta2.PingSourceSpec{
SourceSpec: source.Spec.SourceSpec,
Schedule: source.Spec.Schedule,
Timezone: source.Spec.Timezone,
}

if isCreatedViaV1Beta2API(source) {
// try to unmarshal v1beta2.PingSource.Spec from V1B2SpecAnnotationKey
// key existence and json marshal error already checked in isCreatedViaV1Beta2API
v1beta2Spec := annotations[V1B2SpecAnnotationKey]
_ = json.Unmarshal([]byte(v1beta2Spec), &sink.Spec)
} else {
var err error
if sink.Spec, err = toV1Beta2Spec(&source.Spec); err != nil {
return err
}
// marshal and store v1beta1.PingSource.Spec into V1B1SpecAnnotationKey
// this is to help if we need to convert back to v1beta1.PingSource
v1beta1Spec, err := json.Marshal(source.Spec)
if source.Spec.JsonData != "" {
msg, err := makeMessage(source.Spec.JsonData)
if err != nil {
return fmt.Errorf("error marshalling source.Spec: %v, err: %v", source.Spec, err)
return fmt.Errorf("error converting jsonData to a higher version: %v", err)
}
annotations[V1B1SpecAnnotationKey] = string(v1beta1Spec)
sink.Spec.ContentType = cloudevents.ApplicationJSON
sink.Spec.Data = string(msg)
}

// we don't need this annotation in a v1beta2.PingSource object
delete(annotations, V1B2SpecAnnotationKey)
sink.SetAnnotations(annotations)
return nil
default:
return apis.ConvertToViaProxy(ctx, source, &v1beta2.PingSource{}, sink)
Expand All @@ -106,94 +81,18 @@ func (sink *PingSource) ConvertFrom(ctx context.Context, obj apis.Convertible) e
SourceStatus: source.Status.SourceStatus,
}

// deep copy annotations to avoid mutation on source.ObjectMeta.Annotations
annotations := make(map[string]string)
for key, value := range source.GetAnnotations() {
annotations[key] = value
}

if isV1Beta1AnnotationConsistentWithV1Beta2Spec(source) {
// errors already handled in isV1Beta1AnnotationConsistentWithV1Beta2Spec
v1beta1Spec := annotations[V1B1SpecAnnotationKey]
_ = json.Unmarshal([]byte(v1beta1Spec), &sink.Spec)
sink.Spec = PingSourceSpec{
SourceSpec: source.Spec.SourceSpec,
Schedule: source.Spec.Schedule,
Timezone: source.Spec.Timezone,
}

// marshal and store v1beta2.PingSource.Spec into V1B2SpecAnnotationKey
// this is to help if we need to convert back to v1beta2.PingSource
v1beta2Configuration, err := json.Marshal(source.Spec)
if err != nil {
return fmt.Errorf("error marshalling source.Spec: %v, err: %v", source.Spec, err)
if source.Spec.ContentType == cloudevents.ApplicationJSON {
sink.Spec.JsonData = source.Spec.Data
}
annotations[V1B2SpecAnnotationKey] = string(v1beta2Configuration)
// we don't need this annotation in a v1beta1.PingSource object
delete(annotations, V1B1SpecAnnotationKey)
sink.SetAnnotations(annotations)

return nil
default:
return apis.ConvertFromViaProxy(ctx, source, &v1beta2.PingSource{}, sink)
}
}

func toV1Beta2Spec(srcSpec *PingSourceSpec) (v1beta2.PingSourceSpec, error) {
targetSpec := v1beta2.PingSourceSpec{
SourceSpec: srcSpec.SourceSpec,
Schedule: srcSpec.Schedule,
Timezone: srcSpec.Timezone,
}

if srcSpec.JsonData != "" {
msg, err := makeMessage(srcSpec.JsonData)
if err != nil {
return targetSpec, fmt.Errorf("error converting jsonData to a higher version: %v", err)
}
targetSpec.ContentType = cloudevents.ApplicationJSON
targetSpec.Data = string(msg)
}

return targetSpec, nil
}

// checks if a v1beta1.PingSource is originally created in v1beta2, it must meet both of the following criteria:
//
// 1. V1B2SpecAnnotationKey annotation must exist and can be unmarshalled to v1beta2.PingSourceSpec, it indicates that it's converted from v1beta2 -> v1beta1.
// 2. Spec.Sink must be {Ref: nil, URI: nil}, as we don't set these values during conversion from v1beta2 -> v1beta1, see PingSource.ConvertFrom;
func isCreatedViaV1Beta2API(source *PingSource) bool {
v1beta2Annotation, ok := source.GetAnnotations()[V1B2SpecAnnotationKey]
if !ok {
return false
}

v1beta2Spec := &v1beta2.PingSourceSpec{}
if err := json.Unmarshal([]byte(v1beta2Annotation), v1beta2Spec); err != nil {
return false
}

return source.Spec.Sink.Ref == nil && source.Spec.Sink.URI == nil
}

// for a v1beta2.PingSource, checks if its V1B1SpecAnnotationKey is consistent with its spec.
// returns false if one of the following satisfies:
//
// 1. V1B1SpecAnnotationKey does not exist.
// 2. V1B1SpecAnnotationKey exists, but we cannot unmarshal it to v1beta1.PingSourceSpec.
// 3. V1B1SpecAnnotationKey exists, but if we unmarshal it to v1beta1.PingSourceSpec and convert it to v1beta2,
// the converted v1beta2.PingSourceSpec is not the same as source.Spec.
func isV1Beta1AnnotationConsistentWithV1Beta2Spec(source *v1beta2.PingSource) bool {
v1beta1Annotation, ok := source.GetAnnotations()[V1B1SpecAnnotationKey]
if !ok {
return false
}

v1beta1Spec := &PingSourceSpec{}
if err := json.Unmarshal([]byte(v1beta1Annotation), v1beta1Spec); err != nil {
return false
}

v1beta2Spec, err := toV1Beta2Spec(v1beta1Spec)
if err != nil {
return false
}

return reflect.DeepEqual(v1beta2Spec, source.Spec)
}
4 changes: 1 addition & 3 deletions vendor/knative.dev/pkg/webhook/configmaps/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package configmaps

import (
"bytes"
"context"
"encoding/json"
"errors"
Expand Down Expand Up @@ -188,8 +187,7 @@ func (ac *reconciler) validate(ctx context.Context, req *admissionv1.AdmissionRe

var newObj corev1.ConfigMap
if len(newBytes) != 0 {
newDecoder := json.NewDecoder(bytes.NewBuffer(newBytes))
if err := newDecoder.Decode(&newObj); err != nil {
if err := json.Unmarshal(newBytes, &newObj); err != nil {
return fmt.Errorf("cannot decode incoming new object: %w", err)
}
}
Expand Down
Loading

0 comments on commit 8fc5955

Please sign in to comment.