Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that any span emitted in error_policy is a child span of the root span for the respective reconciliation run. #600

Merged
merged 2 commits into from
Jul 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ where
let reconciler_span = info_span!("reconciling object", "object.ref" = %request.obj_ref, object.reason = %request.reason);
reconciler_span.in_scope(|| reconciler(obj, context.clone()))
.into_future()
.instrument(reconciler_span)
.instrument(reconciler_span.clone())
// Reconciler errors are OK from the applier's PoV, we need to apply the error policy
// to them separately
.map(|res| Ok((request.obj_ref, res)))
.map(|res| Ok((request.obj_ref, res, reconciler_span)))
.left_future()
},
None => future::err(
Expand All @@ -295,14 +295,14 @@ where
)
.on_complete(async { tracing::debug!("applier runner-merge terminated") })
// finally, for each completed reconcile call:
.and_then(move |(obj_ref, reconciler_result)| {
.and_then(move |(obj_ref, reconciler_result, reconciler_span)| {
let (ReconcilerAction { requeue_after }, requeue_reason) = match &reconciler_result {
Ok(action) =>
// do what user told us
(action.clone(), ReconcileReason::ReconcilerRequestedRetry),
Err(err) =>
// reconciler fn call failed
(error_policy(err, err_context.clone()), ReconcileReason::ErrorPolicyRequestedRetry),
(reconciler_span.in_scope(|| error_policy(err, err_context.clone())), ReconcileReason::ErrorPolicyRequestedRetry),
};
let mut scheduler_tx = scheduler_tx.clone();
async move {
Expand Down Expand Up @@ -486,12 +486,11 @@ where
/// To watch the full set of `Child` objects in the given `Api` scope, you can use [`ListParams::default`].
///
/// [`OwnerReference`]: k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference
pub fn owns<Child: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static>(
pub fn owns<Child: Clone + Resource<DynamicType = ()> + DeserializeOwned + Debug + Send + 'static>(
self,
api: Api<Child>,
lp: ListParams,
) -> Self
{
) -> Self {
self.owns_with(api, (), lp)
}

Expand Down Expand Up @@ -529,7 +528,7 @@ where
/// to watch - in the Api's configured scope - and run through the custom mapper.
/// To watch the full set of `Watched` objects in given the `Api` scope, you can use [`ListParams::default`].
pub fn watches<
Other: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static,
Other: Clone + Resource<DynamicType = ()> + DeserializeOwned + Debug + Send + 'static,
I: 'static + IntoIterator<Item = ObjectRef<K>>,
>(
self,
Expand Down