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

Add kafka contract cleanup script #2553

Closed
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
9 changes: 9 additions & 0 deletions test/upgrade/installation/downgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

for cm_name in "$@"; do
cmdata=$(kubectl get cm "$cm_name" -n knative-eventing -ojson)
if [ ! -z "$cmdata" ]; then

Check warning on line 5 in test/upgrade/installation/downgrade.sh

View workflow job for this annotation

GitHub Actions / Lint

[shellcheck] reported by reviewdog 🐶 Use -n instead of ! -z. Raw Output: ./test/upgrade/installation/downgrade.sh:5:8: info: Use -n instead of ! -z. (ShellCheck.SC2236)
new_data=$(echo $cmdata | jq -r .binaryData.data | base64 --decode | jq 'del(.trustBundles)' -c | base64 -w 0)

Check warning on line 6 in test/upgrade/installation/downgrade.sh

View workflow job for this annotation

GitHub Actions / Lint

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./test/upgrade/installation/downgrade.sh:6:21: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
echo $cmdata | jq --arg new_data $new_data '.binaryData.data = $new_data' | kubectl apply -f -

Check warning on line 7 in test/upgrade/installation/downgrade.sh

View workflow job for this annotation

GitHub Actions / Lint

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./test/upgrade/installation/downgrade.sh:7:10: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

Check warning on line 7 in test/upgrade/installation/downgrade.sh

View workflow job for this annotation

GitHub Actions / Lint

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./test/upgrade/installation/downgrade.sh:7:38: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
fi
done
22 changes: 22 additions & 0 deletions test/upgrade/installation/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package installation

import (
"context"
_ "embed"
"errors"
"fmt"
"os/exec"
"strings"
"time"

Expand All @@ -21,6 +23,9 @@ const (
DefaultInstallPlanTimeout = 15 * time.Minute
)

//go:embed downgrade.sh
var downgradeContractScript string

func UpgradeServerlessTo(ctx *test.Context, csv, source string, timeout time.Duration) error {
if _, err := test.UpdateSubscriptionChannelSource(ctx, test.Flags.Subscription, test.Flags.UpgradeChannel, source); err != nil {
return err
Expand Down Expand Up @@ -188,6 +193,10 @@ func DowngradeServerless(ctx *test.Context) error {
return fmt.Errorf("eventing downgrade failed: %w", err)
}

if err := downgradeKafkaContractsWithScript(); err != nil {
return fmt.Errorf("failed to downgrade contracts: %w", err)
}

if _, err := v1alpha1.WaitForKnativeKafkaState(ctx,
"knative-kafka",
knativeEventing,
Expand Down Expand Up @@ -251,3 +260,16 @@ func setStorageToAlpha(ctx *test.Context, name string) error {
return err
})
}

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only one thing for the script: Should we include the names of the main configmaps already in the script, so support would not need to know the names of the CMs?
And maybe we can pass the namespace as a parameter to the script, so we could also use this (in the rare case) of using the namespaced-broker.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could change that!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry, I could have responded earlier: #2555


c.Stdin = strings.NewReader(downgradeContractScript)

_, err := c.Output()
if err != nil {
return err
}

return nil
}
Loading