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

[release-1.32] Update contract downgrade script to be standalone #2555

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 27 additions & 3 deletions test/upgrade/installation/downgrade.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
#!/usr/bin/env bash

for cm_name in "$@"; do
cmdata=$(kubectl get cm "$cm_name" -n knative-eventing -ojson)
# Removes the `trustBundles` key from contract configmaps.
#
# Usage
# downgrade.sh <namespace> <additional-configmaps>
# Example:
# downgrade.sh knative-eventing kafka-source-dispatcher-0 kafka-source-dispatcher-1
#
# namespace: Optional - The namespace in which to update the configmaps. Defaults to "knative-eventing"
# additional-configmaps: Optional - List of additional contract configmaps to patch
# (in addition to kafka-broker-brokers-triggers, kafka-channel-channels-subscriptions and kafka-sink-sinks)

target_namespace="${1:-"knative-eventing"}"
declare -a contract_configmaps=("kafka-broker-brokers-triggers" "kafka-channel-channels-subscriptions" "kafka-sink-sinks")

for additional_cm in "${@:2}"; do
contract_configmaps+=("$additional_cm")
done

for cm_name in "${contract_configmaps[@]}"; do
cmdata=$(kubectl get cm "$cm_name" -n "$target_namespace" -ojson || true)
if [ -n "$cmdata" ]; then
new_data=$(echo "$cmdata" | jq -r .binaryData.data | base64 --decode | jq 'del(.trustBundles)' -c | base64 -w 0)
new_data=$(echo "$cmdata" | jq -r .binaryData.data | base64 --decode | jq 'del(.trustBundles, .resources[].ingress.enableAutoCreateEventTypes)' -c | base64 -w 0)
echo "$cmdata" | jq --arg new_data "$new_data" '.binaryData.data = $new_data' | kubectl apply -f -
fi
done

# Trigger a reconcile of the related pods (see https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#mounted-configmaps-are-updated-automatically)
declare -a pods_app_labels=("kafka-broker-dispatcher" "kafka-broker-receiver" "kafka-channel-dispatcher" "kafka-channel-receiver" "kafka-source-dispatcher" "kafka-sink-receiver")
for app_label in "${pods_app_labels[@]}"; do
kubectl -n "$target_namespace" annotate pod -l=app="$app_label" why="to trigger a reconcile" --overwrite || true
done
2 changes: 1 addition & 1 deletion test/upgrade/installation/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func setStorageToAlpha(ctx *test.Context, name string) error {
}

func downgradeKafkaContractsWithScript() error {
c := exec.Command("bash", "-s", "-", "kafka-broker-brokers-triggers", "kafka-channel-channels-subscriptions", "kafka-sink-sinks", "kafka-source-dispatcher-0", "kafka-source-dispatcher-1")
c := exec.Command("bash", "-s", "-", test.EventingNamespace, "kafka-source-dispatcher-0", "kafka-source-dispatcher-1")

c.Stdin = strings.NewReader(downgradeContractScript)

Expand Down