mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Merge pull request #130244 from swatisehgal/topology-mgr-logs-improvements
Topology Manager logging improvements
This commit is contained in:
commit
d8c2e46b21
@ -45,7 +45,7 @@ func NewFakeManagerWithHint(hint *TopologyHint) Manager {
|
||||
|
||||
// NewFakeManagerWithPolicy returns an instance of fake topology manager with specified policy
|
||||
func NewFakeManagerWithPolicy(policy Policy) Manager {
|
||||
klog.InfoS("NewFakeManagerWithPolicy")
|
||||
klog.InfoS("NewFakeManagerWithPolicy", "policy", policy.Name())
|
||||
return &fakeManager{
|
||||
policy: policy,
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ func CheckPolicyOptionAvailable(option string) error {
|
||||
}
|
||||
|
||||
if alphaOptions.Has(option) && !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.TopologyManagerPolicyAlphaOptions) {
|
||||
return fmt.Errorf("Topology Manager Policy Alpha-level Options not enabled, but option %q provided", option)
|
||||
return fmt.Errorf("topology manager policy alpha-level options not enabled, but option %q provided", option)
|
||||
}
|
||||
|
||||
if betaOptions.Has(option) && !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.TopologyManagerPolicyBetaOptions) {
|
||||
return fmt.Errorf("Topology Manager Policy Beta-level Options not enabled, but option %q provided", option)
|
||||
return fmt.Errorf("topology manager policy beta-level options not enabled, but option %q provided", option)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -74,7 +74,7 @@ func TestNewTopologyManagerOptions(t *testing.T) {
|
||||
policyOptions: map[string]string{
|
||||
MaxAllowableNUMANodes: "8",
|
||||
},
|
||||
expectedErr: fmt.Errorf("Topology Manager Policy Beta-level Options not enabled,"),
|
||||
expectedErr: fmt.Errorf("topology manager policy beta-level options not enabled,"),
|
||||
},
|
||||
{
|
||||
description: "return empty TopologyManagerOptions",
|
||||
@ -117,7 +117,7 @@ func TestNewTopologyManagerOptions(t *testing.T) {
|
||||
policyOptions: map[string]string{
|
||||
fancyBetaOption: "true",
|
||||
},
|
||||
expectedErr: fmt.Errorf("Topology Manager Policy Beta-level Options not enabled,"),
|
||||
expectedErr: fmt.Errorf("topology manager policy beta-level options not enabled,"),
|
||||
},
|
||||
{
|
||||
description: "test alpha options success",
|
||||
@ -136,7 +136,7 @@ func TestNewTopologyManagerOptions(t *testing.T) {
|
||||
policyOptions: map[string]string{
|
||||
fancyAlphaOption: "true",
|
||||
},
|
||||
expectedErr: fmt.Errorf("Topology Manager Policy Alpha-level Options not enabled,"),
|
||||
expectedErr: fmt.Errorf("topology manager policy alpha-level options not enabled,"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ func (s *containerScope) Admit(pod *v1.Pod) lifecycle.PodAdmitResult {
|
||||
}
|
||||
|
||||
if IsAlignmentGuaranteed(s.policy) {
|
||||
klog.V(4).InfoS("Resource alignment at container scope guaranteed", "pod", klog.KObj(pod))
|
||||
metrics.ContainerAlignedComputeResources.WithLabelValues(metrics.AlignScopeContainer, metrics.AlignedNUMANode).Inc()
|
||||
}
|
||||
}
|
||||
@ -84,6 +85,6 @@ func (s *containerScope) accumulateProvidersHints(pod *v1.Pod, container *v1.Con
|
||||
func (s *containerScope) calculateAffinity(pod *v1.Pod, container *v1.Container) (TopologyHint, bool) {
|
||||
providersHints := s.accumulateProvidersHints(pod, container)
|
||||
bestHint, admit := s.policy.Merge(providersHints)
|
||||
klog.InfoS("ContainerTopologyHint", "bestHint", bestHint)
|
||||
klog.InfoS("ContainerTopologyHint", "bestHint", bestHint, "pod", klog.KObj(pod), "containerName", container.Name)
|
||||
return bestHint, admit
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ func (s *podScope) Admit(pod *v1.Pod) lifecycle.PodAdmitResult {
|
||||
}
|
||||
if IsAlignmentGuaranteed(s.policy) {
|
||||
// increment only if we know we allocate aligned resources.
|
||||
klog.V(4).InfoS("Resource alignment at pod scope guaranteed", "pod", klog.KObj(pod))
|
||||
metrics.ContainerAlignedComputeResources.WithLabelValues(metrics.AlignScopePod, metrics.AlignedNUMANode).Inc()
|
||||
}
|
||||
return admission.GetPodAdmitResult(nil)
|
||||
@ -84,6 +85,6 @@ func (s *podScope) accumulateProvidersHints(pod *v1.Pod) []map[string][]Topology
|
||||
func (s *podScope) calculateAffinity(pod *v1.Pod) (TopologyHint, bool) {
|
||||
providersHints := s.accumulateProvidersHints(pod)
|
||||
bestHint, admit := s.policy.Merge(providersHints)
|
||||
klog.InfoS("PodTopologyHint", "bestHint", bestHint)
|
||||
klog.InfoS("PodTopologyHint", "bestHint", bestHint, "pod", klog.KObj(pod))
|
||||
return bestHint, admit
|
||||
}
|
||||
|
@ -212,11 +212,13 @@ func (m *manager) RemoveContainer(containerID string) error {
|
||||
}
|
||||
|
||||
func (m *manager) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult {
|
||||
klog.V(4).InfoS("Topology manager admission check", "pod", klog.KObj(attrs.Pod))
|
||||
metrics.TopologyManagerAdmissionRequestsTotal.Inc()
|
||||
|
||||
startTime := time.Now()
|
||||
podAdmitResult := m.scope.Admit(attrs.Pod)
|
||||
metrics.TopologyManagerAdmissionDuration.Observe(float64(time.Since(startTime).Milliseconds()))
|
||||
|
||||
klog.V(4).InfoS("Pod Admit Result", "Message", podAdmitResult.Message, "pod", klog.KObj(attrs.Pod))
|
||||
return podAdmitResult
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user