Commit Graph

161 Commits

Author SHA1 Message Date
hasheddan a23862526f
Assert to resource.Object once in APIUpdatingApplicator
This eliminates an extraneous assertion to metav1.Object in the Apply
method of the APIUpdatingApplicator by asserting to resource.Object at
the beginning of the function.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-04 09:33:44 -05: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
Muvaffak Onus 367fa803d9
Add reference for ProviderConfig objects and deprecate Provider references
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-08-27 14:59:31 +03:00
Nic Cope 76a692ce94 Don't require composite resources to be reclaimable
https://github.com/crossplane/crossplane-runtime/pull/186

This change should have been included in the above PR; composite resources
no longer have a reclaim policy and instead are immediately deleted when
their claim (nee requirement) is deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-18 19:33:28 -07:00
Nic Cope dbf0f9af21 Rename 'requirement' to 'claim'
Crossplane composite resources are cluster scoped, but they can be 'published'
to create a namespaced proxy resource. We called this resource a 'requirement',
despite it being conceptually quite similar to our existing (and deprecated)
'resource claim' concept. We've found that the 'publish a requirement' concept
has not resonated with the community and have decided to switch our terminology.

Under this new approach platform builders may choose to enable platform operators
to 'offer' (not publish) a composite resource to their platform consumers. The
namespaced interface to these composite resources will be known as a 'claim' or
'composite resource claim'. Note that we think platform builders and operators
are the key audience for these concepts; platform consumers will simply think of
themselves as using the resource as its kind indicates - e.g. 'a Kubernetes
cluster' or 'an SQL instance', not 'an SQL instance claim'.

In some cases our existing but deprecated resource claim concept has name
conflicts with this new take on the claim concept - i.e. the resource.Claim
interface. In those cases I've named the new type CompositeClaim to distinguish
it.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-18 19:33:28 -07:00
Nic Cope f70051c0e6
Merge pull request #186 from negz/reclamation
Remove reclaim policy from composite resources
2020-08-13 18:23:25 -07:00
Nic Cope c7b7ea8043 Remove reclaim policy from composite resources
See https://github.com/crossplane/crossplane-runtime/issues/179 for context.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-12 17:09:59 -07:00
Nic Cope 72cd5521e6 Rename the Deletable interface to Orphanable
This interface represents a resource with a deletion policy; i.e. a resource
whose underlying external resource may either be deleted or orphaned when the
it is deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-12 13:03:51 -07:00
Nic Cope 5c5d8932d3 Introduce a deletion policy, and deprecate the reclaim policy.
The deletion policy is a more narrowly scoped variant of the reclaim policy. It
affects only whether exeternal resources are deleted or orphaned when their
corresponding managed resource is deleted, as opposed to the reclaim policy
which also affects whether the managed resource is deleted when its bound claim
is deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-11 18:24:16 -07:00
hasheddan e130a99a00
Do not use pointer for Provider references
Provider reference is a required field for types that embed it. In
practice, accessing the Name field of a Provider reference should never
result in a nil pointer dereference, but it is still an unsafe
operation. Changing the Provider reference to a non-pointer absolves the
user from checking for a nil reference each time it is used.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-06-26 10:19:28 -05:00
hasheddan c5b903fedd
Use Refernce type for provider references
We are currently using corev1.ObjectReference for provider resources.
This includes more information than needed and encourages
using helper methods that may depend on other fields in the type that we
do not intend to be utilized. This updates provider references
fields to use the Reference type, which only has a name field.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-06-25 14:59:52 -05:00
hasheddan a964b65a29
Add UpdateFn for mutating ApplyOptions
Add an UpdateFn wrapper around ApplyOption that simplifies
the interface for passing a mutating function to
APIUpdatingApplicator.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-05-12 15:35:54 -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
Muvaffak Onus 1ddc2c5d8d
Add missing field to fake.Composite to satisfy resource.Composite interface
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-29 17:11:34 +03:00
Muvaffak Onus b5206ecd68
Export mock secret owner structs to be used in tests outside this repo
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-29 03:36:46 +03:00
Nic Cope 51ebec91a3 Add tests for unstructured wrappers.
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-25 21:32:29 -07:00
Nic Cope 6382f8b98c Add tests for unstructured.WrapperClient
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-25 20:03:59 -07:00
Nic Cope 100af7315c unstructured.WrapperClient nitpicks
Add a package docstring, and returns a concrete type rather than an interface
where possible.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-25 18:40:05 -07:00
Nic Cope da8cc179e7 Remove unused fake.Workload
This was for an OAM workload, that moved out to oam-kubernetes-runtime.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-24 12:06:27 -07:00
Nic Cope 477b9e592e Add fake composed, composite, and requirement resources.
We could also use pkg/resource/unstructured in tests, but I think this will
require a little less boilerplate to setup tests.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 21:34:33 -07:00
Nic Cope 3060371afd Remove unstructured.ObjectTyper
runtime.Scheme already does this.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 14:28:17 -07: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
Nic Cope ca1fe097be Expand and refactor unstructured types
This switches names around from unstructured.Composite (for example) to
composite.Unstructured, mostly to allow several unstructured types to use
identically named options like WithGroupVersionKind. It also adds a few
getters and setters required for resource publications, and introduces the
resource.Requirement type that represents an application's requirement for a
published composite resource.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 12:48:22 -07:00
Nic Cope 357942c02d Add a "controller engine" that manages the lifecycles of controllers
A controller engine is somewhat like a controller "sub-manager", in that it's
effectively a group of controllers. Unlike a typical controller manager, the
lifecycle of the controllers an engine manages are not coupled to the lifecycle
of the engine itself. An engine may be used by a parent controller to start and
stop child controllers in accordance with configuration provided by the custom
resource that the parent controller watches.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 01:51:27 -07:00
Nic Cope be37c50cc2
Merge pull request #157 from muvaf/unclient
Client for unstructured Crossplane types
2020-04-21 14:10:18 -07:00
Nic Cope 903cf3eff8
Merge pull request #155 from negz/noam
Remove OAM code, which has moved to crossplane/oam-runtime
2020-04-21 13:10:34 -07:00
Muvaffak Onus 9357d0ab18
Controller-runtime client wrapper for objects that are wrappers of unstructured.Unstructured
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-21 17:42:04 +03:00
Nic Cope 8ada1fa72b Compose the Composite interface of smaller interfaces
This also removes Bindable from the Composite interface, which I believe we will
not need.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-20 22:00:04 -07:00
Nic Cope 44099db82c Remove OAM code, which has moved to crossplane/oam-runtime
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-20 20:55:51 -07:00
Muvaffak Onus 4a7ece2ff5
Add composition interfaces and unstructured composition structs.
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-21 03:11:24 +03:00
Nic Cope 55a4bb6323
Merge pull request #149 from muvaf/applyfix
apply should work for objects with only generateName
2020-04-15 22:01:04 -07:00
Nic Cope b9255d7fcc Simplify resource references, and introduce reference selection
This commit introduces managed.APISimpleReferenceResolver, which satisfies the
managed.ReferenceResolver interface. This variant requires much less plumbing
and reflection because it expects that managed resources expose a single
ResolveReferences method that will optionally select and then resolve any
resource references. It also adds a new pkg/reference which contains a library
that managed resource authors _may_ choose to use to avoid reimplementing common
reference selection and resolution logic.

The existing managed.APIReferenceResolver implementation remains the default,
but is marked deprecated and will be removed once all managed resources use the
APISimpleReferenceResolver. Notably, the "reference resolution" condition is no
longer set by managed.Reconciler - managed resources will report reference
resolution issues via the Synced condition (i.e. as a ReconcileError).

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-15 13:59:53 -07:00
Muvaffak Onus 3301bfef95
apply should work for objects with only generateName
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-14 20:35:44 +03: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 ff8a47bab6 Add a MustBeControllableBy ApplyOption
This option replaces ControllersMustMatch. It works slightly differently in that
it takes the expected controller UID explicitly instead of inferring it from the
desired object, and considers current objects with no controller reference to be
controllable. Presumable objects with no controller reference will be adopted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-01 22:20:18 -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 bb562fce25
Clean up OAM reconcilers
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-20 09:48:15 -05:00
hasheddan 57df15c56c
Make WorkloadReferencer use non-pointer types
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-19 16:54:20 -05:00
hasheddan 7d845c0a81
Add TypedObjectReference and use in OAM reconcilers
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-18 21:49:28 -05:00
hasheddan 8a48d21abb Pass apply checks as functions to Applicators
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-16 16:53:41 -05:00
Muvaffak Onus 34f8959f86
Implement GetExternalTags to return Crossplane tags for managed resource controllers to tag their external resources
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-03-04 11:18:24 +03:00
hasheddan 73c6076ff3 Add Applicator interface
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-03 19:20:02 -06:00
Nic Cope 625ec3bf23 Fix controller mismatch detection in resource.Apply
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-03-02 22:37:14 -08:00
Nic Cope 1eec52890b Stash desired, not existing object when applying changes
Getting, creating, or patching an object using the controller-runtime client
updates said object with the latest state from the API server. This commit
alters our resource.Apply logic to patch 'into' the supplied object, not a
deepcopy of that object. This ensures the object passed to apply is updated
with the latest view from the API server, whether it is created or patched.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-03-02 22:00:40 -08:00
Nic Cope 6ef3f96332 Add an Apply object function
This function either creates a new object or patches an existing one. I think
it belongs in crossplane-runtime because we have at least two implementations in
the wild, and I need another one for a new controller.

https://github.com/crossplane/templating-controller/blob/a035e2/pkg/controllers/templating_reconciler.go#L168
https://github.com/crossplane/crossplane/blob/c1933feab/pkg/controller/workload/kubernetes/resource/resource.go#L260

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-02-27 16:42:02 -08: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 5e66b02110 Remove some referencer types back to pkg/resource
These types are used by infrastructure stack API types, which should not need to
import reconciler code.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-01-15 15:15:58 -08:00