Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
toszr committed Feb 14, 2022
1 parent 526474a commit dab2594
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (

dataSourceStartupArguments = "eec-ds-shared"
dataSourceAuthToken = "dsauthtokendir"
eecLogs = "extensions-logs"
)

var _ kubeobjects.ContainerBuilder = (*ExtensionController)(nil)
Expand Down Expand Up @@ -80,7 +81,7 @@ func (eec *ExtensionController) BuildVolumes() []corev1.Volume {
},
},
{
Name: "extensions-logs",
Name: eecLogs,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
Expand Down Expand Up @@ -113,11 +114,11 @@ func (eec *ExtensionController) buildCommand() []string {
func (eec *ExtensionController) buildVolumeMounts() []corev1.VolumeMount {
return []corev1.VolumeMount{
{Name: eecAuthToken, MountPath: activeGateConfigDir},
{Name: dataSourceStartupArguments, MountPath: "/mnt/dsexecargs"},
{Name: dataSourceAuthToken, MountPath: "/var/lib/dynatrace/remotepluginmodule/agent/runtime/datasources"},
{Name: dataSourceMetadata, MountPath: "/opt/dynatrace/remotepluginmodule/agent/datasources/statsd", ReadOnly: true},
{Name: "extensions-logs", MountPath: extensionsLogsDir},
{Name: "statsd-logs", MountPath: statsDLogsDir, ReadOnly: true},
{Name: dataSourceStartupArguments, MountPath: dataSourceStartupArgsMountPoint},
{Name: dataSourceAuthToken, MountPath: dataSourceAuthTokenMountPoint},
{Name: dataSourceMetadata, MountPath: statsdMetadataMountPoint, ReadOnly: true},
{Name: eecLogs, MountPath: extensionsLogsDir},
{Name: dataSourceStatsdLogs, MountPath: statsDLogsDir, ReadOnly: true},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func TestExtensionController_BuildContainerAndVolumes(t *testing.T) {

for _, mountPath := range []string{
activeGateConfigDir,
"/mnt/dsexecargs",
"/var/lib/dynatrace/remotepluginmodule/agent/runtime/datasources",
"/opt/dynatrace/remotepluginmodule/agent/datasources/statsd",
dataSourceStartupArgsMountPoint,
dataSourceAuthTokenMountPoint,
statsdMetadataMountPoint,
extensionsLogsDir,
statsDLogsDir,
} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const statsdProbesPort = 14999
const statsDLogsDir = extensionsLogsDir + "/datasources-statsd"

const (
dataSourceMetadata = "ds-metadata"
dataSourceMetadata = "ds-metadata"
dataSourceStatsdLogs = "statsd-logs"
)

var _ kubeobjects.ContainerBuilder = (*Statsd)(nil)
Expand Down Expand Up @@ -76,7 +77,7 @@ func (statsd *Statsd) BuildVolumes() []corev1.Volume {
},
},
{
Name: "statsd-logs",
Name: dataSourceStatsdLogs,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
Expand Down Expand Up @@ -109,18 +110,18 @@ func (statsd *Statsd) buildPorts() []corev1.ContainerPort {

func (statsd *Statsd) buildVolumeMounts() []corev1.VolumeMount {
return []corev1.VolumeMount{
{Name: dataSourceStartupArguments, MountPath: "/mnt/dsexecargs"},
{Name: dataSourceAuthToken, MountPath: "/var/lib/dynatrace/remotepluginmodule/agent/runtime/datasources"},
{Name: dataSourceMetadata, MountPath: "/mnt/dsmetadata"},
{Name: "statsd-logs", MountPath: statsDLogsDir},
{Name: dataSourceStartupArguments, MountPath: dataSourceStartupArgsMountPoint},
{Name: dataSourceAuthToken, MountPath: dataSourceAuthTokenMountPoint},
{Name: dataSourceMetadata, MountPath: dataSourceMetadataMountPoint},
{Name: dataSourceStatsdLogs, MountPath: statsDLogsDir},
}
}

func (statsd *Statsd) buildEnvs() []corev1.EnvVar {
return []corev1.EnvVar{
{Name: "StatsdExecArgsPath", Value: "/mnt/dsexecargs/statsd.process.json"},
{Name: "StatsdExecArgsPath", Value: dataSourceStartupArgsMountPoint + "/statsd.process.json"},
{Name: "ProbeServerPort", Value: fmt.Sprintf("%d", statsdProbesPort)},
{Name: "StatsdMetadataDir", Value: "/mnt/dsmetadata"},
{Name: "StatsdMetadataDir", Value: dataSourceMetadataMountPoint},
{Name: "DsLogFile", Value: statsDLogsDir + "/dynatracesourcestatsd.log"},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func TestStatsd_BuildContainerAndVolumes(t *testing.T) {
}

for _, mountPath := range []string{
"/mnt/dsexecargs",
"/var/lib/dynatrace/remotepluginmodule/agent/runtime/datasources",
"/mnt/dsmetadata",
dataSourceStartupArgsMountPoint,
dataSourceAuthTokenMountPoint,
dataSourceMetadataMountPoint,
statsDLogsDir,
} {
assertion.Truef(kubeobjects.MountPathIsIn(container.VolumeMounts, mountPath), "Expected that StatsD container defines mount point %s", mountPath)
Expand Down
10 changes: 7 additions & 3 deletions src/controllers/activegate/reconciler/statefulset/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const (
DTGroup = "DT_GROUP"
DTDeploymentMetadata = "DT_DEPLOYMENT_METADATA"

activeGateConfigDir = "/var/lib/dynatrace/gateway/config"
activeGateConfigDir = "/var/lib/dynatrace/gateway/config"
dataSourceStartupArgsMountPoint = "/mnt/dsexecargs"
dataSourceAuthTokenMountPoint = "/var/lib/dynatrace/remotepluginmodule/agent/runtime/datasources"
dataSourceMetadataMountPoint = "/mnt/dsmetadata"
statsdMetadataMountPoint = "/opt/dynatrace/remotepluginmodule/agent/datasources/statsd"
)

type statefulSetProperties struct {
Expand Down Expand Up @@ -257,8 +261,8 @@ func buildVolumeMounts(stsProperties *statefulSetProperties) []corev1.VolumeMoun
if stsProperties.NeedsStatsd() {
volumeMounts = append(volumeMounts,
corev1.VolumeMount{Name: eecAuthToken, MountPath: activeGateConfigDir},
corev1.VolumeMount{Name: "extensions-logs", MountPath: extensionsLogsDir + "/eec", ReadOnly: true},
corev1.VolumeMount{Name: "statsd-logs", MountPath: extensionsLogsDir + "/statsd", ReadOnly: true},
corev1.VolumeMount{Name: eecLogs, MountPath: extensionsLogsDir + "/eec", ReadOnly: true},
corev1.VolumeMount{Name: dataSourceStatsdLogs, MountPath: extensionsLogsDir + "/statsd", ReadOnly: true},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ func TestStatefulSet_TemplateSpec(t *testing.T) {
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, "auth-tokens"),
"Expected that volume mount %s has a predefined pod volume", "auth-tokens",
)
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, "ds-metadata"),
"Expected that volume mount %s has a predefined pod volume", "ds-metadata",
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, dataSourceMetadata),
"Expected that volume mount %s has a predefined pod volume", dataSourceMetadata,
)
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, "extensions-logs"),
"Expected that volume mount %s has a predefined pod volume", "extensions-logs",
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, eecLogs),
"Expected that volume mount %s has a predefined pod volume", eecLogs,
)
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, "statsd-logs"),
"Expected that volume mount %s has a predefined pod volume", "statsd-logs",
assert.Equalf(t, expected, kubeobjects.VolumeIsDefined(templateSpec.Volumes, dataSourceStatsdLogs),
"Expected that volume mount %s has a predefined pod volume", dataSourceStatsdLogs,
)
}

Expand Down

0 comments on commit dab2594

Please sign in to comment.