MCPcopy Index your code
hub / github.com/NVIDIA/gpu-operator / getRuntimeConfigFiles

Function getRuntimeConfigFiles

controllers/object_controls.go:2597–2636  ·  view source on GitHub ↗

getRuntimeConfigFiles returns the path to the top-level and drop-in config files that should be used when configuring the specified container runtime.

(c *corev1.Container, runtime string)

Source from the content-addressed store, hash-verified

2595// getRuntimeConfigFiles returns the path to the top-level and drop-in config files that
2596// should be used when configuring the specified container runtime.
2597func getRuntimeConfigFiles(c *corev1.Container, runtime string) (string, string, error) {
2598 switch runtime {
2599 case gpuv1.Docker.String():
2600 topLevelConfigFile := DefaultDockerConfigFile
2601 if value := getContainerEnv(c, "DOCKER_CONFIG"); value != "" {
2602 topLevelConfigFile = value
2603 } else if value := getContainerEnv(c, "RUNTIME_CONFIG"); value != "" {
2604 topLevelConfigFile = value
2605 }
2606 // Docker does not support drop-in files.
2607 return topLevelConfigFile, "", nil
2608 case gpuv1.Containerd.String():
2609 topLevelConfigFile := DefaultContainerdConfigFile
2610 if value := getContainerEnv(c, "CONTAINERD_CONFIG"); value != "" {
2611 topLevelConfigFile = value
2612 } else if value := getContainerEnv(c, "RUNTIME_CONFIG"); value != "" {
2613 topLevelConfigFile = value
2614 }
2615 dropInConfigFile := DefaultContainerdDropInConfigFile
2616 if value := getContainerEnv(c, "RUNTIME_DROP_IN_CONFIG"); value != "" {
2617 dropInConfigFile = value
2618 }
2619 return topLevelConfigFile, dropInConfigFile, nil
2620 case gpuv1.CRIO.String():
2621 // TODO: We should still allow the top-level config to be specified
2622 topLevelConfigFile := DefaultCRIOConfigFile
2623 if value := getContainerEnv(c, "CRIO_CONFIG"); value != "" {
2624 topLevelConfigFile = value
2625 } else if value := getContainerEnv(c, "RUNTIME_CONFIG"); value != "" {
2626 topLevelConfigFile = value
2627 }
2628 dropInConfigFile := DefaultCRIODropInConfigFile
2629 if value := getContainerEnv(c, "RUNTIME_DROP_IN_CONFIG"); value != "" {
2630 dropInConfigFile = value
2631 }
2632 return topLevelConfigFile, dropInConfigFile, nil
2633 default:
2634 return "", "", fmt.Errorf("invalid runtime: %s", runtime)
2635 }
2636}
2637
2638// get runtime(docker, containerd) socket file path based on toolkit container env or default
2639func getRuntimeSocketFile(c *corev1.Container, runtime string) (string, error) {

Callers 2

transformForRuntimeFunction · 0.85

Calls 2

getContainerEnvFunction · 0.85
StringMethod · 0.80

Tested by 1