diff --git a/cmd/v0.17/pingsource-cleanup/README.md b/cmd/v0.17/pingsource-cleanup/README.md new file mode 100644 index 00000000000..5133ce81ca2 --- /dev/null +++ b/cmd/v0.17/pingsource-cleanup/README.md @@ -0,0 +1,82 @@ +# PingSource cleanup post-0.17.0 install + +The following is a log of testing commands to try out this job. + +The job's log is the yaml of all resources that were deleted. The job uses +eventing's service account. + +--- + +## kind start cluster: + +``` +cat < 0 { + finalizers := sets.NewString(pingsource.Finalizers...) + if finalizers.Has("pingsources.sources.knative.dev") { + fmt.Printf("# Found PingSource %s/%s, need to remove finalizer.\n", pingsource.Namespace, pingsource.Name) + cleanups = append(cleanups, pingsource) + } + } + } + } + + if !env.DryRun { + for _, ref := range cleanups { + fmt.Printf("# will remove finalizer for %s/%s\n", ref.Namespace, ref.Name) + + finalizers := sets.NewString(ref.Finalizers...) + finalizers.Delete("pingsources.sources.knative.dev") + ref.Finalizers = finalizers.List() + + if _, err := client.SourcesV1alpha2().PingSources(ref.Namespace).Update(&ref); err != nil { + fmt.Printf("# [error] failed to update %s/%s %s\n", ref.Namespace, ref.Name, err) + } + } + } + fmt.Printf("# Done, cleaned %d resources.\n", len(cleanups)) +} diff --git a/config/post-install/v0.17.0/dummy.go b/config/post-install/v0.17.0/dummy.go new file mode 100644 index 00000000000..30f6c5d46f0 --- /dev/null +++ b/config/post-install/v0.17.0/dummy.go @@ -0,0 +1,19 @@ +/* +Copyright 2020 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 + + https://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. +*/ + +// Package preinstall is a placeholder that allows us to pull in config files +// via go mod vendor. +package preinstall diff --git a/config/post-install/v0.17.0/pingsource-cleanup.yaml b/config/post-install/v0.17.0/pingsource-cleanup.yaml new file mode 100644 index 00000000000..7d54857bc57 --- /dev/null +++ b/config/post-install/v0.17.0/pingsource-cleanup.yaml @@ -0,0 +1,28 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: v0.17.0-pingsource-cleanup + namespace: knative-eventing + labels: + eventing.knative.dev/release: devel +spec: + ttlSecondsAfterFinished: 600 + template: + metadata: + annotations: + sidecar.istio.io/inject: "false" + spec: + serviceAccountName: eventing-controller + restartPolicy: Never + containers: + - name: pingsource + image: ko://knative.dev/eventing/cmd/v0.17/pingsource-cleanup + env: + - name: SYSTEM_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + +# Note the following ENVVAR settings exist: +# SYSTEM_NAMESPACE - the namespace of the control plane, defaults to knative-eventing +# DRY_RUN - a flag to run the script without deleting or updating, defaults to false. diff --git a/hack/release.sh b/hack/release.sh index 7f9a93ad4e7..ba9cbea7bed 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -26,6 +26,7 @@ readonly MT_CHANNEL_BROKER_YAML="mt-channel-broker.yaml" readonly IN_MEMORY_CHANNEL="in-memory-channel.yaml" readonly PRE_INSTALL_V_0_16="eventing-pre-install-jobs.yaml" readonly POST_INSTALL_V_0_16="eventing-post-install-jobs.yaml" +readonly POST_INSTALL_V_0_17="eventing-post-install-jobs.yaml" declare -A RELEASES RELEASES=( @@ -66,7 +67,10 @@ function build_release() { # Create v0.16.0 post-install job yaml. Cleans up old broker resources from deleted namespaced brokers. ko resolve ${KO_FLAGS} -f config/post-install/v0.16.0/ | "${LABEL_YAML_CMD[@]}" > "${POST_INSTALL_V_0_16}" - local all_yamls=(${EVENTING_CORE_YAML} ${EVENTING_CRDS_YAML} ${SUGAR_CONTROLLER_YAML} ${MT_CHANNEL_BROKER_YAML} ${IN_MEMORY_CHANNEL} ${PRE_INSTALL_V_0_16} ${POST_INSTALL_V_0_16}) + # Create v0.17.0 post-install job yaml. Cleans up pingsources with finalizers + ko resolve ${KO_FLAGS} -f config/post-install/v0.17.0/ | "${LABEL_YAML_CMD[@]}" > "${POST_INSTALL_V_0_17}" + + local all_yamls=(${EVENTING_CORE_YAML} ${EVENTING_CRDS_YAML} ${SUGAR_CONTROLLER_YAML} ${MT_CHANNEL_BROKER_YAML} ${IN_MEMORY_CHANNEL} ${PRE_INSTALL_V_0_16} ${POST_INSTALL_V_0_16} ${POST_INSTALL_V_0_17}) # Assemble the release for yaml in "${!RELEASES[@]}"; do