Commit Graph

46 Commits

Author SHA1 Message Date
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
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
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
Nic Cope 95d71dbd91 Remove support for resource claims and classes
See https://github.com/crossplane/crossplane/issues/1670 for context.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-09-20 17:46:06 -07:00
hasheddan 2274effb45
Update with desired object in APIUpdatingApplicator
This modifies the behavior of the APIUpdatingApplicator to update with
the desired object by setting its resource version to that of the
current. This ensures that a successful update will result in the object
being modified to match the desired by default. Consumers of this
Applicator no longer are required to pass in an UpdateFn to avoid no-op
updates.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-03 22:37:14 -05:00
hasheddan 3420b651d6
Update with object that is gotten in APIUpdatingApplicator
This changes APIUpdatingApplicator to make its Update call
with the object it gets rather than the one passed so that
the default behavior is a no-op rather than a guaranteed
error on mismatched resource versions.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-05-12 15:15:27 -05:00
Nic Cope 70b21471b6 Add a generic ConnectionPropagator
This is effectively identical to the existing ManagedConnectionPropagator, but
propagates from any ConnectionSecretOwner, rather than requiring the much larger
and more specific Managed interface. This allows this propagator to be used to
propagate from managed resources to claims and also from composite resources to
requirements.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 13:04:38 -07:00
Muvaffak Onus fbeeb71921
Make APIFinalizer interface compatible with all Kubernetes resources
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-13 17:02:04 +03:00
Nic Cope cf8d3a6a26 Make connection secret propagation UID-agnostic
This allows propagation to function even when the propagating and/or propagated
secrets have been deleted and recreated, and thus allocated new UIDs.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-05 15:16:25 -07:00
Nic Cope b8b606426d Introduce an updating Applicator
This is roughly the same functionality as controllerutil.CreateOrUpdate, albeit
a little simpler. This variant is useful to us because it satisfies our
Applicator interface.

The key difference between the patching and updating applicators is that the
patching applicator will leave any existing, unset fields untouched (to the
extent that a JSON merge patch allows), while the updating applicator will
always update any existing object to exactly match the desired object.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-02 14:28:38 -07:00
Nic Cope ee9b68e00c Introduce a distinct secret type for connection secrets
This allows resource claims and managed resources to adopt existing orphaned
connection secrets without needing to be concerned with the fact that they
might be adopting an existing secret that is unrelated to Crossplane.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-02 14:28:38 -07:00
Nic Cope 51d293df2f Don't require callers to pass a client.Client to Applicator implementations
The Apply method of the resource.Applicator interface took a client.Client
largely because it was extracted from the pre-existing resource.Apply function
to allow pluggable Apply implementations. Now that we have types that satisfy
resource.Applicator it makes more sense for those types to include a client,
rather than being passed one for every Apply call.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-01 18:23:17 -07:00
hasheddan 16aa98bd07 Update go mod and refs with crossplane org name
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-02-18 18:17:32 -06:00
Nic Cope 034c58db2c Break reconcilers out into distinct packages
I'm hoping this will help us pass in loggers and eventers using variadic options
without awkward names like WithClaimBindingReconcilerLogger. This is a huge diff
but there's no functional changes - only moving things around and renaming them.

I was hoping we'd be able to do with without a breaking API change by using type
aliases, but doing so would create cyclic imports, because the new reconciler
packages depend on the resource package, which is where we'd need to create the
type alias to the reconciler packages.

I've broken up api.go (which contained most of the 'Kubernetes API' - i.e.
default - implementations of most of the pluggable interfaces used by our
reconcilers) into several files. My heuristic here was:

* If the implementation is used by a single reconciler, put it in that
  reconciler's package.
* If the implementation is used by more than one reconciler, put it in the
  resource package.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-01-14 19:52:53 -08:00
Daniel Mangum d5c9dedd2a secret reconciler: allow for propagation to multiple secrets (#92)
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-01-06 16:51:27 -05:00
Muvaffak Onus 5a3ce4f6c8
Removed Mock word from mocks in package fake.
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-12-12 15:02:06 +03:00
Muvaffak Onus 3cf4bd1275
Move MockManager into fake package
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-12-11 16:06:14 +03:00
Muvaffak Onus 81a7488824
Make mock of our interfaces available to be used out of this repository for testing purposes
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-12-11 16:03:16 +03:00
Nic Cope ca4b6b46c9 Mirror PersistentVolume ReclaimPolicy semantics
This commit changes the meaning of the resource claim resource policy to match
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming as
closely as possible, minus the deprecated 'Recycle' policy. Previously the
reclaim policy dictated only what happened to the external resource when its
managed resource was deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-19 14:43:25 -08:00
Nic Cope 8fc49848d6 Set binding phase after update when unbinding
Previously we set the binding phase to unbound, then called Update(), which
reset the binding status to the API server value before we called
Status().Update() to persist it.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-02 02:16:32 -07:00
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 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 551efff860 Add tests for external name annotation back-propagation
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-24 21:07:40 -07:00
Nic Cope 799c22bda6 Set managed resource claim ref at binding time
We already set this reference at dynamic provisioning time, but we need it set
for (bound) statically provisioned managed resources too, so we set it
(potentially again) at binding time.

We must still set the reference at dynamic provisioning time in order to ensure
reconciles are queued for dynamically provisioned managed resources when they
become available.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-24 21:07:40 -07:00
Nic Cope a2e24876e0 Use custom types for secret references
This allows us to require that name (and namespace where appropriate) are set at
the CRD level. In the case of cluster scoped resources that reference secrets
this is less surprising than defaulting to the `default` namespace when the
namespace is omitted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:13:21 -07:00
Nic Cope 9f5188e0cb Assume resources, classes, and providers are cluster scoped
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:13:21 -07:00
Nic Cope a310ee6a4a Remove support for portable resource classes
This commit renames "non portable resource class" back to "resource class", and
requires that resource claims reference a (non portable) resource class in any
namespace.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:12:36 -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 894481e637 Propagate connection secrets
This commit allows constant propagation of connection secrets from managed
resources to their bound resource claims. It does this by updating the existing
APIManagedConnectionPropagator to add 'propagation annotations', which can be
used by a new 'secret propagating reconciler' to watch both secrets for constant
propagation. The predicates and enqueue handler required to implement this are
included.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-08 00:25:11 -07:00
hasheddan 83aac58038 fix broken error values in tests
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-09-13 00:41:57 -05:00
hasheddan 06cc35d1e3 class to nonportable class
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-09-11 22:59:59 -05:00
hasheddan 161ab47fb3 portable and nonportable
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-09-11 16:23:44 -05: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
Jared Watts 07d9fe6e26 Merge pull request #626 from hasheddan/strong-phase1
Enable Strongly Typed Resource Classes
2019-08-02 08:41:30 -07:00
hasheddan 9c60da21bc strongly typed phase one: implement default class reconciler for strongly typed resource classes
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Nic Cope <negz@rk0n.org>
2019-08-02 09:59:19 -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
Nic Cope 1a3451d074 Merge pull request #603 from muvaf/comment-impl
Implement Generic Managed Reconciler
2019-07-31 00:12:26 -07:00
Nic Cope 0681f18c20 Fix typo in license headers
This looks suspiciously like a find and replace bug.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-07-30 21:07:12 -07: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
Nic Cope 91598b2e3f Add a shared managed resource reconciler
This reconciler can be used to reconcile any resource that satisfies the Managed
interface.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-07-23 12:37:19 -07:00
hasheddan d787a8c9cf header typos: correct author spelling
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-07-17 19:20:04 -05:00
Nic Cope b3da55f2be Update all copyrights to 2019
This commit was generated via s/Copyright 2018/Copyright 2019/g

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-07-10 20:16:40 -07:00
Nic Cope fcb9e3663a Create managed resources in their resource class's namespace
https://github.com/crossplaneio/crossplane/issues/92

This returns to our historical behaviour of creating managed resources in the
namespace of thier resource class, not that of their resource claim. I believe
this pattern to be flawed, but mostly changed it in order to leverage owner
references (which cannot cross namespaces) in order to allow a claim to watch
the resources it controls.

Instead we maintain the historical behaviour for the time being, using a custom
event handler to enqueue requests for a resource's claim (reference).

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-27 00:20:40 -07:00
Nic Cope 68a7580935 Add new resource claim reconciler.
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-24 23:47:11 -07:00