vmware-tanzu/sources-for-knative

[BUG] Installation of Tanzu Sources fails for CM config-election-leader with "_example" modified error.

rguske opened this issue · 1 comments

Describe the bug
When trying to install the Tanzu Sources (k apply -f release.yaml) it always fails when creating the config-election-leader configMap.

k apply -f release0371.yaml 
namespace/vmware-sources created
serviceaccount/horizon-source-controller created
serviceaccount/horizon-source-webhook created
clusterrole.rbac.authorization.k8s.io/vsphere-receive-adapter-cm created
clusterrole.rbac.authorization.k8s.io/vmware-sources-admin created
clusterrole.rbac.authorization.k8s.io/vmware-sources-core created
clusterrole.rbac.authorization.k8s.io/podspecable-binding created
clusterrole.rbac.authorization.k8s.io/builtin-podspecable-binding created
serviceaccount/vsphere-controller created
clusterrole.rbac.authorization.k8s.io/horizon-source-controller created
clusterrole.rbac.authorization.k8s.io/horizon-source-observer created
clusterrolebinding.rbac.authorization.k8s.io/vmware-sources-controller-admin created
clusterrolebinding.rbac.authorization.k8s.io/vmware-sources-webhook-podspecable-binding created
clusterrolebinding.rbac.authorization.k8s.io/vmware-sources-webhook-addressable-resolver-binding created
clusterrolebinding.rbac.authorization.k8s.io/horizon-source-controller-rolebinding created
clusterrolebinding.rbac.authorization.k8s.io/horizon-source-webhook-rolebinding created
clusterrolebinding.rbac.authorization.k8s.io/horizon-source-controller-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/horizon-source-webhook created
customresourcedefinition.apiextensions.k8s.io/horizonsources.sources.tanzu.vmware.com created
customresourcedefinition.apiextensions.k8s.io/vspherebindings.sources.tanzu.vmware.com created
customresourcedefinition.apiextensions.k8s.io/vspheresources.sources.tanzu.vmware.com created
service/horizon-source-controller-manager created
service/horizon-source-webhook created
service/vsphere-source-webhook created
deployment.apps/horizon-source-controller created
mutatingwebhookconfiguration.admissionregistration.k8s.io/defaulting.webhook.horizon.sources.tanzu.vmware.com created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.horizon.sources.tanzu.vmware.com created
validatingwebhookconfiguration.admissionregistration.k8s.io/config.webhook.horizon.sources.tanzu.vmware.com created
secret/webhook-certs created
deployment.apps/horizon-source-webhook created
mutatingwebhookconfiguration.admissionregistration.k8s.io/defaulting.webhook.vsphere.sources.tanzu.vmware.com created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.vsphere.sources.tanzu.vmware.com created
validatingwebhookconfiguration.admissionregistration.k8s.io/config.webhook.vsphere.sources.tanzu.vmware.com created
secret/vsphere-webhook-certs created
mutatingwebhookconfiguration.admissionregistration.k8s.io/vspherebindings.webhook.vsphere.sources.tanzu.vmware.com created
deployment.apps/vsphere-source-webhook created
configmap/config-logging created
configmap/config-observability created
Error from server (BadRequest): error when creating "release0371.yaml": admission webhook "config.webhook.eventing.knative.dev" denied the request: validation failed: the update modifies a key in "_example" which is probably not what you want. Instead, copy the respective setting to the top-level of the ConfigMap, directly below "data"

To Reproduce
Steps to reproduce the behavior:

  1. kn quickstart kind
  2. kubectl apply -f release.yaml

Expected behavior
A clean run through.

Affected version
I validated Kubernetes version s 1.25.x, 1.28.x and 1.29.x
Knative versions 1.10 and latest 1.13
Tanzu Sources 0.37.1, 0.38.1 and 0.39.0

Screenshots/Debug Output
It runs through when deleting the annotation knative.dev/example-checksum: "a2f53e10"

Fixed by changing the sha of the example checksum annotation and manually changing it in the release.yml file via the Github editing option.

Here is the snippet for more context on how to fix it:


import (
	"fmt"
	"hash/crc32"
	"os"
	"regexp"
	"strings"

	"gopkg.in/yaml.v2"
)

var (
	// Allows for normalizing by collapsing newlines.
	sequentialNewlines = regexp.MustCompile("(?:\r?\n)+")
)

type ConfigMap struct {
	Data map[string]string `json:"data,omitempty" protobuf:"bytes,2,rep,name=data"`
}

func Checksum(value string) string {
	return fmt.Sprintf("%08x", crc32.ChecksumIEEE([]byte(sequentialNewlines.ReplaceAllString(strings.TrimSpace(value), `\n`))))
}

func main() {
	contents, _ := os.ReadFile("./config/config-leader-election.yaml")
	var cm ConfigMap
	if err := yaml.Unmarshal(contents, &cm); err != nil {
		fmt.Println("cannot decode incoming new object:")
	}

	exampleData := cm.Data["_example"]
	chks := Checksum(exampleData)
	exampleChecksum := "a2f53e10"
	fmt.Println(chks, exampleChecksum)
}