@@ -65,6 +65,7 @@ func fakePostgresCluster(clusterName, namespace, clusterUID string,
65
65
ImagePullSecrets: []corev1.LocalObjectReference{{
66
66
Name: "myImagePullSecret"},
67
67
},
68
+ InitImage: "some-init-image",
68
69
Image: "example.com/crunchy-postgres-ha:test",
69
70
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
70
71
Name: "instance1",
@@ -970,10 +971,10 @@ func TestReconcileReplicaCreateBackup(t *testing.T) {
970
971
}
971
972
}
972
973
// verify mounted configuration is present
973
- assert.Assert(t, len(container.VolumeMounts) == 1 )
974
+ assert.Assert(t, len(container.VolumeMounts) == 2 )
974
975
975
976
// verify volume for configuration is present
976
- assert.Assert(t, len(backupJob.Spec.Template.Spec.Volumes) == 1 )
977
+ assert.Assert(t, len(backupJob.Spec.Template.Spec.Volumes) == 2 )
977
978
978
979
// verify the image pull secret
979
980
assert.Assert(t, backupJob.Spec.Template.Spec.ImagePullSecrets != nil)
@@ -2460,7 +2461,7 @@ func TestGenerateBackupJobIntent(t *testing.T) {
2460
2461
},
2461
2462
},
2462
2463
v1beta1.PGBackRestRepo{},
2463
- "",
2464
+ "", "",
2464
2465
nil, nil,
2465
2466
)
2466
2467
assert.Assert(t, cmp.MarshalMatches(spec.Template.Spec, `
@@ -2492,14 +2493,38 @@ containers:
2492
2493
seccompProfile:
2493
2494
type: RuntimeDefault
2494
2495
volumeMounts:
2496
+ - mountPath: /opt/crunchy
2497
+ name: crunchy-bin
2495
2498
- mountPath: /etc/pgbackrest/conf.d
2496
2499
name: pgbackrest-config
2497
2500
readOnly: true
2498
2501
enableServiceLinks: false
2502
+ initContainers:
2503
+ - command:
2504
+ - /usr/local/bin/init-entrypoint.sh
2505
+ name: pgbackrest-init
2506
+ resources: {}
2507
+ securityContext:
2508
+ allowPrivilegeEscalation: false
2509
+ capabilities:
2510
+ drop:
2511
+ - ALL
2512
+ privileged: false
2513
+ readOnlyRootFilesystem: true
2514
+ runAsNonRoot: true
2515
+ seccompProfile:
2516
+ type: RuntimeDefault
2517
+ terminationMessagePath: /dev/termination-log
2518
+ terminationMessagePolicy: File
2519
+ volumeMounts:
2520
+ - mountPath: /opt/crunchy
2521
+ name: crunchy-bin
2499
2522
restartPolicy: Never
2500
2523
securityContext:
2501
2524
fsGroupChangePolicy: OnRootMismatch
2502
2525
volumes:
2526
+ - emptyDir: {}
2527
+ name: crunchy-bin
2503
2528
- name: pgbackrest-config
2504
2529
projected:
2505
2530
sources:
@@ -2533,7 +2558,7 @@ volumes:
2533
2558
}
2534
2559
job := generateBackupJobSpecIntent(ctx,
2535
2560
cluster, v1beta1.PGBackRestRepo{},
2536
- "",
2561
+ "", "",
2537
2562
nil, nil,
2538
2563
)
2539
2564
assert.Equal(t, job.Template.Spec.Containers[0].ImagePullPolicy, corev1.PullAlways)
@@ -2548,7 +2573,7 @@ volumes:
2548
2573
}
2549
2574
job := generateBackupJobSpecIntent(ctx,
2550
2575
cluster, v1beta1.PGBackRestRepo{},
2551
- "",
2576
+ "", "",
2552
2577
nil, nil,
2553
2578
)
2554
2579
assert.DeepEqual(t, job.Template.Spec.Containers[0].Resources,
@@ -2565,7 +2590,7 @@ volumes:
2565
2590
}
2566
2591
job := generateBackupJobSpecIntent(ctx,
2567
2592
cluster, v1beta1.PGBackRestRepo{},
2568
- "",
2593
+ "", "",
2569
2594
nil, nil,
2570
2595
)
2571
2596
assert.DeepEqual(t, job.Template.Spec.Containers[0].Resources,
@@ -2604,7 +2629,7 @@ volumes:
2604
2629
}
2605
2630
job := generateBackupJobSpecIntent(ctx,
2606
2631
cluster, v1beta1.PGBackRestRepo{},
2607
- "",
2632
+ "", "",
2608
2633
nil, nil,
2609
2634
)
2610
2635
assert.Equal(t, job.Template.Spec.Affinity, affinity)
@@ -2617,7 +2642,7 @@ volumes:
2617
2642
}
2618
2643
job := generateBackupJobSpecIntent(ctx,
2619
2644
cluster, v1beta1.PGBackRestRepo{},
2620
- "",
2645
+ "", "",
2621
2646
nil, nil,
2622
2647
)
2623
2648
assert.Equal(t, job.Template.Spec.PriorityClassName, "some-priority-class")
@@ -2635,7 +2660,7 @@ volumes:
2635
2660
}
2636
2661
job := generateBackupJobSpecIntent(ctx,
2637
2662
cluster, v1beta1.PGBackRestRepo{},
2638
- "",
2663
+ "", "",
2639
2664
nil, nil,
2640
2665
)
2641
2666
assert.DeepEqual(t, job.Template.Spec.Tolerations, tolerations)
@@ -2648,14 +2673,14 @@ volumes:
2648
2673
cluster.Spec.Backups.PGBackRest.Jobs = nil
2649
2674
2650
2675
spec := generateBackupJobSpecIntent(ctx,
2651
- cluster, v1beta1.PGBackRestRepo{}, "", nil, nil,
2676
+ cluster, v1beta1.PGBackRestRepo{}, "", "", nil, nil,
2652
2677
)
2653
2678
assert.Assert(t, spec.TTLSecondsAfterFinished == nil)
2654
2679
2655
2680
cluster.Spec.Backups.PGBackRest.Jobs = &v1beta1.BackupJobs{}
2656
2681
2657
2682
spec = generateBackupJobSpecIntent(ctx,
2658
- cluster, v1beta1.PGBackRestRepo{}, "", nil, nil,
2683
+ cluster, v1beta1.PGBackRestRepo{}, "", "", nil, nil,
2659
2684
)
2660
2685
assert.Assert(t, spec.TTLSecondsAfterFinished == nil)
2661
2686
})
@@ -2666,7 +2691,7 @@ volumes:
2666
2691
}
2667
2692
2668
2693
spec := generateBackupJobSpecIntent(ctx,
2669
- cluster, v1beta1.PGBackRestRepo{}, "", nil, nil,
2694
+ cluster, v1beta1.PGBackRestRepo{}, "", "", nil, nil,
2670
2695
)
2671
2696
if assert.Check(t, spec.TTLSecondsAfterFinished != nil) {
2672
2697
assert.Equal(t, *spec.TTLSecondsAfterFinished, int32(0))
@@ -2679,7 +2704,7 @@ volumes:
2679
2704
}
2680
2705
2681
2706
spec := generateBackupJobSpecIntent(ctx,
2682
- cluster, v1beta1.PGBackRestRepo{}, "", nil, nil,
2707
+ cluster, v1beta1.PGBackRestRepo{}, "", "", nil, nil,
2683
2708
)
2684
2709
if assert.Check(t, spec.TTLSecondsAfterFinished != nil) {
2685
2710
assert.Equal(t, *spec.TTLSecondsAfterFinished, int32(100))
0 commit comments