@@ -3005,21 +3005,42 @@ func TestReconcile_ProbeConfiguration(t *testing.T) {
30053005 }
30063006 })
30073007
3008+ t .Run ("LivenessProbeEmptyObjectRemainsDisabled" , func (t * testing.T ) {
3009+ cp := createCoderControlPlaneUnstructured (ctx , t , "test-probe-liveness-empty-object" , "default" , map [string ]any {
3010+ "image" : "test-probes:latest" ,
3011+ "livenessProbe" : map [string ]any {},
3012+ })
3013+
3014+ r := & controller.CoderControlPlaneReconciler {Client : k8sClient , Scheme : scheme }
3015+ if _ , err := r .Reconcile (ctx , ctrl.Request {NamespacedName : types.NamespacedName {Name : cp .Name , Namespace : cp .Namespace }}); err != nil {
3016+ t .Fatalf ("reconcile control plane: %v" , err )
3017+ }
3018+
3019+ deployment := & appsv1.Deployment {}
3020+ if err := k8sClient .Get (ctx , types.NamespacedName {Name : cp .Name , Namespace : cp .Namespace }, deployment ); err != nil {
3021+ t .Fatalf ("get deployment: %v" , err )
3022+ }
3023+ container := deployment .Spec .Template .Spec .Containers [0 ]
3024+ if container .LivenessProbe != nil {
3025+ t .Fatalf ("expected liveness probe to stay disabled for empty object, got %#v" , container .LivenessProbe )
3026+ }
3027+ })
3028+
30083029 t .Run ("BothProbesEnabledWithCustomTiming" , func (t * testing.T ) {
30093030 cp := & coderv1alpha1.CoderControlPlane {
30103031 ObjectMeta : metav1.ObjectMeta {Name : "test-probe-custom" , Namespace : "default" },
30113032 Spec : coderv1alpha1.CoderControlPlaneSpec {
30123033 Image : "test-probes:latest" ,
30133034 ReadinessProbe : coderv1alpha1.ProbeSpec {
3014- Enabled : true ,
3035+ Enabled : ptrTo ( true ) ,
30153036 InitialDelaySeconds : 3 ,
30163037 PeriodSeconds : ptrTo (int32 (7 )),
30173038 TimeoutSeconds : ptrTo (int32 (2 )),
30183039 SuccessThreshold : ptrTo (int32 (2 )),
30193040 FailureThreshold : ptrTo (int32 (5 )),
30203041 },
30213042 LivenessProbe : coderv1alpha1.ProbeSpec {
3022- Enabled : true ,
3043+ Enabled : ptrTo ( true ) ,
30233044 InitialDelaySeconds : 11 ,
30243045 PeriodSeconds : ptrTo (int32 (13 )),
30253046 TimeoutSeconds : ptrTo (int32 (4 )),
0 commit comments