-
Notifications
You must be signed in to change notification settings - Fork 621
CRD validation ratcheting: userInterface #4198
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
CRD validation ratcheting: userInterface #4198
Conversation
pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types_conversion.go
Outdated
Show resolved
Hide resolved
func TestPostgresClusterWebhooks(t *testing.T) { | ||
var _ webhook.Defaulter = new(PostgresCluster) | ||
} |
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.
I noticed in a Dependabot PR that this doesn't compile with newer controller-runtime:
golangci-lint: pkg/apis/postgres-operator.crunchydata.com/v1beta1/postgrescluster_types_test.go#L18
undefined: webhook.Defaulter (typecheck)
⛏️ What do you think of removing this now, in both apiVersions, as we're considering ratcheting over webhooks?
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.
I actually removed this file locally since we didn't make any changes, but now I'm waffling. Ah well, removing for now.
15f72a7
to
8c2ad0e
Compare
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.
📝 Missed some generated code.
LGTM. Please squash.
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Schemaless | ||
// +kubebuilder:validation:Type=object | ||
// +kubebuilder:validation:XValidation:rule="type(self) == null_type || self == oldSelf", message="DynamicConfiguration not available in v1, please use ..." |
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.
👍🏻 Ah! oldSelf
means no K8s ratcheting, and self == oldSelf
sounds similar to the built-in ratcheting.
// The PGBackRest field is incompatible with the PostgresCluster field: only one | ||
// data source can be used for pre-populating a new PostgreSQL cluster | ||
// +optional | ||
// +kubebuilder:validation:XValidation:rule="!has(self.repo.volume)", message="Only S3, GCS or Azure repos can be used as a pgBackRest data source.", fieldPath=".repo" |
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.
🤔 I wish there were a way to define these rules over multiple lines.
@@ -0,0 +1,740 @@ | |||
// Copyright 2021 - 2025 Crunchy Data Solutions, Inc. |
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.
🤔 Looks like the copy/re-use goes file-wise; that works for me. We can arrange things into smaller files if/as we find it necessary.
}, | ||
}, | ||
postgresVersion: 16, | ||
backups: { |
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.
🤔 I remember now that I tried turning backups
into a pointer so we could omit it in these tests, and it sent me down some long hole.
}, | ||
}, | ||
postgresVersion: 16, | ||
backups: { |
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.
🤔 🤔 I'll think about making it a pointer on the new struct!
assert.ErrorContains(t, cc.Update(ctx, v1base), | ||
"userInterface not available in v1") |
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.
👍🏻 I like this test!
- Add kubebuilder markers to v1beta1 to mark as storage version - Add v1 files for changed version (postgrescluster) - Add rule to disallow userInterface - Add v1 conversion test, runtime scheme - Add a helper for kube version tests - Remove ref to webhook in v1beta1 Issues: [PGO-2524]
8c2ad0e
to
b8b9d49
Compare
Checklist:
Type of Changes:
What is the current behavior (link to any open issues here)?
What is the new behavior (if this is a feature change)?
This lays the groundwork for a v1 of the CRD; with a conversion type of None and validation ratcheting to handle differences between versions.
Other Information:
Issues: [PGO-2524]