Skip to content

Conversation

@mclasmeier
Copy link
Contributor

@mclasmeier mclasmeier commented Nov 17, 2025

Implements a conflict resolution strategy for use in rhacs-operator.
Can be reviewed commit by commit.

@mclasmeier mclasmeier changed the title Implement aggressive conflict resolution ROX-31829: Implement aggressive conflict resolution Nov 17, 2025
@mclasmeier mclasmeier marked this pull request as ready for review November 17, 2025 20:32
Copy link
Collaborator

@porridge porridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK in general, some comments inline.
Also, the custom predicates bit should probably be a separate PR for ease of upstreaming later?

@mclasmeier
Copy link
Contributor Author

The WithPredicate change is now in #65.

@mclasmeier
Copy link
Contributor Author

@porridge Hope I have addressed everything. Thank you!
Did a rebase on latest main branch.

Copy link
Collaborator

@porridge porridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and comments inline.

// This is a safety measure to ensure that the chart is fully uninstalled before the CR is deleted.
if obj.GetDeletionTimestamp() == nil && !controllerutil.ContainsFinalizer(obj, uninstallFinalizer) {
log.V(1).Info("Adding uninstall finalizer.")
patch := client.MergeFrom(obj.DeepCopy())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the doc for MergeFrom, it seems like we want to use strategic merge patch for the list that finalizers is, no? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Agreed, there was a race, thanks for noticing.
  2. StrategicMergePatch() unfortunately doesn't fix it. I think this has to do with the fact that the finalizers list has no merge strategy associated. It would still just replace -- I tested this with a test using an interceptor to modify an object during a Get() call while still returning the old one.
  3. I think a JSON merge patch might do the trick here, but thinking about this again, I think we can refrain from complicating this piece of code for two reasons:
    3a. The reconciler code as it is now is not expecting any other finalizers to be in the picture, it's deliberately replacing them with SetFinalizers() anyway.
    3b. Even if there was a conflict here, I think this is one of the few situations where we could keep failing with a conflict error, because it happens right at the beginning of the reconciliation, before any heave Helm work is being done. And also because this is not something that should happen frequently -- it is, as far as I can tell, not expected that users fiddle around with the finalizers of a helm-operator-managed CR.

In any case, modifying this behavior seems to be independent of this specific feature.

Hence, I have reverted this change so that we have the old behavior.

Moritz Clasmeier and others added 2 commits November 21, 2025 10:21
@mclasmeier mclasmeier requested a review from porridge November 21, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants