Skip to content

Commit

Permalink
Fix CRI vs Docker socket path priority. Always try to mount default r…
Browse files Browse the repository at this point in the history
…untime dir if using standard path to maximize usage of Env AD (#320)
  • Loading branch information
vboulineau committed Jun 9, 2021
1 parent 8072ba9 commit 78737f2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions controllers/datadogagent/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,21 +996,25 @@ func getVolumesForAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.Volume {
Name: datadoghqv1alpha1.CriSocketVolumeName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "",
Path: defaultRuntimeDir,
},
},
}

var userCriPath string
if dda.Spec.Agent.Config.CriSocket != nil {
if dda.Spec.Agent.Config.CriSocket.DockerSocketPath != nil {
runtimeVolume.VolumeSource.HostPath.Path = *dda.Spec.Agent.Config.CriSocket.DockerSocketPath
} else if dda.Spec.Agent.Config.CriSocket.CriSocketPath != nil {
runtimeVolume.VolumeSource.HostPath.Path = *dda.Spec.Agent.Config.CriSocket.CriSocketPath
if dda.Spec.Agent.Config.CriSocket.CriSocketPath != nil {
userCriPath = *dda.Spec.Agent.Config.CriSocket.CriSocketPath
} else if dda.Spec.Agent.Config.CriSocket.DockerSocketPath != nil {
userCriPath = *dda.Spec.Agent.Config.CriSocket.DockerSocketPath
}
}
if runtimeVolume.VolumeSource.HostPath.Path == "" {
runtimeVolume.VolumeSource.HostPath.Path = defaultRuntimeDir

// Always use default mount (/var/run) except if user path is not under the same path
if userCriPath != "" && !strings.HasPrefix(userCriPath, defaultRuntimeDir) {
runtimeVolume.VolumeSource.HostPath.Path = userCriPath
}

volumes = append(volumes, runtimeVolume)

if shouldAddProcessContainer(dda) || isComplianceEnabled(&dda.Spec) {
Expand Down

0 comments on commit 78737f2

Please sign in to comment.