-
Notifications
You must be signed in to change notification settings - Fork 195
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
K8SPXC-1509: Fix reconciler error when PiTR enabled #1879
Changes from all commits
56d9024
a92b87c
357575d
17d12b2
571c7b9
ba854da
c3439e3
6647ff7
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,46 @@ | ||||||||||||||||||||
package pxc | ||||||||||||||||||||
|
||||||||||||||||||||
import ( | ||||||||||||||||||||
"context" | ||||||||||||||||||||
|
||||||||||||||||||||
"github.com/pkg/errors" | ||||||||||||||||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||||||||||||||||||||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||||||||||||||||||||
|
||||||||||||||||||||
api "github.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1" | ||||||||||||||||||||
"github.com/percona/percona-xtradb-cluster-operator/pkg/k8s" | ||||||||||||||||||||
"github.com/percona/percona-xtradb-cluster-operator/pkg/pxc/app/deployment" | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
func (r *ReconcilePerconaXtraDBCluster) reconcileBinlogCollector(ctx context.Context, cr *api.PerconaXtraDBCluster) error { | ||||||||||||||||||||
log := logf.FromContext(ctx) | ||||||||||||||||||||
|
||||||||||||||||||||
initImage, err := k8s.GetInitImage(ctx, cr, r.client) | ||||||||||||||||||||
if err != nil { | ||||||||||||||||||||
return errors.Wrap(err, "failed to get init image") | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
binlogCollector, err := deployment.GetBinlogCollectorDeployment(cr, initImage) | ||||||||||||||||||||
if err != nil { | ||||||||||||||||||||
return errors.Wrapf(err, "get binlog collector deployment for cluster '%s'", cr.Name) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
err = setControllerReference(cr, &binlogCollector, r.scheme) | ||||||||||||||||||||
if err != nil { | ||||||||||||||||||||
return errors.Wrapf(err, "set controller reference for binlog collector deployment '%s'", binlogCollector.Name) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
res, err := controllerutil.CreateOrUpdate(ctx, r.client, &binlogCollector, func() error { return nil }) | ||||||||||||||||||||
if err != nil { | ||||||||||||||||||||
return errors.Wrap(err, "create or update binlog collector") | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
switch res { | ||||||||||||||||||||
case controllerutil.OperationResultCreated: | ||||||||||||||||||||
log.Info("Created binlog collector", "name", binlogCollector.Name) | ||||||||||||||||||||
case controllerutil.OperationResultUpdated: | ||||||||||||||||||||
log.Info("Updated binlog collector", "name", binlogCollector.Name) | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+38
to
+43
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. Why don't we 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. we can do something like this, but i prefer the current version tbh
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
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.
Discussed with @egegunes that if can also add a unit test for the controller if we have some time
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 spend some time on this but binlog collector is only reconciled after cluster is ready and unfortunately on envtest we have no means to make cluster ready
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.
alright thanks for checking this