mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-21 17:15:35 +00:00
Record SyncTerminatingPod error and set error status on span when non-nil err returned
Signed-off-by: Nick Rutigliano <rutigliano.nick@gmail.com>
This commit is contained in:
@@ -2127,19 +2127,28 @@ func (kl *Kubelet) SyncPod(ctx context.Context, updateType kubetypes.SyncPodType
|
||||
// during eviction). This method is not guaranteed to be called if a pod is force deleted from the
|
||||
// configuration and the kubelet is restarted - SyncTerminatingRuntimePod handles those orphaned
|
||||
// pods.
|
||||
func (kl *Kubelet) SyncTerminatingPod(_ context.Context, pod *v1.Pod, podStatus *kubecontainer.PodStatus, gracePeriod *int64, podStatusFn func(*v1.PodStatus)) error {
|
||||
func (kl *Kubelet) SyncTerminatingPod(_ context.Context, pod *v1.Pod, podStatus *kubecontainer.PodStatus, gracePeriod *int64, podStatusFn func(*v1.PodStatus)) (err error) {
|
||||
// TODO(#113606): connect this with the incoming context parameter, which comes from the pod worker.
|
||||
// Currently, using that context causes test failures.
|
||||
ctx, otelSpan := kl.tracer.Start(context.Background(), "syncTerminatingPod", trace.WithAttributes(
|
||||
ctx := context.Background()
|
||||
|
||||
logger := klog.FromContext(ctx)
|
||||
klog.V(4).InfoS("SyncTerminatingPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||
|
||||
ctx, otelSpan := kl.tracer.Start(ctx, "syncTerminatingPod", trace.WithAttributes(
|
||||
semconv.K8SPodUIDKey.String(string(pod.UID)),
|
||||
attribute.String("k8s.pod", klog.KObj(pod).String()),
|
||||
semconv.K8SPodNameKey.String(pod.Name),
|
||||
semconv.K8SNamespaceNameKey.String(pod.Namespace),
|
||||
))
|
||||
logger := klog.FromContext(ctx)
|
||||
defer otelSpan.End()
|
||||
klog.V(4).InfoS("SyncTerminatingPod enter", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||
defer klog.V(4).InfoS("SyncTerminatingPod exit", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||
defer func() {
|
||||
if err != nil {
|
||||
otelSpan.RecordError(err)
|
||||
otelSpan.SetStatus(codes.Error, err.Error())
|
||||
}
|
||||
otelSpan.End()
|
||||
klog.V(4).InfoS("SyncTerminatingPod exit", "pod", klog.KObj(pod), "podUID", pod.UID)
|
||||
}()
|
||||
|
||||
apiPodStatus := kl.generateAPIPodStatus(pod, podStatus, false)
|
||||
if podStatusFn != nil {
|
||||
|
||||
Reference in New Issue
Block a user