Skip to content

Commit

Permalink
Merge pull request #432 from kubescape/feature/socket-path-support
Browse files Browse the repository at this point in the history
Adding support for non unix prefixes
  • Loading branch information
amitschendel authored Dec 11, 2024
2 parents d870fa3 + 66d2112 commit 9cb836c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,21 @@ func getContainerRuntimeSocketPath(clientset *k8sinterface.KubernetesApi, nodeNa
if err != nil {
return "", fmt.Errorf("getting /configz: %w", err)
}
socketPath, found := strings.CutPrefix(kubeletConfig.ContainerRuntimeEndpoint, "unix://")
if !found {
return "", fmt.Errorf("socket path does not start with unix:// %s", helpers.String("socketPath", kubeletConfig.ContainerRuntimeEndpoint))

endpoint := kubeletConfig.ContainerRuntimeEndpoint
socketPath := endpoint

// If it starts with unix://, strip the prefix
if strings.HasPrefix(endpoint, "unix://") {
socketPath = strings.TrimPrefix(endpoint, "unix://")
}
logger.L().Info("using the detected container runtime socket path from Kubelet's config", helpers.String("socketPath", socketPath))

if socketPath == "" {
return "", fmt.Errorf("container runtime socket path is empty")
}

logger.L().Info("using the detected container runtime socket path from Kubelet's config",
helpers.String("socketPath", socketPath))
return socketPath, nil
}

Expand Down

0 comments on commit 9cb836c

Please sign in to comment.