-
Notifications
You must be signed in to change notification settings - Fork 64
K8SPG-777 set crVersion #1210
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
K8SPG-777 set crVersion #1210
Changes from 2 commits
031aea7
299de12
0e53193
3bb786b
f770dbf
bf07684
dc3710c
0b8a9b0
14adbc9
a788b0a
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 | ||
---|---|---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |||
"fmt" | ||||
"io" | ||||
"reflect" | ||||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||||
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. [goimports-reviser] reported by reviewdog 🐶
Suggested change
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 think the importing order here is wrong as correctly the linter complains. Also the alias for the import is not needed at all. We can drop it. 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. Please have a look on this: #1210 (comment) |
||||
"slices" | ||||
"strings" | ||||
"time" | ||||
|
@@ -49,6 +50,7 @@ import ( | |||
"github.com/percona/percona-postgresql-operator/percona/pmm" | ||||
perconaPG "github.com/percona/percona-postgresql-operator/percona/postgres" | ||||
"github.com/percona/percona-postgresql-operator/percona/utils/registry" | ||||
"github.com/percona/percona-postgresql-operator/percona/version" | ||||
"github.com/percona/percona-postgresql-operator/percona/watcher" | ||||
v2 "github.com/percona/percona-postgresql-operator/pkg/apis/pgv2.percona.com/v2" | ||||
"github.com/percona/percona-postgresql-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1" | ||||
|
@@ -201,6 +203,9 @@ func (r *PGClusterReconciler) Reconcile(ctx context.Context, request reconcile.R | |||
return ctrl.Result{}, errors.Wrap(err, "get PerconaPGCluster") | ||||
} | ||||
|
||||
if err := r.setCRVersion(ctx, cr); err != nil { | ||||
return reconcile.Result{}, errors.Wrap(err, "set CR version") | ||||
} | ||||
cr.Default() | ||||
|
||||
if cr.Spec.OpenShift == nil { | ||||
|
@@ -964,3 +969,20 @@ func (r *PGClusterReconciler) ensureFinalizers(ctx context.Context, cr *v2.Perco | |||
|
||||
return nil | ||||
} | ||||
|
||||
func (r *PGClusterReconciler) setCRVersion(ctx context.Context, cr *v2.PerconaPGCluster) error { | ||||
if len(cr.Spec.CRVersion) > 0 { | ||||
return nil | ||||
} | ||||
|
||||
orig := cr.DeepCopy() | ||||
cr.Spec.CRVersion = version.Version() | ||||
|
||||
if err := r.Client.Patch(ctx, cr, client.MergeFrom(orig)); err != nil { | ||||
return errors.Wrap(err, "patch CR") | ||||
} | ||||
|
||||
logf.FromContext(ctx).Info("Set CR version", "version", cr.Spec.CRVersion) | ||||
|
||||
return nil | ||||
} |
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.
Can I use 2.6.0 with this CRD?
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.
yes, it was like en example.
how can we make it better?
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.
ok, please check this test https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pg-operator/PR-1210/bf0768457/upgrade-consistency.log
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.
fixed.