Skip to content

Commit fcc3c21

Browse files
authored
Merge pull request #600 from LukeMathWalker/error-policy-under-same-span
Ensure that any span emitted in `error_policy` is a child span of the root span for the respective reconciliation run.
2 parents fb551cc + 269cc3e commit fcc3c21

File tree

1 file changed

+7
-8
lines changed
  • kube-runtime/src/controller

1 file changed

+7
-8
lines changed

kube-runtime/src/controller/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ where
273273
let reconciler_span = info_span!("reconciling object", "object.ref" = %request.obj_ref, object.reason = %request.reason);
274274
reconciler_span.in_scope(|| reconciler(obj, context.clone()))
275275
.into_future()
276-
.instrument(reconciler_span)
276+
.instrument(reconciler_span.clone())
277277
// Reconciler errors are OK from the applier's PoV, we need to apply the error policy
278278
// to them separately
279-
.map(|res| Ok((request.obj_ref, res)))
279+
.map(|res| Ok((request.obj_ref, res, reconciler_span)))
280280
.left_future()
281281
},
282282
None => future::err(
@@ -295,14 +295,14 @@ where
295295
)
296296
.on_complete(async { tracing::debug!("applier runner-merge terminated") })
297297
// finally, for each completed reconcile call:
298-
.and_then(move |(obj_ref, reconciler_result)| {
298+
.and_then(move |(obj_ref, reconciler_result, reconciler_span)| {
299299
let (ReconcilerAction { requeue_after }, requeue_reason) = match &reconciler_result {
300300
Ok(action) =>
301301
// do what user told us
302302
(action.clone(), ReconcileReason::ReconcilerRequestedRetry),
303303
Err(err) =>
304304
// reconciler fn call failed
305-
(error_policy(err, err_context.clone()), ReconcileReason::ErrorPolicyRequestedRetry),
305+
(reconciler_span.in_scope(|| error_policy(err, err_context.clone())), ReconcileReason::ErrorPolicyRequestedRetry),
306306
};
307307
let mut scheduler_tx = scheduler_tx.clone();
308308
async move {
@@ -486,12 +486,11 @@ where
486486
/// To watch the full set of `Child` objects in the given `Api` scope, you can use [`ListParams::default`].
487487
///
488488
/// [`OwnerReference`]: k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference
489-
pub fn owns<Child: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static>(
489+
pub fn owns<Child: Clone + Resource<DynamicType = ()> + DeserializeOwned + Debug + Send + 'static>(
490490
self,
491491
api: Api<Child>,
492492
lp: ListParams,
493-
) -> Self
494-
{
493+
) -> Self {
495494
self.owns_with(api, (), lp)
496495
}
497496

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

0 commit comments

Comments
 (0)