MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / MakePGBackrestLogDir

Function MakePGBackrestLogDir

internal/pgbackrest/config.go:171–196  ·  view source on GitHub ↗

MakePGBackrestLogDir creates the pgBackRest default log path directory used when a dedicated repo host is configured.

(template *corev1.PodTemplateSpec,
	cluster *v1beta1.PostgresCluster)

Source from the content-addressed store, hash-verified

169// MakePGBackrestLogDir creates the pgBackRest default log path directory used when a
170// dedicated repo host is configured.
171func MakePGBackrestLogDir(template *corev1.PodTemplateSpec,
172 cluster *v1beta1.PostgresCluster) string {
173
174 pgBackRestLogPath := generateRepoHostLogPath(cluster)
175
176 container := corev1.Container{
177 // TODO(log-rotation): The second argument here should be the path
178 // of the volume mount. Find a way to calculate that consistently.
179 Command: []string{"bash", "-c", shell.MakeDirectories(path.Dir(pgBackRestLogPath), pgBackRestLogPath)},
180 Image: config.PGBackRestContainerImage(cluster),
181 ImagePullPolicy: cluster.Spec.ImagePullPolicy,
182 Name: naming.ContainerPGBackRestLogDirInit,
183 SecurityContext: initialize.RestrictedSecurityContext(),
184 }
185
186 // Set the container resources to the 'pgbackrest' container configuration.
187 for i, c := range template.Spec.Containers {
188 if c.Name == naming.PGBackRestRepoContainerName {
189 container.Resources = template.Spec.Containers[i].Resources
190 break
191 }
192 }
193 template.Spec.InitContainers = append(template.Spec.InitContainers, container)
194
195 return pgBackRestLogPath
196}
197
198// RestoreCommand returns the command for performing a pgBackRest restore. In addition to calling
199// the pgBackRest restore command with any pgBackRest options provided, the script also does the

Callers 2

TestMakePGBackrestLogDirFunction · 0.85

Calls 4

MakeDirectoriesFunction · 0.92
PGBackRestContainerImageFunction · 0.92
generateRepoHostLogPathFunction · 0.85

Tested by 1

TestMakePGBackrestLogDirFunction · 0.68