-
Notifications
You must be signed in to change notification settings - Fork 156
K8SPSMDB-1211: handle FULL CLUSTER CRASH
error during the restore
#1926
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
Open
pooknull
wants to merge
32
commits into
main
Choose a base branch
from
K8SPSMDB-1211
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e2b7e97
K8SPSMDB-1211: handle `FULL CLUSTER CRASH` error during the restore
pooknull 47073d9
Merge remote-tracking branch 'origin/main' into K8SPSMDB-1211
pooknull 49cc044
remove unused comment
pooknull 19de9e6
fix lint
pooknull 9bf2482
remove common reconciler
pooknull 879163f
fix
pooknull f87bcc8
fix unit-test
pooknull a566737
fix
pooknull 20e0558
Merge remote-tracking branch 'origin/main' into K8SPSMDB-1211
pooknull 35a2e22
fix manifests
pooknull 81186a8
fix tests
pooknull 2614d85
Merge branch 'main' into K8SPSMDB-1211
hors dc8663f
small fix
pooknull 0a442b9
Merge branch 'main' into K8SPSMDB-1211
pooknull b433511
add sleep
pooknull 81d2898
fix tests
pooknull 3cd0736
Merge branch 'main' into K8SPSMDB-1211
hors f9354c4
wait after adding resync annotation
pooknull 788505c
backoff wait after adding resync
pooknull 915ffc8
remove wait and fix tests
pooknull 9f69da2
Merge remote-tracking branch 'origin/main' into K8SPSMDB-1211
pooknull aaa227b
fix merge
pooknull 82c139f
fix manifests
pooknull 050f5ef
Merge remote-tracking branch 'origin/main' into K8SPSMDB-1211
pooknull ae459c2
fix merge
pooknull ced15a2
fix merge
pooknull 756aefe
fix arbiter
pooknull 6995236
Merge branch 'main' into K8SPSMDB-1211
pooknull fd8c741
Merge remote-tracking branch 'origin/main' into K8SPSMDB-1211
pooknull 3f6285a
remove commented code
pooknull 423d48d
fix lint
pooknull d4d89df
Merge branch 'main' into K8SPSMDB-1211
pooknull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
api "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1" | ||
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb" | ||
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/backup" | ||
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo" | ||
) | ||
|
||
func New(client client.Client, scheme *runtime.Scheme, newPBMFunc backup.NewPBMFunc, mongoClientProvider psmdb.MongoClientProvider) CommonReconciler { | ||
return CommonReconciler{ | ||
client: client, | ||
scheme: scheme, | ||
newPBMFunc: newPBMFunc, | ||
mongoClientProvider: mongoClientProvider, | ||
} | ||
} | ||
|
||
type CommonReconciler struct { | ||
client client.Client | ||
scheme *runtime.Scheme | ||
newPBMFunc backup.NewPBMFunc | ||
mongoClientProvider psmdb.MongoClientProvider | ||
} | ||
|
||
func (r *CommonReconciler) Client() client.Client { | ||
return r.client | ||
} | ||
|
||
func (r *CommonReconciler) Scheme() *runtime.Scheme { | ||
return r.scheme | ||
} | ||
|
||
func (r *CommonReconciler) NewPBM(ctx context.Context, cluster *api.PerconaServerMongoDB) (backup.PBM, error) { | ||
return r.newPBMFunc(ctx, r.client, cluster) | ||
} | ||
|
||
func (r *CommonReconciler) NewPBMFunc() backup.NewPBMFunc { | ||
return r.newPBMFunc | ||
} | ||
|
||
func (r *CommonReconciler) getMongoClientProvider() psmdb.MongoClientProvider { | ||
if r.mongoClientProvider == nil { | ||
return psmdb.NewProvider(r.client) | ||
} | ||
return r.mongoClientProvider | ||
} | ||
|
||
func (r *CommonReconciler) MongoClientWithRole(ctx context.Context, cr *api.PerconaServerMongoDB, rs *api.ReplsetSpec, role api.SystemUserRole) (mongo.Client, error) { | ||
return r.getMongoClientProvider().Mongo(ctx, cr, rs, role) | ||
} | ||
|
||
func (r *CommonReconciler) MongosClientWithRole(ctx context.Context, cr *api.PerconaServerMongoDB, role api.SystemUserRole) (mongo.Client, error) { | ||
return r.getMongoClientProvider().Mongos(ctx, cr, role) | ||
} | ||
|
||
func (r *CommonReconciler) StandaloneClientWithRole(ctx context.Context, cr *api.PerconaServerMongoDB, rs *api.ReplsetSpec, role api.SystemUserRole, pod corev1.Pod) (mongo.Client, error) { | ||
host, err := psmdb.MongoHost(ctx, r.client, cr, cr.Spec.ClusterServiceDNSMode, rs, rs.Expose.Enabled, pod) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to get mongo host") | ||
} | ||
return r.getMongoClientProvider().Standalone(ctx, cr, role, host, cr.TLSEnabled()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think packages named common, utils, etc., tend to be vague, as they imply shared logic without a clearly defined domain or separation of concerns.
In this file, the main struct is
CommonReconciler
, but it's not clear what exactly is being reconciled. The struct also mixes responsibilities: as it's constructing and returning heterogeneous components like backup.PBM, mongo.Client, a scheme, and a k8s client.To improve clarity and maintainability, I'd suggest:
Keeping the scheme and the Kubernetes client in
ReconcilePerconaServerMongoDB
, and having related function with receivers of typeReconcilePerconaServerMongoDB
.Splitting out PBM-related logic into a dedicated PBM factory/service.
Doing the same for the MongoClientProvider.
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.
9bf2482