@@ -41,6 +41,24 @@ const (
41
41
BackupRestoreVolume = "backup-restore"
42
42
43
43
SolrZKConnectionStringAnnotation = "solr.apache.org/zkConnectionString"
44
+
45
+ DefaultLivenessProbeInitialDelaySeconds = 20
46
+ DefaultLivenessProbeTimeoutSeconds = 1
47
+ DefaultLivenessProbeSuccessThreshold = 1
48
+ DefaultLivenessProbeFailureThreshold = 3
49
+ DefaultLivenessProbePeriodSeconds = 10
50
+
51
+ DefaultReadinessProbeInitialDelaySeconds = 15
52
+ DefaultReadinessProbeTimeoutSeconds = 1
53
+ DefaultReadinessProbeSuccessThreshold = 1
54
+ DefaultReadinessProbeFailureThreshold = 3
55
+ DefaultReadinessProbePeriodSeconds = 5
56
+
57
+ DefaultStartupProbeInitialDelaySeconds = 20
58
+ DefaultStartupProbeTimeoutSeconds = 30
59
+ DefaultStartupProbeSuccessThreshold = 1
60
+ DefaultStartupProbeFailureThreshold = 15
61
+ DefaultStartupProbePeriodSeconds = 10
44
62
)
45
63
46
64
// GenerateStatefulSet returns a new appsv1.StatefulSet pointer generated for the SolrCloud instance
@@ -53,6 +71,13 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCl
53
71
solrPodPort := solrCloud .Spec .SolrAddressability .PodPort
54
72
fsGroup := int64 (solrPodPort )
55
73
defaultMode := int32 (420 )
74
+ defaultHandler := corev1.Handler {
75
+ HTTPGet : & corev1.HTTPGetAction {
76
+ Scheme : corev1 .URISchemeHTTP ,
77
+ Path : "/solr/admin/info/system" ,
78
+ Port : intstr .FromInt (solrPodPort ),
79
+ },
80
+ }
56
81
57
82
labels := solrCloud .SharedLabelsWith (solrCloud .GetLabels ())
58
83
selectorLabels := solrCloud .SharedLabels ()
@@ -276,37 +301,25 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCl
276
301
Protocol : "TCP" ,
277
302
},
278
303
},
279
- VolumeMounts : volumeMounts ,
280
- Args : []string {"-DhostPort=" + strconv .Itoa (solrAdressingPort )},
281
- Env : envVars ,
282
304
LivenessProbe : & corev1.Probe {
283
- InitialDelaySeconds : 20 ,
284
- TimeoutSeconds : 1 ,
285
- SuccessThreshold : 1 ,
286
- FailureThreshold : 3 ,
287
- PeriodSeconds : 10 ,
288
- Handler : corev1.Handler {
289
- HTTPGet : & corev1.HTTPGetAction {
290
- Scheme : corev1 .URISchemeHTTP ,
291
- Path : "/solr/admin/info/system" ,
292
- Port : intstr .FromInt (solrPodPort ),
293
- },
294
- },
305
+ InitialDelaySeconds : DefaultLivenessProbeInitialDelaySeconds ,
306
+ TimeoutSeconds : DefaultLivenessProbeTimeoutSeconds ,
307
+ SuccessThreshold : DefaultLivenessProbeSuccessThreshold ,
308
+ FailureThreshold : DefaultLivenessProbeFailureThreshold ,
309
+ PeriodSeconds : DefaultLivenessProbePeriodSeconds ,
310
+ Handler : defaultHandler ,
295
311
},
296
312
ReadinessProbe : & corev1.Probe {
297
- InitialDelaySeconds : 15 ,
298
- TimeoutSeconds : 1 ,
299
- SuccessThreshold : 1 ,
300
- FailureThreshold : 3 ,
301
- PeriodSeconds : 5 ,
302
- Handler : corev1.Handler {
303
- HTTPGet : & corev1.HTTPGetAction {
304
- Scheme : corev1 .URISchemeHTTP ,
305
- Path : "/solr/admin/info/system" ,
306
- Port : intstr .FromInt (solrPodPort ),
307
- },
308
- },
313
+ InitialDelaySeconds : DefaultReadinessProbeInitialDelaySeconds ,
314
+ TimeoutSeconds : DefaultReadinessProbeTimeoutSeconds ,
315
+ SuccessThreshold : DefaultReadinessProbeSuccessThreshold ,
316
+ FailureThreshold : DefaultReadinessProbeFailureThreshold ,
317
+ PeriodSeconds : DefaultReadinessProbePeriodSeconds ,
318
+ Handler : defaultHandler ,
309
319
},
320
+ VolumeMounts : volumeMounts ,
321
+ Args : []string {"-DhostPort=" + strconv .Itoa (solrAdressingPort )},
322
+ Env : envVars ,
310
323
TerminationMessagePath : "/dev/termination-log" ,
311
324
TerminationMessagePolicy : "File" ,
312
325
},
@@ -353,6 +366,19 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCl
353
366
if customPodOptions .NodeSelector != nil {
354
367
stateful .Spec .Template .Spec .NodeSelector = customPodOptions .NodeSelector
355
368
}
369
+
370
+ if customPodOptions .LivenessProbe != nil {
371
+ stateful .Spec .Template .Spec .Containers [0 ].LivenessProbe = fillProbe (* customPodOptions .LivenessProbe , DefaultLivenessProbeInitialDelaySeconds , DefaultLivenessProbeTimeoutSeconds , DefaultLivenessProbeSuccessThreshold , DefaultLivenessProbeFailureThreshold , DefaultLivenessProbePeriodSeconds , & defaultHandler )
372
+ }
373
+
374
+ if customPodOptions .ReadinessProbe != nil {
375
+ stateful .Spec .Template .Spec .Containers [0 ].ReadinessProbe = fillProbe (* customPodOptions .ReadinessProbe , DefaultReadinessProbeInitialDelaySeconds , DefaultReadinessProbeTimeoutSeconds , DefaultReadinessProbeSuccessThreshold , DefaultReadinessProbeFailureThreshold , DefaultReadinessProbePeriodSeconds , & defaultHandler )
376
+ }
377
+
378
+ if customPodOptions .StartupProbe != nil {
379
+ stateful .Spec .Template .Spec .Containers [0 ].StartupProbe = fillProbe (* customPodOptions .StartupProbe , DefaultStartupProbeInitialDelaySeconds , DefaultStartupProbeTimeoutSeconds , DefaultStartupProbeSuccessThreshold , DefaultStartupProbeFailureThreshold , DefaultStartupProbePeriodSeconds , & defaultHandler )
380
+ }
381
+
356
382
}
357
383
358
384
return stateful
@@ -526,6 +552,44 @@ func CopyConfigMapFields(from, to *corev1.ConfigMap) bool {
526
552
return requireUpdate
527
553
}
528
554
555
+ // fillProbe builds the probe logic used for pod liveness, readiness, startup checks
556
+ func fillProbe (customSolrKubeOptions corev1.Probe , defaultInitialDelaySeconds int32 , defaultTimeoutSeconds int32 , defaultSuccessThreshold int32 , defaultFailureThreshold int32 , defaultPeriodSeconds int32 , defaultHandler * corev1.Handler ) * corev1.Probe {
557
+ probe := & corev1.Probe {
558
+ InitialDelaySeconds : defaultInitialDelaySeconds ,
559
+ TimeoutSeconds : defaultTimeoutSeconds ,
560
+ SuccessThreshold : defaultSuccessThreshold ,
561
+ FailureThreshold : defaultFailureThreshold ,
562
+ PeriodSeconds : defaultPeriodSeconds ,
563
+ Handler : * defaultHandler ,
564
+ }
565
+
566
+ if customSolrKubeOptions .InitialDelaySeconds != 0 {
567
+ probe .InitialDelaySeconds = customSolrKubeOptions .InitialDelaySeconds
568
+ }
569
+
570
+ if customSolrKubeOptions .TimeoutSeconds != 0 {
571
+ probe .TimeoutSeconds = customSolrKubeOptions .TimeoutSeconds
572
+ }
573
+
574
+ if customSolrKubeOptions .SuccessThreshold != 0 {
575
+ probe .SuccessThreshold = customSolrKubeOptions .SuccessThreshold
576
+ }
577
+
578
+ if customSolrKubeOptions .FailureThreshold != 0 {
579
+ probe .FailureThreshold = customSolrKubeOptions .FailureThreshold
580
+ }
581
+
582
+ if customSolrKubeOptions .PeriodSeconds != 0 {
583
+ probe .PeriodSeconds = customSolrKubeOptions .PeriodSeconds
584
+ }
585
+
586
+ if customSolrKubeOptions .Handler .Exec != nil || customSolrKubeOptions .Handler .HTTPGet != nil {
587
+ probe .Handler = customSolrKubeOptions .Handler
588
+ }
589
+
590
+ return probe
591
+ }
592
+
529
593
// GenerateCommonService returns a new corev1.Service pointer generated for the entire SolrCloud instance
530
594
// solrCloud: SolrCloud instance
531
595
func GenerateCommonService (solrCloud * solr.SolrCloud ) * corev1.Service {
0 commit comments