Skip to content

OCPBUGS-56569: [release-4.18] fix: don't template registry+v1 manifests #354

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

Open
wants to merge 1 commit into
base: release-4.18
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions internal/rukpak/convert/registryv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,22 @@ func toChart(in RegistryV1, installNamespace string, watchNamespaces []string) (
return nil, err
}
hash := sha256.Sum256(jsonData)
chrt.Templates = append(chrt.Templates, &chart.File{
Name: fmt.Sprintf("object-%x.json", hash[0:8]),
name := fmt.Sprintf("object-%x.json", hash[0:8])

// Some registry+v1 manifests may actually contain Go Template strings
// that are meant to survive and actually persist into etcd (e.g. to be
// used as a templated configuration for another component). In order to
// avoid applying templating logic to registry+v1's static manifests, we
// create the manifests as Files, and then template those files via simple
// Templates.
chrt.Files = append(chrt.Files, &chart.File{
Name: name,
Data: jsonData,
})
chrt.Templates = append(chrt.Templates, &chart.File{
Name: name,
Data: []byte(fmt.Sprintf(`{{.Files.Get "%s"}}`, name)),
})
}

return chrt, nil
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/cluster_extension_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
}
}, pollDuration, pollInterval)

t.Log("By verifying that no templating occurs for registry+v1 bundle manifests")
cm := corev1.ConfigMap{}
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
require.Contains(t, cm.Annotations, "shouldNotTemplate")
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: test-configmap
annotations:
shouldNotTemplate: >
The namespace is {{ $labels.namespace }}. The templated
$labels.namespace is NOT expected to be processed by OLM's
rendering engine for registry+v1 bundles.
data:
version: "v1.0.0"
name: "test-configmap"