@@ -13,6 +13,7 @@ import (
1313 "github.com/crunchydata/postgres-operator/internal/feature"
1414 "github.com/crunchydata/postgres-operator/internal/initialize"
1515 "github.com/crunchydata/postgres-operator/internal/naming"
16+ "github.com/crunchydata/postgres-operator/internal/shell"
1617 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1718)
1819
@@ -40,7 +41,8 @@ func AddToPod(
4041 inInstanceConfigMap * corev1.ConfigMap ,
4142 outPod * corev1.PodSpec ,
4243 volumeMounts []corev1.VolumeMount ,
43- sqlQueryPassword string ,
44+ sqlQueryPassword ,
45+ dir string ,
4446 includeLogrotate bool ,
4547) {
4648 if ! (feature .Enabled (ctx , feature .OpenTelemetryLogs ) || feature .Enabled (ctx , feature .OpenTelemetryMetrics )) {
@@ -81,7 +83,7 @@ func AddToPod(
8183 Name : naming .ContainerCollector ,
8284 Image : config .CollectorContainerImage (spec ),
8385 ImagePullPolicy : pullPolicy ,
84- Command : startCommand (includeLogrotate ),
86+ Command : startCommand (dir , includeLogrotate ),
8587 Env : []corev1.EnvVar {
8688 {
8789 Name : "K8S_POD_NAMESPACE" ,
@@ -143,7 +145,12 @@ func AddToPod(
143145}
144146
145147// startCommand generates the command script used by the collector container
146- func startCommand (includeLogrotate bool ) []string {
148+ func startCommand (dir string , includeLogrotate bool ) []string {
149+ var mkdirScript string
150+ if dir != "" {
151+ mkdirScript = `
152+ ` + shell .MakeDirectories (0o775 , dir , dir + "/receiver" )
153+ }
147154 var startScript = `
148155/otelcol-contrib --config /etc/otel-collector/config.yaml
149156`
159166`
160167 }
161168
162- wrapper := `monitor() {` + startScript + `}; export -f monitor; exec -a "$0" bash -ceu monitor`
169+ wrapper := `monitor() {` + mkdirScript + startScript + `}; export -f monitor; exec -a "$0" bash -ceu monitor`
163170
164171 return []string {"bash" , "-ceu" , "--" , wrapper , "collector" }
165172}
0 commit comments