Skip to content
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

build: don't minimize CRD for WorkflowEventBinding and WorkflowArtifactGCTask. Fixes #12166 #13754

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion hack/manifests/crdgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ find manifests/base/crds/full -name 'argoproj.io*.yaml' | while read -r file; do
minimal="manifests/base/crds/minimal/$(basename "$file")"
echo "Creating minimal CRD file: ${minimal}"
cp "$file" "$minimal"
go run ./hack/manifests removecrdvalidation "$minimal"
go run ./hack/manifests minimizecrd "$minimal"
done
32 changes: 23 additions & 9 deletions hack/manifests/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func cleanCRD(filename string) {
}
}

func removeCRDValidation(filename string) {
// minimizeCRD is a workaround for https://github.com/kubernetes/kubernetes/issues/82292 that strips out large fields from CRDs.
// Without this, deploying the CRDs under ./manifests/base/crds/minimal/ will lead to the error "Request entity too large: limit is 3145728"
func minimizeCRD(filename string) {
data, err := os.ReadFile(filepath.Clean(filename))
if err != nil {
panic(err)
Expand All @@ -56,15 +58,13 @@ func removeCRDValidation(filename string) {
if err != nil {
panic(err)
}
spec := crd["spec"].(obj)
versions := spec["versions"].([]interface{})
version := versions[0].(obj)
properties := version["schema"].(obj)["openAPIV3Schema"].(obj)["properties"].(obj)
for k := range properties {
if k == "spec" || k == "status" {
properties[k] = obj{"type": "object", "x-kubernetes-preserve-unknown-fields": true, "x-kubernetes-map-type": "atomic"}
}
name := crd["metadata"].(obj)["name"].(string)
switch name {
// Only minimize CRDs that are too large
case "cronworkflows.argoproj.io", "clusterworkflowtemplates.argoproj.io", "workflows.argoproj.io", "workflowtemplates.argoproj.io", "workflowtasksets.argoproj.io":
crd = stripSpecAndStatusFields(crd)
}

data, err = yaml.Marshal(crd)
if err != nil {
panic(err)
Expand All @@ -74,3 +74,17 @@ func removeCRDValidation(filename string) {
panic(err)
}
}

// stripSpecAndStatusFields strips the "spec" and "status" fields from the CRD, as those are usually the largest.
func stripSpecAndStatusFields(crd obj) obj {
spec := crd["spec"].(obj)
versions := spec["versions"].([]interface{})
version := versions[0].(obj)
properties := version["schema"].(obj)["openAPIV3Schema"].(obj)["properties"].(obj)
for k := range properties {
if k == "spec" || k == "status" {
properties[k] = obj{"type": "object", "x-kubernetes-preserve-unknown-fields": true, "x-kubernetes-map-type": "atomic"}
}
}
return crd
}
4 changes: 2 additions & 2 deletions hack/manifests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ func main() {
switch os.Args[1] {
case "cleancrd":
cleanCRD(os.Args[2])
case "removecrdvalidation":
removeCRDValidation(os.Args[2])
case "minimizecrd":
minimizeCRD(os.Args[2])
default:
panic(os.Args[1])
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/base/crds/full/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Full CRDs

These CRDs have full schema validation. As a result, they are large and probably not suitable to be used in your cluster.
These CRDs have the full schema. As a result, they are large and probably not suitable to be used in your cluster.
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion manifests/base/crds/minimal/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Minimal CRDs

These CRDs omit schema validation.
These CRDs omit large fields as a workaround for [Large CRDs go over size limits (e.g. those with embedded podspecs)](https://github.com/kubernetes/kubernetes/issues/82292).
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading