Skip to content
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
8 changes: 7 additions & 1 deletion pkg/payload/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ func LoadUpdate(dir, releaseImage, excludeIdentifier string, requiredFeatureSet
if task.preprocess != nil {
raw, err = task.preprocess(raw)
if err != nil {
errs = append(errs, fmt.Errorf("preprocess %s: %w", file.Name(), err))
// Template rendering may fail when an older CVO binary
// loads a newer payload that uses template fields the
// older binary does not know about (e.g. .Images). Skip
// the manifest with a warning — the new CVO binary will
// re-load the full payload after it replaces the old one
// at run-level 0.
klog.Warningf("Skipping manifest %s: template rendering failed (may require newer CVO): %v", file.Name(), err)
continue
}
}
Expand Down
20 changes: 20 additions & 0 deletions pkg/payload/payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@ func TestLoadUpdate(t *testing.T) {
}
}

func TestLoadUpdateSkipsUnknownTemplateFields(t *testing.T) {
update, err := LoadUpdate("testdata/payload-unknown-template", "image:test", "", "", DefaultClusterProfile, nil, sets.Set[string]{})
if err != nil {
t.Fatalf("LoadUpdate should not fail when a manifest uses unknown template fields, got: %v", err)
}

var foundValid bool
for _, m := range update.Manifests {
if m.OriginalFilename == "0000_00_valid.yaml" {
foundValid = true
}
if m.OriginalFilename == "0000_50_unknown-field.yaml" {
t.Error("manifest with unknown template field should have been skipped, but was loaded")
}
}
if !foundValid {
t.Error("expected valid manifest (0000_00_valid.yaml) to be loaded")
}
}

func TestLoadUpdateArchitecture(t *testing.T) {
type args struct {
dir string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: valid-manifest
namespace: test
annotations:
include.release.openshift.io/self-managed-high-availability: "true"
data:
release-image: '{{.ReleaseImage}}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: future-manifest
namespace: test
annotations:
include.release.openshift.io/self-managed-high-availability: "true"
data:
image: '{{index .FutureField "some-key"}}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"kind": "ImageStream",
"apiVersion": "image.openshift.io/v1",
"metadata": {
"name": "1.0.0-test"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"kind":"cincinnati-metadata-v0","version":"1.0.0-test"}