Skip to content

Commit 83a18bf

Browse files
authored
koordlet: decouple CUDA dependency Accelerators feature disabled (#1876)
Signed-off-by: saintube <saintube@foxmail.com>
1 parent a056ccb commit 83a18bf

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

pkg/koordlet/metricsadvisor/metrics_advisor.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,28 @@ func (m *metricAdvisor) Run(stopCh <-chan struct{}) error {
109109
}
110110

111111
func (m *metricAdvisor) setup() {
112-
for _, device := range m.context.DeviceCollectors {
113-
device.Setup(m.context)
112+
for name, dc := range m.context.DeviceCollectors {
113+
if !dc.Enabled() {
114+
klog.V(4).Infof("device collector %v is not enabled, skip setup", name)
115+
continue
116+
}
117+
dc.Setup(m.context)
114118
}
115-
for _, collector := range m.context.Collectors {
119+
for name, collector := range m.context.Collectors {
120+
if !collector.Enabled() {
121+
klog.V(4).Infof("collector %v is not enabled, skip setup", name)
122+
continue
123+
}
116124
collector.Setup(m.context)
117125
}
118126
}
119127

120128
func (m *metricAdvisor) shutdown() {
121-
for _, dc := range m.context.DeviceCollectors {
129+
for name, dc := range m.context.DeviceCollectors {
130+
if !dc.Enabled() {
131+
klog.V(4).Infof("device collector %v is not enabled, skip shutdown", name)
132+
continue
133+
}
122134
dc.Shutdown()
123135
}
124136
}

pkg/koordlet/util/cpuinfo.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ func getHyperThreadEnabled() (bool, error) {
117117
klog.V(5).Infof("read %s err: %v, try `lscpu`", hyperThreadEnabledPath, err)
118118

119119
lsCPUStr, err := lsCPU("-y")
120+
if err != nil {
121+
return false, err
122+
}
120123
for _, line := range strings.Split(lsCPUStr, "\n") {
121124
items := strings.Split(line, ":")
122125
if len(items) != 2 || !strings.Contains(items[0], "Thread(s) per core") {
@@ -128,7 +131,7 @@ func getHyperThreadEnabled() (bool, error) {
128131
}
129132
return threadsPerCore > 1, nil
130133
}
131-
klog.Warningf("failed to get HyperThreadEnabled, considered as disabled, err: %s", err)
134+
klog.Warningf("failed to get HyperThreadEnabled, considered as disabled, lscpu output: %s", lsCPUStr)
132135
return false, nil
133136
}
134137

@@ -179,7 +182,7 @@ func lsCPU(option string) (string, error) {
179182

180183
executable, err := exec.LookPath("lscpu")
181184
if err != nil {
182-
return "", err
185+
return "", fmt.Errorf("failed to lookup lscpu path, err: %w", err)
183186
}
184187
output, err := exec.CommandContext(ctx, executable, option).Output()
185188
if err != nil {

0 commit comments

Comments
 (0)