-
Notifications
You must be signed in to change notification settings - Fork 631
Add a Make target that runs crd-schema-checker #4288
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
base: main
Are you sure you want to change the base?
Conversation
Makefile
Outdated
define NL | ||
|
||
|
||
endef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining a newline? Does the awk
on l. 156 need a newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
Defining a newline?
Yeah, this is a Make variable that contains one newline.
Does the
awk
on l. 156 need a newline?
Without the newline, Make prints all the go run
commands at once, then four outputs from the tool come out. With this, each command and its output are separated like this:
go run github.com/openshift/crd-schema-checker/cmd/crd-schema-checker@latest check-manifests --new-crd-filename 'config/crd/bases/postgresoperator.crunchydata.com_crunchybridgeclusters.yaml' 2>&1 | awk -f hack/check-manifests.awk
##
## wall of log lines
##
go run github.com/openshift/crd-schema-checker/cmd/crd-schema-checker@latest check-manifests --new-crd-filename 'config/crd/bases/postgres-operator.crunchydata.com_pgadmins.yaml' 2>&1 | awk -f hack/check-manifests.awk
##
## wall of log lines
##
go run github.com/openshift/crd-schema-checker/cmd/crd-schema-checker@latest check-manifests --new-crd-filename 'config/crd/bases/postgres-operator.crunchydata.com_pgupgrades.yaml' 2>&1 | awk -f hack/check-manifests.awk
##
## wall of log lines
##
go run github.com/openshift/crd-schema-checker/cmd/crd-schema-checker@latest check-manifests --new-crd-filename 'config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml' 2>&1 | awk -f hack/check-manifests.awk
##
## wall of log lines
##
🤔 What's a better way to present / read this stuff?
@@ -1307,6 +1307,7 @@ spec: | |||
type: object | |||
type: object | |||
type: array | |||
x-kubernetes-list-type: atomic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are all these lists getting flagged for atomic? Is that the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are all these lists getting flagged for atomic?
Because the destination for these values is an atomic list in Kubernetes; https://pkg.go.dev/k8s.io/api/core/v1#PodSpec.Tolerations
// If specified, the pod's tolerations.
// +optional
// +listType=atomic
Tolerations [][Toleration](https://pkg.go.dev/k8s.io/api/core/v1#Toleration)
Is that the default?
Not the way I think you're asking, but also yes, that's my understanding.
https://docs.k8s.io/reference/using-api/server-side-apply#custom-resources-and-server-side-apply
By default, Server-Side Apply treats custom resources as unstructured data. All keys are treated the same as struct fields, and all lists are considered atomic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are all these lists getting flagged for atomic?
I've added the +listType=atomic
marker to our Go structs in /pkg
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blockers
This tool estimates the total and relative cost of CEL validation rules. See: https://github.com/openshift/crd-schema-checker
The "ListsMustHaveSSATags" checker identifies this issue. This change is backward compatible because unmarked lists are atomic. See: https://docs.k8s.io/reference/using-api/server-side-apply#custom-resources-and-server-side-apply
The "ListsMustHaveSSATags" checker identifies this issue. This change is backward compatible because unmarked lists are atomic. See: https://docs.k8s.io/reference/using-api/server-side-apply#custom-resources-and-server-side-apply
Just thinking aloud here, but this make target isn't wired up to any other make target, so we might want to write / think about some guidance about when to use it. It's not just for checking CEL rule budget, yeah? |
4ca0d19
to
b5ab008
Compare
I don't understand the tool enough to give any guidance, really. I used it to check CEL budgets, but I have no idea how accurate that was (or if accuracy even matters). When we understand the tool better, we can configure it and wire it up as a blocking check.
|
Checklist:
This tool helped me understand the cost of CEL validation rules as I was writing them. The second and third commits are optional; I followed some of the recommendations emitted by the tool.
The output for PGUpgrades looks like this: