Commit Graph

20 Commits

Author SHA1 Message Date
Nic Cope a3a5f918ac Add managed resource finalizer immediately before creating
This commit moves where we set the finalizer for managed resources to right
before creating them, not at the beginning of the reconcile. This means we'll be
less likely to encounter issues where we can't delete a managed resource because
we could never create it in the first place, but we added a finalizer.

* By the time we get here we know our Observe call worked. If (for example) our
  cloud provider credentials were completely wrong, we'd never proceed far
  enough to add the finalizer.
* If Observe works but Create fails (for example because we had RO cloud
  provider credentials) we would already have added the finalizer, but...
* When the managed resource was deleted we'd be able to Observe that the
  external resource does not exist (because we were never able to Create it) and
  thus would not call Delete on the external resource and go straight to
  unpublishing credentials and removing the finalizer.

This commit also renames and refactors a bunch of our interfaces to use less
obtuse names. Previously sometimes a "finalize" method unbound a managed
resource, while at other times it removed the finalizer. Similarly, finalizers
were added in "initialize". We now have a 'Binder' interface with bind and
unbind methods, and two 'Finalizer' interfaces (one for Claim, and one for
Managed) that add and remove finalizers, as you would expect.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-01 15:48:09 -07:00
Nic Cope b01c234701 Don't attempt to update resource status after finalizer removal
This status update is only useful when:

* Some other controller also added a finalizer to this managed resource.
* The other controller has not yet processed the delete and removed its finalizer.

Given that this is a rare (or non-existent) edge case, and given that attempting
to update the status of a non-existent managed resource results in spurious
errors in the logs, I think it's safe to remove this logic.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-01 15:14:07 -07:00
Nic Cope 78e91b4b29 Don't trigger a requeue after a successful deletion
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-01 15:00:10 -07:00
Nic Cope bc04c33519 Resolve references on every reconcile
Reference resolution is now a no-op if nothing changes, so we run it on every
reconcile. We also run it after delete has been handled, so unresolved
references will only block creates and updates.

This commit means we'll make more get calls to the cache (or API) in order to
resolve our references each reconcile, and also risk potentially changing the
values of 'immutable' fields automatically if and when our references resources
change. I believe we should address this by having referencers be no-ops when
the field value they would set is already set.

I attempted to move reference resolution to right before we call create or
update (i.e. after observe and delete), but it turns out certain resources
(specifically GCP Connections) could need references to be resolved in order to
observe the external resource.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-31 16:11:10 -07:00
Nic Cope 5468d81383 Use real conditioned and binding statuses in mock objects
The mock binding status was identical to the real one, while the mock
conditioned status set only the most recent condition, leading to a few
slightly broken managed resource reconciler tests.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-31 13:27:40 -07:00
Nic Cope d5dadd4e74 Requeue after a short wait when references are not ready
the established convention is for the managed resource reconciler to requeue
after a short wait (typically 30 seconds) when it knows it is waiting for an
operation.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-31 13:27:30 -07:00
Nic Cope 4fbddd0d00 Clean up managed resource reconciler tests
No functional updates to the code here, just tidying up the tests a bit to
ensure they all mock out their various moving parts via options.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-31 12:35:28 -07:00
soorena776 f063ec82d3 - Removing class level reference resolution if we can get away with it
- Removing the panic recovery logic
- Removing the superfluous IsConditionReady method
- Adding Nic's unit-tests for GetCondition and IsConditionTrue
- Minor other fixes

Signed-off-by: soorena776 <javad@upbound.io>
2019-10-21 17:05:15 -07:00
soorena776 8df7f7cab7 Change ReferenceResolver signature to accept CanReference type instead of Managed
Signed-off-by: soorena776 <javad@upbound.io>
2019-10-21 16:39:26 -07:00
soorena776 2a086a07f6 Rename `ValidateReady` to `GetStatus` in `AttributeReferencer` interface, to show more granular information about the status of the referencers
Signed-off-by: soorena776 <javad@upbound.io>
2019-10-21 16:39:26 -07:00
soorena776 b09e1340b6 Adding RefereceResolver tests to managed_reconciler_test.go
Signed-off-by: soorena776 <javad@upbound.io>
2019-10-21 16:39:26 -07:00
muvaffak onus d72012f1c2 Use managed resource name as external name (#45)
* - Introduces Initializer hook to managed reconciler.
- ManagedNameAsExternalName is introduced and used
  by default by all managed reconcilers.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* GetExternalName and SetExternalName functions are implemented

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* - Unit tests for ManagedNameAsExternalName struct
- Move ExternalNameAnnotationKey into meta package.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* Remove Establisher mechanism and port existing
establisher to Initializer.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* Fix claim's external name annotation propagation to
the managed resource.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-10-15 10:23:05 -07:00
Nic Cope ab3cac0175 Don't update managed resources if we determine they're up to date
This allows us to determine whether an external resource needs updating inside
the Observe method, which must already get a fresh copy of the external resource
from the cloud provider API in order to determine whether it exists and update
the managed resource's status.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-09-05 01:10:10 -07:00
hasheddan 7d786e2dff runtime migration: strip apis and update dependencies
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-08-20 09:27:20 -05:00
hasheddan a72525edae kubebuilderv2: update core packages and tooling
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Co-authored-by: Jared Watts <jbw976@gmail.com>
Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
2019-08-13 17:39:59 -05:00
Muvaffak Onus ca248a6d0f - Added new unit tests to Managed Reconciler.
- Added unit tests for Managed Finalizer Remover & Adder types.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-08-01 09:05:23 +03:00
Muvaffak Onus f3905eef13 - Unnecessary comments are removed.
- WithLongWait and WithShortWait are used in tests.
- Some of cosmetic issues are fixed.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-07-31 09:26:14 +03:00
Muvaffak Onus 19daef9388 New tests for non-deletion scenarios added to Managed Reconciler.
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-07-30 14:35:57 +03:00
Muvaffak Onus 542990b820 - Elasticache managed reconciler Create call made idempotent to AlreadyExists error.
- Naming fixes.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-07-29 11:12:32 +03:00
Muvaffak Onus 94040da9f9 Managed Reconciler unit tests
- Tests for the interaction between Managed<>External resource.
- make reviewable fixes.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-07-26 18:15:06 +03:00