Skip to content

Commit 23df737

Browse files
committed
see if this fixes our segf
1 parent 6d4f257 commit 23df737

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/controller/postgrescluster/pgbackrest.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,11 @@ func (r *Reconciler) reconcilePostgresClusterDataSource(ctx context.Context,
16361636
backupsSpecFound bool,
16371637
) error {
16381638

1639+
// Check if dataSource is nil - this can happen in some test scenarios
1640+
if dataSource == nil {
1641+
return errors.New("PostgresClusterDataSource is nil")
1642+
}
1643+
16391644
// Ensure the proper instance and instance set can be identified via the status. The
16401645
// StartupInstance and StartupInstanceSet values should be populated when the cluster
16411646
// is being prepared for a restore, and should therefore always exist at this point.
@@ -1867,6 +1872,11 @@ func (r *Reconciler) reconcileCloudBasedDataSource(ctx context.Context,
18671872
func (r *Reconciler) createRestoreConfig(ctx context.Context, postgresCluster *v1beta1.PostgresCluster,
18681873
configHash string) error {
18691874

1875+
// Check for nil DataSource or PGBackRest to prevent panic
1876+
if postgresCluster.Spec.DataSource == nil || postgresCluster.Spec.DataSource.PGBackRest == nil {
1877+
return errors.New("PostgresCluster DataSource or DataSource.PGBackRest is nil")
1878+
}
1879+
18701880
postgresClusterWithMockedBackups := postgresCluster.DeepCopy()
18711881
postgresClusterWithMockedBackups.Spec.Backups.PGBackRest.Global = postgresCluster.Spec.
18721882
DataSource.PGBackRest.Global

0 commit comments

Comments
 (0)