Skip to content

Commit d8c2e46

Browse files
authored
Merge pull request kubernetes#130244 from swatisehgal/topology-mgr-logs-improvements
Topology Manager logging improvements
2 parents 4f3fd12 + 8ee3558 commit d8c2e46

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

pkg/kubelet/cm/topologymanager/fake_topology_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewFakeManagerWithHint(hint *TopologyHint) Manager {
4545

4646
// NewFakeManagerWithPolicy returns an instance of fake topology manager with specified policy
4747
func NewFakeManagerWithPolicy(policy Policy) Manager {
48-
klog.InfoS("NewFakeManagerWithPolicy")
48+
klog.InfoS("NewFakeManagerWithPolicy", "policy", policy.Name())
4949
return &fakeManager{
5050
policy: policy,
5151
}

pkg/kubelet/cm/topologymanager/policy_options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func CheckPolicyOptionAvailable(option string) error {
4747
}
4848

4949
if alphaOptions.Has(option) && !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.TopologyManagerPolicyAlphaOptions) {
50-
return fmt.Errorf("Topology Manager Policy Alpha-level Options not enabled, but option %q provided", option)
50+
return fmt.Errorf("topology manager policy alpha-level options not enabled, but option %q provided", option)
5151
}
5252

5353
if betaOptions.Has(option) && !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.TopologyManagerPolicyBetaOptions) {
54-
return fmt.Errorf("Topology Manager Policy Beta-level Options not enabled, but option %q provided", option)
54+
return fmt.Errorf("topology manager policy beta-level options not enabled, but option %q provided", option)
5555
}
5656

5757
return nil

pkg/kubelet/cm/topologymanager/policy_options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestNewTopologyManagerOptions(t *testing.T) {
7474
policyOptions: map[string]string{
7575
MaxAllowableNUMANodes: "8",
7676
},
77-
expectedErr: fmt.Errorf("Topology Manager Policy Beta-level Options not enabled,"),
77+
expectedErr: fmt.Errorf("topology manager policy beta-level options not enabled,"),
7878
},
7979
{
8080
description: "return empty TopologyManagerOptions",
@@ -117,7 +117,7 @@ func TestNewTopologyManagerOptions(t *testing.T) {
117117
policyOptions: map[string]string{
118118
fancyBetaOption: "true",
119119
},
120-
expectedErr: fmt.Errorf("Topology Manager Policy Beta-level Options not enabled,"),
120+
expectedErr: fmt.Errorf("topology manager policy beta-level options not enabled,"),
121121
},
122122
{
123123
description: "test alpha options success",
@@ -136,7 +136,7 @@ func TestNewTopologyManagerOptions(t *testing.T) {
136136
policyOptions: map[string]string{
137137
fancyAlphaOption: "true",
138138
},
139-
expectedErr: fmt.Errorf("Topology Manager Policy Alpha-level Options not enabled,"),
139+
expectedErr: fmt.Errorf("topology manager policy alpha-level options not enabled,"),
140140
},
141141
}
142142

pkg/kubelet/cm/topologymanager/scope_container.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func (s *containerScope) Admit(pod *v1.Pod) lifecycle.PodAdmitResult {
6363
}
6464

6565
if IsAlignmentGuaranteed(s.policy) {
66+
klog.V(4).InfoS("Resource alignment at container scope guaranteed", "pod", klog.KObj(pod))
6667
metrics.ContainerAlignedComputeResources.WithLabelValues(metrics.AlignScopeContainer, metrics.AlignedNUMANode).Inc()
6768
}
6869
}
@@ -84,6 +85,6 @@ func (s *containerScope) accumulateProvidersHints(pod *v1.Pod, container *v1.Con
8485
func (s *containerScope) calculateAffinity(pod *v1.Pod, container *v1.Container) (TopologyHint, bool) {
8586
providersHints := s.accumulateProvidersHints(pod, container)
8687
bestHint, admit := s.policy.Merge(providersHints)
87-
klog.InfoS("ContainerTopologyHint", "bestHint", bestHint)
88+
klog.InfoS("ContainerTopologyHint", "bestHint", bestHint, "pod", klog.KObj(pod), "containerName", container.Name)
8889
return bestHint, admit
8990
}

pkg/kubelet/cm/topologymanager/scope_pod.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (s *podScope) Admit(pod *v1.Pod) lifecycle.PodAdmitResult {
6464
}
6565
if IsAlignmentGuaranteed(s.policy) {
6666
// increment only if we know we allocate aligned resources.
67+
klog.V(4).InfoS("Resource alignment at pod scope guaranteed", "pod", klog.KObj(pod))
6768
metrics.ContainerAlignedComputeResources.WithLabelValues(metrics.AlignScopePod, metrics.AlignedNUMANode).Inc()
6869
}
6970
return admission.GetPodAdmitResult(nil)
@@ -84,6 +85,6 @@ func (s *podScope) accumulateProvidersHints(pod *v1.Pod) []map[string][]Topology
8485
func (s *podScope) calculateAffinity(pod *v1.Pod) (TopologyHint, bool) {
8586
providersHints := s.accumulateProvidersHints(pod)
8687
bestHint, admit := s.policy.Merge(providersHints)
87-
klog.InfoS("PodTopologyHint", "bestHint", bestHint)
88+
klog.InfoS("PodTopologyHint", "bestHint", bestHint, "pod", klog.KObj(pod))
8889
return bestHint, admit
8990
}

pkg/kubelet/cm/topologymanager/topology_manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ func (m *manager) RemoveContainer(containerID string) error {
212212
}
213213

214214
func (m *manager) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult {
215+
klog.V(4).InfoS("Topology manager admission check", "pod", klog.KObj(attrs.Pod))
215216
metrics.TopologyManagerAdmissionRequestsTotal.Inc()
216217

217218
startTime := time.Now()
218219
podAdmitResult := m.scope.Admit(attrs.Pod)
219220
metrics.TopologyManagerAdmissionDuration.Observe(float64(time.Since(startTime).Milliseconds()))
220221

222+
klog.V(4).InfoS("Pod Admit Result", "Message", podAdmitResult.Message, "pod", klog.KObj(attrs.Pod))
221223
return podAdmitResult
222224
}

0 commit comments

Comments
 (0)