Skip to content

Commit

Permalink
koordlet: decouple CUDA dependency Accelerators feature disabled (koo…
Browse files Browse the repository at this point in the history
…rdinator-sh#1876)

Signed-off-by: saintube <saintube@foxmail.com>
  • Loading branch information
saintube authored and ls-2018 committed Mar 25, 2024
1 parent 1b09bea commit 8fd5fb0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
20 changes: 16 additions & 4 deletions pkg/koordlet/metricsadvisor/metrics_advisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,28 @@ func (m *metricAdvisor) Run(stopCh <-chan struct{}) error {
}

func (m *metricAdvisor) setup() {
for _, device := range m.context.DeviceCollectors {
device.Setup(m.context)
for name, dc := range m.context.DeviceCollectors {
if !dc.Enabled() {
klog.V(4).Infof("device collector %v is not enabled, skip setup", name)
continue
}
dc.Setup(m.context)
}
for _, collector := range m.context.Collectors {
for name, collector := range m.context.Collectors {
if !collector.Enabled() {
klog.V(4).Infof("collector %v is not enabled, skip setup", name)
continue
}
collector.Setup(m.context)
}
}

func (m *metricAdvisor) shutdown() {
for _, dc := range m.context.DeviceCollectors {
for name, dc := range m.context.DeviceCollectors {
if !dc.Enabled() {
klog.V(4).Infof("device collector %v is not enabled, skip shutdown", name)
continue
}
dc.Shutdown()
}
}
7 changes: 5 additions & 2 deletions pkg/koordlet/util/cpuinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ func getHyperThreadEnabled() (bool, error) {
klog.V(5).Infof("read %s err: %v, try `lscpu`", hyperThreadEnabledPath, err)

lsCPUStr, err := lsCPU("-y")
if err != nil {
return false, err
}
for _, line := range strings.Split(lsCPUStr, "\n") {
items := strings.Split(line, ":")
if len(items) != 2 || !strings.Contains(items[0], "Thread(s) per core") {
Expand All @@ -128,7 +131,7 @@ func getHyperThreadEnabled() (bool, error) {
}
return threadsPerCore > 1, nil
}
klog.Warningf("failed to get HyperThreadEnabled, considered as disabled, err: %s", err)
klog.Warningf("failed to get HyperThreadEnabled, considered as disabled, lscpu output: %s", lsCPUStr)
return false, nil
}

Expand Down Expand Up @@ -179,7 +182,7 @@ func lsCPU(option string) (string, error) {

executable, err := exec.LookPath("lscpu")
if err != nil {
return "", err
return "", fmt.Errorf("failed to lookup lscpu path, err: %w", err)
}
output, err := exec.CommandContext(ctx, executable, option).Output()
if err != nil {
Expand Down

0 comments on commit 8fd5fb0

Please sign in to comment.