From 1e613e5a4c0abd6cbd6549cdf6523d69b1b5269f Mon Sep 17 00:00:00 2001 From: nolancon Date: Wed, 29 Jan 2020 07:30:34 +0000 Subject: [PATCH 1/2] Update TopologyManager Feature Gate: - Alpha to Beta. - True by default. - Remove redundant validation checks. --- pkg/features/kube_features.go | 3 ++- pkg/kubelet/apis/config/validation/validation_test.go | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 623c2f39f13..25d56ab55d0 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -140,6 +140,7 @@ const ( // owner: @lmdaly // alpha: v1.16 + // beta: v1.18 // // Enable resource managers to make NUMA aligned decisions TopologyManager featuregate.Feature = "TopologyManager" @@ -557,7 +558,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS AttachVolumeLimit: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.19 CPUManager: {Default: true, PreRelease: featuregate.Beta}, CPUCFSQuotaPeriod: {Default: false, PreRelease: featuregate.Alpha}, - TopologyManager: {Default: false, PreRelease: featuregate.Alpha}, + TopologyManager: {Default: true, PreRelease: featuregate.Beta}, ServiceNodeExclusion: {Default: false, PreRelease: featuregate.Alpha}, NodeDisruptionExclusion: {Default: false, PreRelease: featuregate.Alpha}, CSIDriverRegistry: {Default: true, PreRelease: featuregate.Beta}, diff --git a/pkg/kubelet/apis/config/validation/validation_test.go b/pkg/kubelet/apis/config/validation/validation_test.go index 501afa233d5..00ed0aaf268 100644 --- a/pkg/kubelet/apis/config/validation/validation_test.go +++ b/pkg/kubelet/apis/config/validation/validation_test.go @@ -53,7 +53,6 @@ func TestValidateKubeletConfiguration(t *testing.T) { HairpinMode: kubeletconfig.PromiscuousBridge, NodeLeaseDurationSeconds: 1, CPUCFSQuotaPeriod: metav1.Duration{Duration: 100 * time.Millisecond}, - TopologyManagerPolicy: "none", } if allErrors := ValidateKubeletConfiguration(successCase1); allErrors != nil { t.Errorf("expect no errors, got %v", allErrors) @@ -86,7 +85,6 @@ func TestValidateKubeletConfiguration(t *testing.T) { HairpinMode: kubeletconfig.PromiscuousBridge, NodeLeaseDurationSeconds: 1, CPUCFSQuotaPeriod: metav1.Duration{Duration: 100 * time.Millisecond}, - TopologyManagerPolicy: "none", ReservedSystemCPUs: "0-3", } if allErrors := ValidateKubeletConfiguration(successCase2); allErrors != nil { @@ -118,9 +116,8 @@ func TestValidateKubeletConfiguration(t *testing.T) { HairpinMode: "foo", NodeLeaseDurationSeconds: -1, CPUCFSQuotaPeriod: metav1.Duration{Duration: 0}, - TopologyManagerPolicy: "", } - const numErrsErrorCase1 = 26 + const numErrsErrorCase1 = 25 if allErrors := ValidateKubeletConfiguration(errorCase1); len(allErrors.(utilerrors.Aggregate).Errors()) != numErrsErrorCase1 { t.Errorf("expect %d errors, got %v", numErrsErrorCase1, len(allErrors.(utilerrors.Aggregate).Errors())) } @@ -152,7 +149,6 @@ func TestValidateKubeletConfiguration(t *testing.T) { HairpinMode: kubeletconfig.PromiscuousBridge, NodeLeaseDurationSeconds: 1, CPUCFSQuotaPeriod: metav1.Duration{Duration: 100 * time.Millisecond}, - TopologyManagerPolicy: "none", ReservedSystemCPUs: "0-3", } const numErrsErrorCase2 = 1 From e8538d9b76abe944a61eab10bfc2a580974f25fd Mon Sep 17 00:00:00 2001 From: nolancon Date: Fri, 14 Feb 2020 03:38:39 +0000 Subject: [PATCH 2/2] Add mutex to Topology Manager Add/RemoveContainer This was exposed as a potential bug during e2e test debugging of this PR. --- pkg/kubelet/cm/topologymanager/topology_manager.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/cm/topologymanager/topology_manager.go b/pkg/kubelet/cm/topologymanager/topology_manager.go index dab59aa8aa6..f17f3c04c83 100644 --- a/pkg/kubelet/cm/topologymanager/topology_manager.go +++ b/pkg/kubelet/cm/topologymanager/topology_manager.go @@ -18,6 +18,7 @@ package topologymanager import ( "fmt" + "sync" "k8s.io/api/core/v1" "k8s.io/klog" @@ -54,6 +55,7 @@ type Manager interface { } type manager struct { + mutex sync.Mutex //The list of components registered with the Manager hintProviders []HintProvider //Mapping of a Pods mapping of Containers and their TopologyHints @@ -189,13 +191,18 @@ func (m *manager) AddHintProvider(h HintProvider) { } func (m *manager) AddContainer(pod *v1.Pod, containerID string) error { + m.mutex.Lock() + defer m.mutex.Unlock() + m.podMap[containerID] = string(pod.UID) return nil } func (m *manager) RemoveContainer(containerID string) error { - klog.Infof("[topologymanager] RemoveContainer - Container ID: %v", containerID) + m.mutex.Lock() + defer m.mutex.Unlock() + klog.Infof("[topologymanager] RemoveContainer - Container ID: %v", containerID) podUIDString := m.podMap[containerID] delete(m.podMap, containerID) if _, exists := m.podTopologyHints[podUIDString]; exists {