MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / loadPodSpec

Function loadPodSpec

cmd/nvidia-validator/main.go:1394–1414  ·  view source on GitHub ↗
(podSpecPath string)

Source from the content-addressed store, hash-verified

1392}
1393
1394func loadPodSpec(podSpecPath string) (*corev1.Pod, error) {
1395 var pod corev1.Pod
1396 manifest, err := os.ReadFile(podSpecPath)
1397 if err != nil {
1398 panic(err)
1399 }
1400 s := json.NewSerializerWithOptions(json.DefaultMetaFactory, scheme.Scheme,
1401 scheme.Scheme, json.SerializerOptions{Yaml: true, Pretty: false, Strict: false})
1402 reg := regexp.MustCompile(`\b(\w*kind:\w*)\B.*\b`)
1403
1404 kind := reg.FindString(string(manifest))
1405 slice := strings.Split(kind, ":")
1406 kind = strings.TrimSpace(slice[1])
1407
1408 log.Debugf("Decoding for Kind %s in path: %s", kind, podSpecPath)
1409 _, _, err = s.Decode(manifest, nil, &pod)
1410 if err != nil {
1411 return nil, err
1412 }
1413 return &pod, nil
1414}
1415
1416func (p *Plugin) countGPUResources() (int64, error) {
1417 // get node info to check discovered GPU resources

Callers 2

runWorkloadMethod · 0.85
runWorkloadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected