Commit Graph

64 Commits

Author SHA1 Message Date
Dr. Stefan Schimanski 8333c5c0bd
reconciler/managed: simplify conflict suppression with helper
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
2023-09-26 16:20:56 +02:00
lsviben 55a8c10930
gmp to beta
Signed-off-by: lsviben <sviben.lovro@gmail.com>
2023-09-20 11:46:19 +02:00
Samuel Littley 381948c05d Switch to supporting only a single PollIntervalHook
Signed-off-by: Samuel Littley <slittley@thoughtmachine.net>
2023-09-05 11:37:36 +01:00
Samuel Littley b1cc110def Define WithPollJitter in terms of a PollIntervalHook
Signed-off-by: Samuel Littley <slittley@thoughtmachine.net>
2023-09-04 16:53:29 +01:00
Samuel Littley e7a425b136 Add a hook for customising the poll interval
Signed-off-by: Samuel Littley <slittley@thoughtmachine.net>
2023-09-04 16:53:29 +01:00
Samuel Littley 7bf25e3e5a Add support for applying jitter when requeuing resources after reconcile
Signed-off-by: Samuel Littley <slittley@thoughtmachine.net>
2023-09-04 16:53:29 +01:00
Hasan Turken 11e9468944
Cleanup deprecated stuff that are no longer used
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-08-11 13:02:54 +03:00
Dr. Stefan Schimanski c1ae379705
reconciler/managed: only debug log transient conflict errors
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
2023-08-04 16:32:44 +02:00
lsviben 73a675c82c
implement granular managementPolicies
Signed-off-by: lsviben <sviben.lovro@gmail.com>
2023-07-13 13:43:34 +02:00
Philippe Scorsolini 511b39fa56
chore: address issues reported by revive
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2023-04-05 12:03:27 +02:00
Hasan Turken 0023964825
Resolve Comments in Observe Only PR
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-27 12:05:07 +03:00
Hasan Turken 473dc1e87a
Management Policies should be off by default
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-27 12:05:07 +03:00
Hasan Turken 743b93ca70
Do not late init when observe only
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-27 12:05:07 +03:00
Hasan Turken 2f4e4c0d9d
Lateinit and publish conn for observe only
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-27 12:05:06 +03:00
Hasan Turken 79cb4c8ac1
Add management policy to managed
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-27 12:05:06 +03:00
Nic Cope f0fcbc0af5 Update linter config to match c/c
This repo is a little out of date relative to our latest linting
practices.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:32:46 -08:00
Alper Rifat Ulucinar eaa6119f23
Add meta.IsPaused that checks whether reconciliations are paused for the managed resource
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2022-09-30 01:24:50 +03:00
Alper Rifat Ulucinar d5661c8fd6
Add support for a pause annotation which pauses reconciliations on managed resources
- If a managed resource has the "crossplane.io/paused" annotation with its value
  set to "true", then the managed reconciler emits an event indicating that
  further reconciliations on that resource are paused and returns early after
  setting a Synced status condition to false with the reason "ReconcilePaused".

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2022-09-29 04:27:29 +03:00
Hasan Turken 86fb15da2c
Extend Secret Store interface with more power
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-10 18:10:52 +03:00
Hasan Turken bbbe8f8c66
Return proper error if Secret Store disabled but API used
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 16:29:42 +03:00
Hasan Turken 3ce0d92570
Refactor packages for connection details types and interfaces
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 12:43:52 +03:00
Nic Cope 295de4764e Tweak ExternalDisconnecter implementation
The primary functional change here is to avoid setting a status condition when a
deferred disconnect fails. We don't want to overwrite the original status
condition that may have been written if we're returning from Reconcile because
we hit an error. Emitting an event and a debug log should be sufficient.

This commit also tweaks a bit of grammar and updates the NopConnectDisconnecter
implementation to more closely match its docstring description.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-12-02 22:37:02 +00:00
Nic Cope 5cc9857410
Merge pull request #296 from vaspahomov/feature/disconnect-in-reconcile
Add Disconnect call in Reconcile
2021-12-02 14:16:43 -08:00
vaspahomov a5ff67d5a0
remove named returns; disconnect error should not requeue reconcile
Signed-off-by: vaspahomov <vas2142553@gmail.com>
2021-10-28 15:25:12 +05:00
vaspahomov bf53464ca5
Add Disconnect call in Reconcile
Signed-off-by: vaspahomov <vas2142553@gmail.com>
2021-10-28 15:20:56 +05:00
Nic Cope ee4131e543 Plumb up reconciler contexts
I believe the Reconcile method started including a context in controller-runtime
v0.8.0, but it was never plumbed up. If I follow the contexts correctly the one
passed to Reconcile can be traced back to the one passed to mgr.Start, which is
typically a context that is cancelled on SIGTERM or SIGINT.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-10-14 00:36:16 +00:00
Muvaffak Onus d6c9f3e919
managed: make finalizer name string public so that it can be used in NewAPIFinalizer calls outside of package managed
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2021-09-30 00:27:45 +03:00
Nic Cope f1ff9b11b7 Set Creating and Deleting conditions close to Status().Update() calls
https://github.com/crossplane/crossplane-runtime/issues/285

This approach causes us to repeat ourselves a bit, but prevents issues like the
above, where refactoring caused us to accidentally overwrite a pending status
update that we hadn't committed.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-17 23:35:29 +00:00
Nic Cope af4e148a11 Replace github.com/pkg/errors with our own pkg/errors.
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-09 07:50:57 +00:00
Nic Cope 8e780ecd6d Don't rely on removal of the external-create-pending annotation
The retry logic we use to persist critical annotations makes it difficult to
delete an annotation without potentially also deleting annotations added by
another controller (e.g. the composition logic). This commit therefore changes
the way we detect whether we might have created an external resource but not
recorded the result. Previously we relied on the presence of the 'pending'
annotation to detect this state. Now we check whether the 'pending' annotation
is newer than any 'succeeded' or 'failed' annotation.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-03 04:41:00 +00:00
Nic Cope a3a59c95b6 Account for two different kinds of consistency issues
This commit is intended to address two issues that we diagnosed while
investigating https://github.com/crossplane/provider-aws/issues/802.

The first issue is that controller-runtime does not guarantee reads from cache
will return the freshest version of a resource. It's possible we could create an
external resource in one reconcile, then shortly after trigger another in which
it appears that the managed resource was never created because we didn't record
its external-name. This only affects the subset of managed resources with
non-deterministic external-names that are assigned during creation.

The second issue is that some external APIs are eventually consistent. A newly
created external resource may take some time before our ExternalClient's observe
call can confirm it exists. AWS EC2 is an example of one such API.

This commit attempts to address the first issue by making an Update to a managed
resource immediately before Create it called. This Update call will be rejected
by the API server if the managed resource we read from cache was not the latest
version.

It attempts to address the second issue by allowing managed resource controller
authors to configure an optional grace period that begins when an external
resource is successfully created. During this grace period we'll requeue and
keep waiting if Observe determines that the external resource doesn't exist,
rather than (re)creating it.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-01 06:04:31 +00:00
Alec Rajeev 5193d240d4 Improve name and log message
Signed-off-by: Alec Rajeev <alecinthecloud@gmail.com>
2021-07-13 20:16:39 -04:00
Alec Rajeev 4eb03bf865 Added verbose logging option when resource is updated
Signed-off-by: Alec Rajeev <alecinthecloud@gmail.com>
2021-07-11 21:27:21 -04:00
hasheddan f2418dc9cd
Remove redundant managed resource deletion policy check
Now that the managed reconciler will handle deletion with policy Orphan
early, there is no need to check that deletion policy is not orphan when
handling a managed resource with deletion timestamp set and external
resource exists.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:13 -05:00
hasheddan cf89dda36b
Set status to deleting even when external resource does not exist
Updates the status of managed resource to be set to deleting in the case
where an external resource does not exist, but we fail to unpublish
connection or remove finalizer.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:13 -05:00
hasheddan 426347c178
Skip external connect when deletion policy orphan
Modifies managed reconciler to skip attempting to connect to external
client as well as initialize and resolve references when managed
resource has deletion timestamp and deletion policy is orphan.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:11 -05:00
Nic Cope 824eb6919d Use OpenAPI to set the default ProviderConfig
This allows us to avoid an extra update call to the API server when new managed
resources are created.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-03-11 08:02:04 +00:00
cvodak1 279d86b6ac remove odd numbered key:value on debugs
Signed-off-by: cvodak1 <cvodak@ea.com>
2021-02-25 19:49:18 -06:00
Daniel Mangum 30a941c3c3
Merge pull request #243 from hasheddan/backoff
Make use of rate limiting in managed reconciler
2021-02-19 09:53:38 -06:00
hasheddan 598fa1fec9
Update managed reconciler comments with backoff
Updates comments in managed reconciler to indicate requeues are not tied
to short wait but instead are explicit and trigger the configured
backoff strategy.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-02-19 09:45:58 -06:00
hasheddan eba74050f8
Make use of controller rate limiter in managed reconciler
Updates managed reconciler to return Requeue: true instead of
RequeueAfter when encountering non-status update errors. This allows the
reconciler to make use of the controller rate limiter rather use a
constant value for requeuing after errors.

This also renames longWait to pollInterval to more accurately reflect
its behavior.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-02-16 09:15:43 -06:00
Muvaffak Onus 24edc02184
managed reconciler: set deleting and creating conditions before calling respective external functions
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2021-02-11 14:05:11 +03:00
Sascha Grunert 423918f457
Update controller runtime to v0.8.0
This updates the controller-runtime and all of its dependencies to the
latest release.

This includes a bunch of changes which break backwards compatibility
introduced by controller-runtime 0.7.0 and 0.8.0, for example:

> A number of methods that previously took runtime.Object & internally
> type-asserted them to metav1.Object now take client.Object (for non-list
> objects) or client.ObjectList (for lists). The practical upshot of this
> is more type-safety and clarity around what's required for particular
> methods.
> All concrete API types (anything that implements runtime.Object & has
> a metadata field) already implement client.Object or client.ObjectList,
> so practical impact should be limited to folks who pass around
> runtime.Object values instead of concrete types.

Signed-off-by: Sascha Grunert <mail@saschagrunert.de>
2021-01-21 13:29:16 +01:00
hasheddan 0b27607592
Update core/v1alpha1 imports to common/v1
Updates all core/v1alpha1 imports to the common/v1, which is the new
home of these embedded API types.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-11-19 20:03:48 -06:00
Muvaffak Onus 6b88ef0288
managed reconciler: add retry attempt for updating the resource whose external name is assigned during the Create call
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-11-17 00:56:09 +03:00
Nic Cope 378a57303e
Merge pull request #219 from negz/cleaninghouse
Remove several deprecated types
2020-10-19 12:35:07 -07:00
Nic Cope 7ebe7a94da Remove the deprecated first generation reference resolver
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-16 19:59:24 -07:00
Nic Cope 48f0c2018a Clarify the contract around late initalizing resources
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-15 14:56:06 -07:00
Nic Cope 2be0127c60 Update late initialized resources
A design goal of the managed.Reconciler implementation was to insulate folks who
are authoring an ExternalClient implementation from needing to interact with the
Kubernetes API directly. The separation of concerns is intended to be:

* ExternalClient accepts a managed resource struct and reconciles it with the
  provider. It may update the struct it is passed, but otherwise does not
  interact with the Kubernetes API.
* ExternalConnector interacts with the Kubernetes API in order to produce an
  ExternalClient.
* Reconciler orchestrates the ExternalConnector and ExternalClient, propagating
  updates from the ExeternalClient back to the Kubernetes API as necessary.

The desire to late initialize managed resources sullied this separation of
concern (or single responsibility) by plumbing a Kubernetes client down into the
ExternalClient implementations. I believe this was done because:

* We must update the resource spec before we update its status, or changes made
  to the status will be overwritten.
* We don't want to update the resource spec on every reconcile if it's possible
  to avoid doing so.

This small change to the managed resource reconciler allows an ExternalClient to
signal that it has late initialized a managed resource, and thus defer updating
that managed resource to the Reconciler. I believe this change is backward
compatible (ExternalClient implementations could continue to 'manually' late
initialize the resource and not return ResourceLateInitialized).

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-12 19:57:17 -07:00
Nic Cope 72119f63ba Explain the various managed reconciler return values
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-12 18:34:29 -07:00