K8SPSMDB-1466 improve MCS error handling to prevent operator crashes #2044
+64
−2
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.
CHANGE DESCRIPTION
Description
This PR fixes the issue where the Percona Server MongoDB Operator would crash when encountering errors during Multi-Cluster Services (MCS) discovery, specifically the "stale GroupVersion discovery" error.
Problem
The operator was crashing with the following error:
This occurred in the MCS registration process when
dc.ServerPreferredResources()
failed, causing the entire operator pod to crash and restart.Solution
Register()
function inpkg/mcs/register.go
to handle any discovery error gracefullyNew Unit Tests in
pkg/mcs/register_test.go
TestIsAvailable()
: Tests MCS availability statusTestMCSSchemeGroupVersion()
: Tests scheme group version initializationTestServiceExport()
: Tests ServiceExport object creationTestServiceExportList()
: Tests ServiceExportList object creationBenefits
Testing
Type of Change
Checklist
Related Issues
Fixes the operator crash issue when MCS discovery fails with "stale GroupVersion discovery" error.
Additional Notes
This fix ensures that MCS (Multi-Cluster Services) is treated as an optional feature. When MCS discovery fails for any reason, the operator gracefully marks MCS as unavailable and continues with normal MongoDB cluster operations. This makes the operator more resilient and prevents unnecessary pod restarts.