-
Notifications
You must be signed in to change notification settings - Fork 106
CLOUDP-358677: Add Flex e2e2 test #3036
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?
Conversation
|
test is not passing yet, needs debugging |
a5365e1 to
5ccbafc
Compare
3521cd0 to
3f91d2a
Compare
|
Something is still wrong with this, I will debug further |
a61fab2 to
8d103f4
Compare
8d103f4 to
40d30d0
Compare
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
40d30d0 to
559a636
Compare
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
559a636 to
64f0fcf
Compare
| // If Group is not found but we have group ID in status, use it to proceed with deletion. | ||
| var statusErr *apierrors.StatusError | ||
| if errors.As(err, &statusErr) && apierrors.IsNotFound(statusErr) { | ||
| if group := h.getMinimalGroupFromStatusOrSpec(flexcluster); group != 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.
This is doable in this case but not all objects have Group IDs (i.e. DatabaseUsers). I rather suggest blocking deletion of the Group in the group reconciler in the first place:
func (h *Handlerv20250312) HandleDeletionRequested(ctx context.Context, group *akov2generated.Group) (ctrlstate.Result, error) {
var dependents []reconcile.Request
dependents = append(dependents, indexers.NewFlexClusterByGroupMapFunc(h.kubeClient)(ctx, group)...)
dependents = append(dependents, indexers.NewDatabaseUserByGroupMapFunc(h.kubeClient)(ctx, group)...)
dependents = append(dependents, indexers.NewClusterByGroupMapFunc(h.kubeClient)(ctx, group)...)
if len(dependends) > 0 {
return result.NextState(state.StateDeletionRequested, fmt.Sprintf("failed to delete group because %v resources depend on it.", len(dependents)))
}
if customresource.IsResourcePolicyKeepOrDefault(group, h.deletionProtection) {
return result.NextState(state.StateDeleted, "Group deleted.")
}
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.
The good news is that we have the mapping functions auto-generated already!
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 just tried the above code and it works nicely. I first:
- Tried to delete the group. This blocks because a
Cluster, aFlexCluster, and aDatabaseUserdepend on it:
- Deleted the
Cluster, aFlexCluster, and aDatabaseUser. In the meantime the count of dependend resources went down:
- Finally the deletion in Atlas was initiated and executed:
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.
side note: this is a pretty canonical use of indexes in the combination with finalizers (in our case nicely gated via the universal state machine)
s-urbaniak
left a comment
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 rather suggest blocking the group vs. having smartness in the reconciler as not all resources have a groupId in their status, i.e. DatabaseUsers
Summary
Add a e2e2 test for Flex Clusters.
Proof of Work
Tested locally.
Checklist