Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koordlet: decouple CUDA dependency Accelerators feature disabled #1876

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading