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>
Updates the package parsing logic to only attempt decoding with the
object scheme in the case that the error from decoding in the meta
scheme is due to the GVK not being registered. This does not change the
definition of a valid package, but does result in more informative
errors being returned when a package is invalid due to a malformed meta
type.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
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>
This PR tweaks how ratelimiters are applied to support _actual_ global reconcile
rate limiting - that is all reconcile triggers are rate limited, not just some.
See https://github.com/crossplane/crossplane/issues/2595 for details.
Signed-off-by: Nic Cope <negz@rk0n.org>
I don't really expect these to be used in practice. They're mostly useful for
places like the XRD controllers where we need a default set of options to plumb
down to the XR and XRC controllers when none are passed to use (i.e. in tests).
Signed-off-by: Nic Cope <negz@rk0n.org>
This type is intended to be passed as the argument to most Crossplane Setup
functions, for example:
```go
func Setup(mgr ctrl.Manager, o controller.Options) error
```
This allows us to add new options to be plumbed down to all or most controllers
without increasing the number of arguments provided to each Setup function. Sets
of controllers that require additional arguments (e.g. the pkg controllers from
crossplane/crossplane) can define their own Options struct that embeds this one.
Signed-off-by: Nic Cope <negz@rk0n.org>
I'd like to reuse these existing ratelimiters for crossplane, where the names
'Provider' and 'Managed' don't make as much sense.
Signed-off-by: Nic Cope <negz@rk0n.org>
https://github.com/crossplane/crossplane/tree/b7ce021e32/internal/featurehttps://github.com/crossplane/crossplane/issues/2313.
This is a copy of the (almost) identical crossplane/crossplane package, which
will be removed in favor of this one. Moving to crossplane-runtime allows us to
use the same package in providers, e.g. to disable Alpha APIs per the above
issue.
The package is _almost_ identical because the Flag type has been changed from
int to string. This makes it easier to give flags string names, because the
stringer tool we previously used requires that types and instances be defined in
the same package.
Signed-off-by: Nic Cope <negz@rk0n.org>
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>
I tried to address this TODO today, but found that I kind of prefer how our
implementation works. I've found from time to time while writing tests that
I was accidentally wrapping my errors with the wrong context (i.e. message),
which is not something the cmpopts variant tests for.
Signed-off-by: Nic Cope <negz@rk0n.org>
Go introduced a 'native' way to wrap errors back in v1.13. At that point we were
already using github.com/pkg/errors to 'wrap' errors with context, and we never
got around to migrating. In addition to pure inertia, I've personally avoided
making the switch because I prefer the github.com/pkg/errors API. Specifically I
like that errors.Wrap handles the "outer context: inner context" error format
that Go uses by convention, and that errors.Wrap will return nil when passed a
nil error.
Given that github.com/pkg/errors has long been in maintenance mode, and is (per
https://github.com/pkg/errors/issues/245) no longer used by its original author
now seems as good a time as any to migrate. This commit attempts to ease that
migration for the Crossplane project - and to retain the nice API - by adding a
package that acts as a small github.com/pkg/errors style shim layer around the
stdlib pkg/errors (and friends, like fmt.Errorf).
Signed-off-by: Nic Cope <negz@rk0n.org>