-
Notifications
You must be signed in to change notification settings - Fork 78
K8SPG-777 Fix the crash in ShouldCheckStandbyLag #1652
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?
Changes from all commits
0e52d77
ed73169
e9b2244
4901a83
4199c53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ type PerconaPGCluster struct { | |
| } | ||
|
|
||
| // +kubebuilder:validation:XValidation:rule="!has(self.users) || self.postgresVersion >= 15 || self.users.all(u, !has(u.grantPublicSchemaAccess) || !u.grantPublicSchemaAccess)",message="PostgresVersion must be >= 15 if grantPublicSchemaAccess exists and is true" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.crVersion) || self.crVersion == \"\" || self.crVersion.matches('^[0-9]+\\\\.[0-9]+\\\\.[0-9]+(-[a-zA-Z0-9.+-]+)?$')",message="CRVersion must be a valid semantic version" | ||
| type PerconaPGClusterSpec struct { | ||
| // +optional | ||
| Metadata *crunchyv1beta1.Metadata `json:"metadata,omitempty"` | ||
|
|
@@ -505,7 +506,11 @@ func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crun | |
| } | ||
|
|
||
| func (cr *PerconaPGCluster) Version() *gover.Version { | ||
| return gover.Must(gover.NewVersion(cr.Spec.CRVersion)) | ||
| crVersion := cr.Spec.CRVersion | ||
| if crVersion == "" { | ||
| crVersion = version.Version() | ||
| } | ||
| return gover.Must(gover.NewVersion(crVersion)) | ||
|
Comment on lines
+509
to
+513
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this only falls back with the assumption that the opeator will reconcile the cluster and set the version asynchronously. Falling back to version.Version() on non empty can introduce hard to find bugs. But a way to do it, would actually be a validation pattern on the CRD
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i agree |
||
| } | ||
|
|
||
| func (cr *PerconaPGCluster) CompareVersion(ver string) int { | ||
|
|
||
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.
This test case would only work on e2e tests
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.
we don't need to test ShouldCheckStandbyLag regression but it'd be great to add a simple unit test that covers
PerconaPGCluster.Version()behavior