Skip to content

Create cloud repo specific job #4205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions internal/controller/postgrescluster/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,11 +1169,11 @@ func (r *Reconciler) reconcileInstance(
)

if err == nil {
instanceConfigMap, err = r.reconcileInstanceConfigMap(ctx, cluster, spec, instance, otelConfig)
instanceConfigMap, err = r.reconcileInstanceConfigMap(ctx, cluster, spec, instance, otelConfig, backupsSpecFound)
}
if err == nil {
instanceCertificates, err = r.reconcileInstanceCertificates(
ctx, cluster, spec, instance, rootCA)
ctx, cluster, spec, instance, rootCA, backupsSpecFound)
}
if err == nil {
postgresDataVolume, err = r.reconcilePostgresDataVolume(ctx, cluster, spec, instance, clusterVolumes, nil)
Expand Down Expand Up @@ -1398,10 +1398,8 @@ func addPGBackRestToInstancePodSpec(
ctx context.Context, cluster *v1beta1.PostgresCluster,
instanceCertificates *corev1.Secret, instancePod *corev1.PodSpec,
) {
if pgbackrest.RepoHostVolumeDefined(cluster) {
pgbackrest.AddServerToInstancePod(ctx, cluster, instancePod,
instanceCertificates.Name)
}
pgbackrest.AddServerToInstancePod(ctx, cluster, instancePod,
instanceCertificates.Name)

pgbackrest.AddConfigToInstancePod(cluster, instancePod)
}
Expand All @@ -1412,7 +1410,7 @@ func addPGBackRestToInstancePodSpec(
// files (etc) that apply to instance of cluster.
func (r *Reconciler) reconcileInstanceConfigMap(
ctx context.Context, cluster *v1beta1.PostgresCluster, spec *v1beta1.PostgresInstanceSetSpec,
instance *appsv1.StatefulSet, otelConfig *collector.Config,
instance *appsv1.StatefulSet, otelConfig *collector.Config, backupsSpecFound bool,
) (*corev1.ConfigMap, error) {
instanceConfigMap := &corev1.ConfigMap{ObjectMeta: naming.InstanceConfigMap(instance)}
instanceConfigMap.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("ConfigMap"))
Expand All @@ -1439,11 +1437,9 @@ func (r *Reconciler) reconcileInstanceConfigMap(
err = collector.AddToConfigMap(ctx, otelConfig, instanceConfigMap)

// Add pgbackrest logrotate if OpenTelemetryLogs is enabled and
// local volumes are available
// backups are enabled
if err == nil &&
feature.Enabled(ctx, feature.OpenTelemetryLogs) &&
pgbackrest.RepoHostVolumeDefined(cluster) &&
cluster.Spec.Instrumentation != nil {
collector.OpenTelemetryLogsEnabled(ctx, cluster) && backupsSpecFound {

collector.AddLogrotateConfigs(ctx, cluster.Spec.Instrumentation,
instanceConfigMap,
Expand All @@ -1470,7 +1466,7 @@ func (r *Reconciler) reconcileInstanceConfigMap(
func (r *Reconciler) reconcileInstanceCertificates(
ctx context.Context, cluster *v1beta1.PostgresCluster,
spec *v1beta1.PostgresInstanceSetSpec, instance *appsv1.StatefulSet,
root *pki.RootCertificateAuthority,
root *pki.RootCertificateAuthority, backupsSpecFound bool,
) (*corev1.Secret, error) {
existing := &corev1.Secret{ObjectMeta: naming.InstanceCertificates(instance)}
err := errors.WithStack(client.IgnoreNotFound(
Expand Down Expand Up @@ -1513,7 +1509,7 @@ func (r *Reconciler) reconcileInstanceCertificates(
root.Certificate, leafCert.Certificate,
leafCert.PrivateKey, instanceCerts)
}
if err == nil {
if err == nil && backupsSpecFound {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double-checking: why don't we need this if using a local volume? Because these certs have to do with talking between repo/instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure what you are referring to, but we always need the instance certificates now. Both the cloud backup from the backup job and the local volume backup from the repo host need to be able to talk to the pgbackrest server in the instance pod.

err = pgbackrest.InstanceCertificates(ctx, cluster,
root.Certificate, leafCert.Certificate, leafCert.PrivateKey,
instanceCerts)
Expand Down
Loading
Loading