Skip to content
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

feat(reconciler): Shared reconciliation loop logic for controllers #623

Merged
merged 77 commits into from
Oct 16, 2024

Conversation

abhijith-darshan
Copy link
Contributor

@abhijith-darshan abhijith-darshan commented Oct 7, 2024

Description

Implements a shared Reconcile functionality that can be adopted by all controllers to have standard base reconciliation loop.

  • Handles Adding, Removing common finalizer greenhouse.sap/cleanup and removes the need for individual finalizers for each resource
  • Splits the events into EnsureCreated and EnsureDeleted
  • Implements standard Deletion condition to check if resource has been deleted to allow garbage collection
  • Stores original resource before modification into ctx
  • Does a status patch by merging the changes done to the object during reconciliation (Addition / Modification of status fields) from original object (old). This prevents resource generation from changing and can be used in Controller Mgr WithEventFilter to avoid duplicate reconciliation
  • Implements default conditions for create state if a specific status func is not passed to Reconcile

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Added to documentation?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

reconcile context stores the original resource that is being reconciled intact to patch status at a later point in time.
helper methods to add, remove finalizers to check and set status conditions
common reconcile interface to standardize reconciliation for all greenhouse controllers
@abhijith-darshan abhijith-darshan self-assigned this Oct 7, 2024
@github-actions github-actions bot added documentation Improvements or additions to documentation feature core-apis labels Oct 7, 2024
Copy link
Contributor

@IvoGoman IvoGoman left a comment

Choose a reason for hiding this comment

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

This looks good and will make the controllers more readable/ better to maintain, also for new ones.

pkg/lifecycle/reconcile.go Outdated Show resolved Hide resolved
pkg/lifecycle/reconcile.go Outdated Show resolved Hide resolved
pkg/lifecycle/utils.go Outdated Show resolved Hide resolved
pkg/lifecycle/utils.go Outdated Show resolved Hide resolved
pkg/lifecycle/utils.go Outdated Show resolved Hide resolved
pkg/lifecycle/reconcile.go Outdated Show resolved Hide resolved
implements a strategy to update the status of the resource with conditions at a later point in time
@abhijith-darshan abhijith-darshan merged commit bb57e12 into main Oct 16, 2024
@abhijith-darshan abhijith-darshan deleted the feat/reconcile_standardization branch October 16, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-apis dependencies documentation Improvements or additions to documentation feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] - Standardized reconciliation loop logic for controllers
3 participants