Skip to content

Avoid non-requeue for MRs with determinstic external names.#841

Merged
negz merged 6 commits intocrossplane:mainfrom
nolancon:requeue-deterministic-mr-if-pending
Jun 9, 2025
Merged

Avoid non-requeue for MRs with determinstic external names.#841
negz merged 6 commits intocrossplane:mainfrom
nolancon:requeue-deterministic-mr-if-pending

Conversation

@nolancon
Copy link
Contributor

@nolancon nolancon commented May 28, 2025

Description of your changes

  • Add a new Annotation crossplane.io/external-name-is-deterministic WithDeterministicExternalName reconciler option which allows the user to declare that a given resource is deterministically named by the external system.
  • For MRs which are deterministically named, ignore the safeguard against leaked resources.

These changes enables the user to essentially "opt-out" of the current behaviour which blocks re-queuing of MRs in a scenario where creation is deemed incomplete. This safeguard is perfectly justified for MRs which are given non-deterministic names by the external system, preventing leaked resources (this scenario is described in detail here).

However, for resources which are deterministically named by the external system, the decision to not re-queue the MR is unnecessary as these resources are not in danger of leaking. For instance, provider-ceph creates S3 buckets by reconciling Bucket MRs - these s3 buckets are deterministically named and created idempotently. Therefore there is no danger in re-queuing after an initial "incomplete creation" failure (in fact it is expected). This kind of failure can (and does) happen regularly and in a system with 1000s of buckets leads to dozens of MRs which are not re-queued and therefore left in this pending state requiring manual intervention.

I have tested this patched version of the runtime against provider ceph. More details can be seen on this demo PR demo PR which also contains details on the existing workaround we use to attempt to mitigate the above scenario (but this is only best-effort and does not eradicate the problem completely).

Also, I'm happy to open a docs PR on this but would like to get feedback on this approach first, thanks.

Fixes #
#340 (maybe not fixes, but allows an "opt-out")

I have:

Need help with this checklist? See the cheat sheet.

nolancon added 2 commits May 28, 2025 10:13
Signed-off-by: nolancon <cmsnolan@gmail.com>
Signed-off-by: nolancon <cmsnolan@gmail.com>
@nolancon nolancon force-pushed the requeue-deterministic-mr-if-pending branch from 873d166 to 604c58f Compare May 28, 2025 10:14
@nolancon nolancon marked this pull request as ready for review May 28, 2025 10:16
@nolancon nolancon requested a review from a team as a code owner May 28, 2025 10:16
@nolancon nolancon requested a review from negz May 28, 2025 10:16
@negz
Copy link
Member

negz commented Jun 6, 2025

Thanks for taking a shot at this! I was thinking about something similar.

Could this be configured at the entire-type level though? I assume the if one kind: Widget has a deterministic external name, that'll be true for all kind: Widget resources, right? Ideally you wouldn't need to add this annotation to all of them.

Configuring this at the type level feels like the right way to go, but it's harder. It seems like a good use for the ManagedResourceDefinition type proposed in crossplane/crossplane#2262.

@negz
Copy link
Member

negz commented Jun 6, 2025

Actually I guess this could just be handled at the code level via a new option to the MR reconciler. That'd mean provider authors would need to adopt it rather than being something end-users could specify though.

@nolancon
Copy link
Contributor Author

nolancon commented Jun 6, 2025

Hi @negz, thanks for taking a look.

Could this be configured at the entire-type level though? I assume the if one kind: Widget has a deterministic external name, that'll be true for all kind: Widget resources, right? Ideally you wouldn't need to add this annotation to all of them.

Yes to both. The annotation approach is suitable for our use case because MRs are never really created by our users. They are created by a separate piece of software that interprets the user's "create" request. So adding the annotation will never be the burden of the user, instead it's just an extra line of code when we create the MR on the user's behalf (by machine - hence the annotation instead of a label). But I can appreciate this may not be the case for other providers.

Actually I guess this could just be handled at the code level via a new option to the MR reconciler. That'd mean provider authors would need to adopt it rather than being something end-users could specify though.

I like this approach and it had crossed my mind also, but I felt like using an annotation was less disruptive. However, reflecting on the above, maybe this would be a happy medium as it solves the problem and also removes the burden of adding annotations for end users.

nolancon added 3 commits June 6, 2025 11:37
This reverts commit 604c58f.

Signed-off-by: nolancon <cmsnolan@gmail.com>
This reverts commit fb7b837.

Signed-off-by: nolancon <cmsnolan@gmail.com>
Signed-off-by: nolancon <cmsnolan@gmail.com>
@nolancon
Copy link
Contributor Author

nolancon commented Jun 6, 2025

@negz I reverted the earlier changes and added a new commit with the ReconcilerOption approach to make the diff more readable. Here is an example PR for how this can be implemented by a downstream provider linode/provider-ceph#333

Copy link
Member

@negz negz left a comment

Choose a reason for hiding this comment

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

One suggestion but this LGTM. Thank you!

Signed-off-by: nolancon <cmsnolan@gmail.com>
@negz negz self-assigned this Jun 9, 2025
@negz negz merged commit 2b288ff into crossplane:main Jun 9, 2025
10 checks passed
@jbw976 jbw976 moved this to Done in Crossplane Roadmap Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants