diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..44e66646 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +generate: + ./openshift/generate.sh +.PHONY: generate + +generate-release: generate +.PHONY: generate + +e2e-tests: + ./openshift/install.sh + ./openshift/e2e-tests.sh +.PHONY: e2e-tests diff --git a/openshift/ci-operator/build-image/Dockerfile b/openshift/ci-operator/build-image/Dockerfile new file mode 100755 index 00000000..c52e7bb2 --- /dev/null +++ b/openshift/ci-operator/build-image/Dockerfile @@ -0,0 +1,23 @@ +# DO NOT EDIT! Generated Dockerfile. + +# Dockerfile to bootstrap build and test in openshift-ci +FROM registry.ci.openshift.org/openshift/release:golang-1.19 as builder + +RUN echo "[kubernetes]" >> /etc/yum.repos.d/kubernetes.repo && \ + echo "name=Kubernetes" >> /etc/yum.repos.d/kubernetes.repo && \ + echo "baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64" >> /etc/yum.repos.d/kubernetes.repo && \ + echo "enabled=1" >> /etc/yum.repos.d/kubernetes.repo && \ + echo "gpgcheck=1" >> /etc/yum.repos.d/kubernetes.repo && \ + echo "repo_gpgcheck=0" >> /etc/yum.repos.d/kubernetes.repo && \ + echo "gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg" >> /etc/yum.repos.d/kubernetes.repo + +RUN yum install -y kubectl httpd-tools + +RUN GOFLAGS='' go install github.com/mikefarah/yq/v3@latest + +# go install creates $GOPATH/.cache with root permissions, we delete it here +# to avoid permission issues with the runtime users +RUN rm -rf $GOPATH/.cache + +# Allow runtime users to add entries to /etc/passwd +RUN chmod g+rw /etc/passwd diff --git a/openshift/ci-operator/knative-images/controller/Dockerfile b/openshift/ci-operator/knative-images/controller/Dockerfile new file mode 100755 index 00000000..f4363563 --- /dev/null +++ b/openshift/ci-operator/knative-images/controller/Dockerfile @@ -0,0 +1,20 @@ +# DO NOT EDIT! Generated Dockerfile for cmd/controller. +FROM registry.ci.openshift.org/openshift/release:golang-1.19 as builder + +COPY . . + +RUN mkdir -p /var/run/ko && \ + mkdir -p cmd/controller/kodata && \ + go build -o /usr/bin/main ./cmd/controller && \ + cp -r cmd/controller/kodata /var/run/ko + +FROM registry.access.redhat.com/ubi8/ubi-minimal + +# install the missing zoneinfo to ubi-minimal +RUN microdnf install tzdata + +USER 65532 + +COPY --from=builder /usr/bin/main /usr/bin/main +COPY --from=builder /var/run/ko /var/run/ko +ENTRYPOINT ["/usr/bin/main"] diff --git a/openshift/ci-operator/source-image/Dockerfile b/openshift/ci-operator/source-image/Dockerfile new file mode 100755 index 00000000..3750d862 --- /dev/null +++ b/openshift/ci-operator/source-image/Dockerfile @@ -0,0 +1,3 @@ +# DO NOT EDIT! Generated Dockerfile. + +FROM src diff --git a/openshift/e2e-tests.sh b/openshift/e2e-tests.sh new file mode 100755 index 00000000..30f7c21a --- /dev/null +++ b/openshift/e2e-tests.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +repo_root_dir=$(dirname "$(realpath "${BASH_SOURCE[0]}")")/.. + +export SKIP_INITIALIZE=true +export GOPATH=/tmp/go +export GOCACHE=/tmp/go-cache +export ARTIFACTS=${ARTIFACT_DIR:-$(mktemp -u -t -d)} + +pushd "${repo_root_dir}/third_party/eventing" +echo "Apply eventing submodule patches" +git apply -v ../../openshift/submodule-patches/eventing/* +popd + +"${repo_root_dir}/test/e2e-tests.sh" diff --git a/openshift/generate.sh b/openshift/generate.sh new file mode 100755 index 00000000..60ecc134 --- /dev/null +++ b/openshift/generate.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -euo pipefail + +repo_root_dir=$(dirname "$(realpath "${BASH_SOURCE[0]}")")/.. + +release=$(yq r openshift/project.yaml project.tag) +release=${release/knative/release} + +function resolve_resources(){ + echo $@ + + local dir=$1 + local resolved_file_name=$2 + + local version=${release/release-/} + + echo "Writing resolved yaml to $resolved_file_name" + + for yaml in "$dir"/*.yaml; do + echo "Resolving ${yaml}" + + echo "---" >> "$resolved_file_name" + + sed \ + -e "s+eventing.knative.dev/release: devel+eventing.knative.dev/release: ${version}+" \ + -e "s+app.kubernetes.io/version: devel+app.kubernetes.io/version: ${version}+" \ + "$yaml" >> "$resolved_file_name" + done +} + +"${repo_root_dir}/hack/update-deps.sh" + +GO111MODULE=off go get -u github.com/openshift-knative/hack/cmd/generate + +$(go env GOPATH)/bin/generate \ + --root-dir "${repo_root_dir}" \ + --generators dockerfile \ + --excludes "vendor.*" \ + --excludes "third_party.*" \ + --images-from eventing \ + --images-from eventing-kafka-broker + +"$repo_root_dir/hack/update-codegen.sh" + +rm -rf "${repo_root_dir}/openshift/release/artifacts" +mkdir -p "${repo_root_dir}/openshift/release/artifacts" +resolve_resources "${repo_root_dir}/config/eventing-istio/roles" "${repo_root_dir}/openshift/release/artifacts/eventing-istio-controller.yaml" +resolve_resources "${repo_root_dir}/config/eventing-istio/controller" "${repo_root_dir}/openshift/release/artifacts/eventing-istio-controller.yaml" diff --git a/openshift/images.yaml b/openshift/images.yaml new file mode 100755 index 00000000..4611050d --- /dev/null +++ b/openshift/images.yaml @@ -0,0 +1,37 @@ +knative.dev/eventing-istio/cmd/controller: registry.ci.openshift.org/openshift/knative-eventing-istio-controller:knative-nightly +knative.dev/eventing-kafka-broker/control-plane/cmd/kafka-controller: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-kafka-controller:knative-nightly +knative.dev/eventing-kafka-broker/control-plane/cmd/kafka-source-controller: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-kafka-source-controller:knative-nightly +knative.dev/eventing-kafka-broker/control-plane/cmd/post-install: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-post-install:knative-nightly +knative.dev/eventing-kafka-broker/control-plane/cmd/webhook-kafka: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-webhook-kafka:knative-nightly +knative.dev/eventing-kafka-broker/test/cmd/logs-exporter: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-test-logs-exporter:knative-nightly +knative.dev/eventing-kafka-broker/test/cmd/watch-cm: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-test-watch-cm:knative-nightly +knative.dev/eventing-kafka-broker/test/test_images/committed-offset: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-test-committed-offset:knative-nightly +knative.dev/eventing-kafka-broker/test/test_images/consumer-group-lag-provider-test: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-test-consumer-group-lag-provider-test:knative-nightly +knative.dev/eventing-kafka-broker/test/test_images/kafka-consumer: registry.ci.openshift.org/openshift/knative-eventing-kafka-broker-test-kafka-consumer:knative-nightly +knative.dev/eventing/cmd/apiserver_receive_adapter: registry.ci.openshift.org/openshift/knative-eventing-apiserver-receive-adapter:knative-nightly +knative.dev/eventing/cmd/appender: registry.ci.openshift.org/openshift/knative-eventing-appender:knative-nightly +knative.dev/eventing/cmd/broker/filter: registry.ci.openshift.org/openshift/knative-eventing-filter:knative-nightly +knative.dev/eventing/cmd/broker/ingress: registry.ci.openshift.org/openshift/knative-eventing-ingress:knative-nightly +knative.dev/eventing/cmd/controller: registry.ci.openshift.org/openshift/knative-eventing-controller:knative-nightly +knative.dev/eventing/cmd/event_display: registry.ci.openshift.org/openshift/knative-eventing-event-display:knative-nightly +knative.dev/eventing/cmd/heartbeats: registry.ci.openshift.org/openshift/knative-eventing-heartbeats:knative-nightly +knative.dev/eventing/cmd/heartbeats_receiver: registry.ci.openshift.org/openshift/knative-eventing-heartbeats-receiver:knative-nightly +knative.dev/eventing/cmd/in_memory/channel_controller: registry.ci.openshift.org/openshift/knative-eventing-channel-controller:knative-nightly +knative.dev/eventing/cmd/in_memory/channel_dispatcher: registry.ci.openshift.org/openshift/knative-eventing-channel-dispatcher:knative-nightly +knative.dev/eventing/cmd/mtchannel_broker: registry.ci.openshift.org/openshift/knative-eventing-mtchannel-broker:knative-nightly +knative.dev/eventing/cmd/mtping: registry.ci.openshift.org/openshift/knative-eventing-mtping:knative-nightly +knative.dev/eventing/cmd/pong: registry.ci.openshift.org/openshift/knative-eventing-pong:knative-nightly +knative.dev/eventing/cmd/schema: registry.ci.openshift.org/openshift/knative-eventing-schema:knative-nightly +knative.dev/eventing/cmd/webhook: registry.ci.openshift.org/openshift/knative-eventing-webhook:knative-nightly +knative.dev/eventing/cmd/websocketsource: registry.ci.openshift.org/openshift/knative-eventing-websocketsource:knative-nightly +knative.dev/eventing/test/test_images/event-sender: registry.ci.openshift.org/openshift/knative-eventing-test-event-sender:knative-nightly +knative.dev/eventing/test/test_images/performance: registry.ci.openshift.org/openshift/knative-eventing-test-performance:knative-nightly +knative.dev/eventing/test/test_images/print: registry.ci.openshift.org/openshift/knative-eventing-test-print:knative-nightly +knative.dev/eventing/test/test_images/recordevents: registry.ci.openshift.org/openshift/knative-eventing-test-recordevents:knative-nightly +knative.dev/eventing/test/test_images/request-sender: registry.ci.openshift.org/openshift/knative-eventing-test-request-sender:knative-nightly +knative.dev/eventing/test/test_images/wathola-fetcher: registry.ci.openshift.org/openshift/knative-eventing-test-wathola-fetcher:knative-nightly +knative.dev/eventing/test/test_images/wathola-forwarder: registry.ci.openshift.org/openshift/knative-eventing-test-wathola-forwarder:knative-nightly +knative.dev/eventing/test/test_images/wathola-receiver: registry.ci.openshift.org/openshift/knative-eventing-test-wathola-receiver:knative-nightly +knative.dev/eventing/test/test_images/wathola-sender: registry.ci.openshift.org/openshift/knative-eventing-test-wathola-sender:knative-nightly +knative.dev/pkg/apiextensions/storageversion/cmd/migrate: registry.ci.openshift.org/openshift/knative-eventing-migrate:knative-nightly +knative.dev/reconciler-test/cmd/eventshub: registry.ci.openshift.org/openshift/knative-eventing-test-eventshub:knative-nightly diff --git a/openshift/install.sh b/openshift/install.sh new file mode 100755 index 00000000..ae09b959 --- /dev/null +++ b/openshift/install.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +function install_eventing_with_mesh() { + local operator_dir=/tmp/serverless-operator + git clone --branch main https://github.com/openshift-knative/serverless-operator.git $operator_dir + + pushd $operator_dir || return $? + + export ON_CLUSTER_BUILDS=true + export DOCKER_REPO_OVERRIDE=image-registry.openshift-image-registry.svc:5000/openshift-marketplace + + make OPENSHIFT_CI="true" SCALE_UP=5 TRACING_BACKEND=zipkin images install-certmanager install-strimzi install-kafka-with-mesh || return $? + + popd || return $? +} + +install_eventing_with_mesh || exit 1 diff --git a/openshift/patches/01-openshift_tests.patch b/openshift/patches/01-openshift_tests.patch new file mode 100644 index 00000000..4b069ef0 --- /dev/null +++ b/openshift/patches/01-openshift_tests.patch @@ -0,0 +1,85 @@ +diff --git a/test/e2e-common.sh b/test/e2e-common.sh +index 8b67cf7..d690543 100755 +--- a/test/e2e-common.sh ++++ b/test/e2e-common.sh +@@ -28,6 +28,8 @@ function run_eventing_core_tests() { + -parallel=12 \ + -run TestPingSource \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" go_test_e2e \ +@@ -35,6 +37,8 @@ function run_eventing_core_tests() { + -parallel=12 \ + -run TestBrokerConformance \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + BROKER_TEMPLATES="${KAFKA_NAMESPACED_BROKER_TEMPLATES}" go_test_e2e \ +@@ -42,6 +46,8 @@ function run_eventing_core_tests() { + -parallel=12 \ + -run TestBrokerConformance \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" go_test_e2e \ +@@ -49,6 +55,8 @@ function run_eventing_core_tests() { + -parallel=12 \ + -run TestContainerSource \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" go_test_e2e \ +@@ -56,6 +64,8 @@ function run_eventing_core_tests() { + -parallel=12 \ + -run TestSinkBinding \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + CHANNEL_GROUP_KIND="InMemoryChannel.messaging.knative.dev" \ +@@ -65,6 +75,8 @@ function run_eventing_core_tests() { + -parallel=18 \ + -run TestChannel \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + CHANNEL_GROUP_KIND="KafkaChannel.messaging.knative.dev" \ +@@ -74,6 +86,8 @@ function run_eventing_core_tests() { + -parallel=18 \ + -run TestChannel \ + ./test/rekt/ \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + popd +@@ -87,6 +101,8 @@ function run_eventing_kafka_broker_tests() { + -parallel=12 \ + -run TestKafkaSource \ + ./test/e2e_new/... \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" BROKER_CLASS="Kafka" go_test_e2e \ +@@ -94,6 +110,8 @@ function run_eventing_kafka_broker_tests() { + -parallel=12 \ + -run TestKafkaSink \ + ./test/e2e_new/... \ ++ --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ ++ --environment.namespace="serverless-tests" \ + --istio.enabled=true || return $? + + popd diff --git a/openshift/project.yaml b/openshift/project.yaml new file mode 100644 index 00000000..29a7b84e --- /dev/null +++ b/openshift/project.yaml @@ -0,0 +1,3 @@ +project: + tag: knative-nightly + imagePrefix: knative-eventing-istio diff --git a/openshift/release/artifacts/eventing-istio-controller.yaml b/openshift/release/artifacts/eventing-istio-controller.yaml new file mode 100644 index 00000000..7ad7fdae --- /dev/null +++ b/openshift/release/artifacts/eventing-istio-controller.yaml @@ -0,0 +1,223 @@ +--- +# Copyright 2023 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: knative-eventing-istio-controller + labels: + app.kubernetes.io/version: nightly + app.kubernetes.io/name: knative-eventing +rules: + - apiGroups: + - "" + resources: + - "services" + - "configmaps" + verbs: + - "get" + - "list" + - "watch" + + - apiGroups: + - "" + resources: + - "services/finalizers" + verbs: + - "create" + - "update" + - "delete" + - "get" + - "list" + - "watch" + + - apiGroups: + - "networking.istio.io" + resources: + - "destinationrules" + verbs: &everything + - "get" + - "list" + - "create" + - "update" + - "delete" + - "patch" + - "watch" + + # For leader election + - apiGroups: + - "coordination.k8s.io" + resources: + - "leases" + verbs: *everything + + # For creating events and reporting errors + - apiGroups: + - "" + resources: + - "events" + verbs: *everything +--- +# Copyright 2023 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: eventing-istio-controller + namespace: knative-eventing + labels: + app.kubernetes.io/version: nightly + app.kubernetes.io/name: knative-eventing + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: eventing-istio-controller + labels: + app.kubernetes.io/version: nightly + app.kubernetes.io/name: knative-eventing +subjects: + - kind: ServiceAccount + name: eventing-istio-controller + namespace: knative-eventing +roleRef: + kind: ClusterRole + name: knative-eventing-istio-controller + apiGroup: rbac.authorization.k8s.io +--- +# Copyright 2023 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: eventing-istio-controller + namespace: knative-eventing + labels: + knative.dev/high-availability: "true" + app.kubernetes.io/component: eventing-istio-controller + app.kubernetes.io/version: nightly + app.kubernetes.io/name: knative-eventing +spec: + selector: + matchLabels: + app: eventing-istio-controller + template: + metadata: + labels: + app: eventing-istio-controller + app.kubernetes.io/component: eventing-istio-controller + app.kubernetes.io/version: nightly + app.kubernetes.io/name: knative-eventing + spec: + # To avoid node becoming SPOF, spread our replicas to different nodes. + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchLabels: + app: eventing-istio-controller + topologyKey: kubernetes.io/hostname + weight: 100 + + serviceAccountName: eventing-istio-controller + enableServiceLinks: false + containers: + - name: eventing-istio-controller + terminationMessagePolicy: FallbackToLogsOnError + image: ko://knative.dev/eventing-istio/cmd/controller + + resources: + requests: + cpu: 100m + memory: 100Mi + + env: + - name: SYSTEM_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CONFIG_LOGGING_NAME + value: config-logging + - name: CONFIG_OBSERVABILITY_NAME + value: config-observability + - name: METRICS_DOMAIN + value: knative.dev/eventing-istio + # APIServerSource + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + runAsNonRoot: true + capabilities: + drop: + - ALL + seccompProfile: + type: RuntimeDefault + + livenessProbe: + httpGet: + path: /health + port: probes + scheme: HTTP + initialDelaySeconds: 20 + periodSeconds: 10 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: /readiness + port: probes + scheme: HTTP + initialDelaySeconds: 20 + periodSeconds: 10 + timeoutSeconds: 5 + + ports: + - name: metrics + containerPort: 9090 + - name: profiling + containerPort: 8008 + - name: probes + containerPort: 8080 diff --git a/openshift/release/create-release-branch.sh b/openshift/release/create-release-branch.sh new file mode 100755 index 00000000..e41eb4e4 --- /dev/null +++ b/openshift/release/create-release-branch.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Usage: create-release-branch.sh v0.4.1 release-0.4 + +set -ex # Exit immediately on error. + +release=$1 +target=$2 + +# Fetch the latest tags and checkout a new branch from the wanted tag. +git fetch upstream -v --tags +git checkout -b "$target" "$release" + +# Remove GH Action hooks from upstream +rm -rf .github/workflows +git commit -sm ":fire: remove unneeded workflows" .github/ + +# Copy the openshift extra files from the OPENSHIFT/main branch. +git fetch openshift main +git checkout openshift/main -- openshift OWNERS Makefile + +tag=${target/release-/} +yq write --inplace openshift/project.yaml project.tag "knative-$tag" + +# Generate our OCP artifacts +make generate +git apply openshift/patches/* +git add openshift OWNERS Makefile +git commit -m "Add openshift specific files." diff --git a/openshift/release/mirror-upstream-branches.sh b/openshift/release/mirror-upstream-branches.sh new file mode 100755 index 00000000..15ba5051 --- /dev/null +++ b/openshift/release/mirror-upstream-branches.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Usage: openshift/release/mirror-upstream-branches.sh +# This should be run from the basedir of the repo with no arguments + + +set -ex +readonly TMPDIR=$(mktemp -d knativeEventingIstioBranchingCheckXXXX -p /tmp/) + +git fetch upstream --tags +git fetch openshift --tags + +# We need to seed this with a few releases that, otherwise, would make +# the processing regex less clear with more anomalies +cat >> "$TMPDIR"/midstream_branches < "$TMPDIR"/upstream_branches +git branch --list -a "openshift/release-v1.*" | cut -f3 -d'/' | cut -f2 -d'v' | cut -f1,2 -d'.' >> "$TMPDIR"/midstream_branches + +sort -o "$TMPDIR"/midstream_branches "$TMPDIR"/midstream_branches +sort -o "$TMPDIR"/upstream_branches "$TMPDIR"/upstream_branches +comm -32 "$TMPDIR"/upstream_branches "$TMPDIR"/midstream_branches > "$TMPDIR"/new_branches + +UPSTREAM_BRANCH=$(cat "$TMPDIR"/new_branches) +if [ -z "$UPSTREAM_BRANCH" ]; then + echo "no new branch, exiting" + exit 0 +fi +echo "found upstream branch: $UPSTREAM_BRANCH" +readonly UPSTREAM_TAG="knative-v$UPSTREAM_BRANCH.0" +readonly MIDSTREAM_BRANCH="release-v$UPSTREAM_BRANCH" +openshift/release/create-release-branch.sh "$UPSTREAM_TAG" "$MIDSTREAM_BRANCH" +# we would check the error code, but we 'set -e', so assume we're fine +git push openshift "$MIDSTREAM_BRANCH" diff --git a/openshift/release/update-to-head.sh b/openshift/release/update-to-head.sh new file mode 100755 index 00000000..2211eed7 --- /dev/null +++ b/openshift/release/update-to-head.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Synchs the REPO_BRANCH branch to main and then triggers CI +# Usage: update-to-head.sh + +set -e +REPO_NAME="eventing-istio" +REPO_OWNER_NAME="openshift-knative" +REPO_BRANCH="release-next" +REPO_BRANCH_CI="${REPO_BRANCH}-ci" + +# Check if there's an upstream release we need to mirror downstream +openshift/release/mirror-upstream-branches.sh + +# Reset REPO_BRANCH to upstream/main. +git fetch upstream main +git checkout upstream/main -B ${REPO_BRANCH} + +# Update openshift's main and take all needed files from there. +git fetch openshift main +git checkout openshift/main openshift OWNERS Makefile + +# Generate our OCP artifacts +make generate +git apply openshift/patches/* +git add . +git commit -m ":open_file_folder: Update openshift specific files." +git push -f openshift ${REPO_BRANCH} + +# Trigger CI +git checkout ${REPO_BRANCH} -B ${REPO_BRANCH_CI} +date > ci +git add ci +git commit -m ":robot: Triggering CI on branch '${REPO_BRANCH}' after synching to upstream/main" +git push -f openshift ${REPO_BRANCH_CI} + +if hash hub 2>/dev/null; then + # Test if there is already a sync PR in + COUNT=$(hub api -H "Accept: application/vnd.github.v3+json" repos/${REPO_OWNER_NAME}/${REPO_NAME}/pulls --flat \ + | grep -c ":robot: Triggering CI on branch '${REPO_BRANCH}' after synching to upstream/main") || true + if [ "$COUNT" = "0" ]; then + hub pull-request --no-edit -l "kind/sync-fork-to-upstream" -b ${REPO_OWNER_NAME}/${REPO_NAME}:${REPO_BRANCH} -h ${REPO_OWNER_NAME}/${REPO_NAME}:${REPO_BRANCH_CI} + fi +else + echo "hub (https://github.com/github/hub) is not installed, so you'll need to create a PR manually." +fi diff --git a/openshift/submodule-patches/eventing/skip-eventtype-tests.patch b/openshift/submodule-patches/eventing/skip-eventtype-tests.patch new file mode 100644 index 00000000..cde460cd --- /dev/null +++ b/openshift/submodule-patches/eventing/skip-eventtype-tests.patch @@ -0,0 +1,12 @@ +diff --git a/test/rekt/pingsource_test.go b/test/rekt/pingsource_test.go +index 42629cd43..f664eadc7 100644 +--- a/test/rekt/pingsource_test.go ++++ b/test/rekt/pingsource_test.go +@@ -93,6 +93,7 @@ func TestPingSourceWithCloudEventData(t *testing.T) { + } + + func TestPingSourceWithEventTypes(t *testing.T) { ++ t.Skip("Skip, while SO deployes a eventing release, which does not support EventTypes v1beta2") + t.Parallel() + + ctx, env := global.Environment( diff --git a/pkg/client/istio/clientset/versioned/fake/register.go b/pkg/client/istio/clientset/versioned/fake/register.go index f74757ea..8b838349 100644 --- a/pkg/client/istio/clientset/versioned/fake/register.go +++ b/pkg/client/istio/clientset/versioned/fake/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/istio/clientset/versioned/scheme/register.go b/pkg/client/istio/clientset/versioned/scheme/register.go index a65948f0..3011e9ec 100644 --- a/pkg/client/istio/clientset/versioned/scheme/register.go +++ b/pkg/client/istio/clientset/versioned/scheme/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/istio/informers/externalversions/factory.go b/pkg/client/istio/informers/externalversions/factory.go index af6177c7..af2dd0e4 100644 --- a/pkg/client/istio/informers/externalversions/factory.go +++ b/pkg/client/istio/informers/externalversions/factory.go @@ -194,25 +194,25 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal // // It is typically used like this: // -// ctx, cancel := context.Background() -// defer cancel() -// factory := NewSharedInformerFactory(client, resyncPeriod) -// defer factory.WaitForStop() // Returns immediately if nothing was started. -// genericInformer := factory.ForResource(resource) -// typedInformer := factory.SomeAPIGroup().V1().SomeType() -// factory.Start(ctx.Done()) // Start processing these informers. -// synced := factory.WaitForCacheSync(ctx.Done()) -// for v, ok := range synced { -// if !ok { -// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) -// return -// } -// } +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } // -// // Creating informers can also be created after Start, but then -// // Start must be called again: -// anotherGenericInformer := factory.ForResource(resource) -// factory.Start(ctx.Done()) +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) type SharedInformerFactory interface { internalinterfaces.SharedInformerFactory diff --git a/test/e2e-common.sh b/test/e2e-common.sh index 44a5c884..fb0e182c 100755 --- a/test/e2e-common.sh +++ b/test/e2e-common.sh @@ -28,6 +28,8 @@ function run_eventing_core_tests() { -parallel=12 \ -run TestPingSource \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" go_test_e2e \ @@ -35,6 +37,8 @@ function run_eventing_core_tests() { -parallel=12 \ -run TestBrokerConformance \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? BROKER_TEMPLATES="${KAFKA_NAMESPACED_BROKER_TEMPLATES}" go_test_e2e \ @@ -42,6 +46,8 @@ function run_eventing_core_tests() { -parallel=12 \ -run TestBrokerConformance \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" go_test_e2e \ @@ -49,6 +55,8 @@ function run_eventing_core_tests() { -parallel=12 \ -run TestContainerSource \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" go_test_e2e \ @@ -56,6 +64,8 @@ function run_eventing_core_tests() { -parallel=12 \ -run TestSinkBinding \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? CHANNEL_GROUP_KIND="InMemoryChannel.messaging.knative.dev" \ @@ -65,6 +75,8 @@ function run_eventing_core_tests() { -parallel=18 \ -run TestChannel \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? CHANNEL_GROUP_KIND="KafkaChannel.messaging.knative.dev" \ @@ -74,6 +86,8 @@ function run_eventing_core_tests() { -parallel=18 \ -run TestChannel \ ./test/rekt/ \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? popd @@ -87,6 +101,8 @@ function run_eventing_kafka_broker_tests() { -parallel=12 \ -run TestKafkaSource \ ./test/e2e_new/... \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? BROKER_TEMPLATES="${KAFKA_BROKER_TEMPLATES}" BROKER_CLASS="Kafka" go_test_e2e \ @@ -94,6 +110,8 @@ function run_eventing_kafka_broker_tests() { -parallel=12 \ -run TestKafkaSink \ ./test/e2e_new/... \ + --images.producer.file="${REPO_ROOT_DIR}/openshift/images.yaml" \ + --environment.namespace="serverless-tests" \ --istio.enabled=true || return $? popd