Skip to content
Draft
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
2 changes: 2 additions & 0 deletions bootstrap/bootstrap-pod.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# The Pod is deployed as a static Pod during cluster bootstrap by the installer. Static Pods have some notable details,
# such as the fact that the spec cannot refer to API objects, like ServiceAccount and ConfigMap.
apiVersion: v1
kind: Pod
metadata:
Expand Down
8 changes: 5 additions & 3 deletions cmd/cluster-version-operator/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import (
var (
renderCmd = &cobra.Command{
Use: "render",
Short: "Renders the UpdatePayload to disk.",
Long: "",
Run: runRenderCmd,
Short: "Renders and filters release payload manifests for cluster bootstrap.",
Long: `Renders and filters CVO manifests and specific release payload manifests.
Called by the installer as part of cluster bootstrap to generate the initial manifests related to the CVO.`,
Run: runRenderCmd,
}

renderOpts struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: cluster-version-operator
annotations:
include.release.openshift.io/self-managed-high-availability: "true"
release.openshift.io/delete: "true"
roleRef:
kind: ClusterRole
name: cluster-admin
Expand Down
6 changes: 6 additions & 0 deletions pkg/payload/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/openshift/api/config"
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/library-go/pkg/manifest"

"github.com/openshift/cluster-version-operator/lib/resourcedelete"
)

// Render renders critical manifests from /manifests to outputDir.
Expand Down Expand Up @@ -148,6 +150,10 @@ func renderDir(renderConfig manifestRenderConfig, idir, odir string, overrides [
klog.Infof("excluding %s because we do not render that group/kind", manifest.String())
} else if err := manifest.Include(nil, requiredFeatureSet, clusterProfile, nil, overrides, enabledFeatureGates, majorVersion); err != nil {
klog.Infof("excluding %s: %v", manifest.String(), err)
} else if found, err := resourcedelete.ValidDeleteAnnotation(manifest.Obj.GetAnnotations()); err != nil {
errs = append(errs, fmt.Errorf("invalid delete annotation in %s from %s: %w", manifest.String(), file.Name(), err))
} else if found {
klog.Infof("excluding %s because we do not render manifests with the delete annotation", manifest.String())
} else {
filteredManifests = append(filteredManifests, string(manifest.Raw))
klog.Infof("including %s", manifest.String())
Expand Down
56 changes: 53 additions & 3 deletions pkg/payload/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ func TestRenderManifest(t *testing.T) {
}
}

func TestRenderDirWithMajorVersionFiltering(t *testing.T) {
func TestRenderDirFiltering(t *testing.T) {
tests := []struct {
name string
manifests []testManifest
majorVersion *uint64
expectedInclusions []string // Names of manifests that should be included
expectedExclusions []string // Names of manifests that should be excluded
expectError bool // Whether an error is expected
}{
{
name: "major version 4 includes version 4 manifests",
Expand Down Expand Up @@ -183,6 +184,49 @@ func TestRenderDirWithMajorVersionFiltering(t *testing.T) {
expectedInclusions: []string{"version4-or-5-manifest", "exclude-version3-manifest"},
expectedExclusions: []string{"version6-only-manifest"},
},
{
name: "delete annotation excludes manifests",
manifests: []testManifest{
{
name: "normal-manifest",
annotations: map[string]string{},
},
{
name: "deleted-manifest",
annotations: map[string]string{
"release.openshift.io/delete": "true",
},
},
{
name: "another-normal-manifest",
annotations: map[string]string{
"some.other.annotation": "value",
},
},
},
majorVersion: ptr.To(uint64(4)),
expectedInclusions: []string{"normal-manifest", "another-normal-manifest"},
expectedExclusions: []string{"deleted-manifest"},
},
{
name: "invalid delete annotation value returns error but continues rendering",
manifests: []testManifest{
{
name: "normal-manifest",
annotations: map[string]string{},
},
{
name: "invalid-delete-manifest",
annotations: map[string]string{
"release.openshift.io/delete": "false",
},
},
},
majorVersion: ptr.To(uint64(4)),
expectedInclusions: []string{"normal-manifest"},
expectedExclusions: []string{"invalid-delete-manifest"},
expectError: true,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -233,8 +277,14 @@ func TestRenderDirWithMajorVersionFiltering(t *testing.T) {
sets.Set[schema.GroupKind]{}, // filterGroupKind
)

if err != nil {
t.Fatalf("renderDir failed: %v", err)
if tt.expectError {
if err == nil {
t.Errorf("expected error but got none")
}
} else {
if err != nil {
t.Fatalf("renderDir failed: %v", err)
}
}

// Check which manifests were included in output
Expand Down