This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new b6504a7f Remove the preStop hook from the Solr container (#891)
b6504a7f is described below

commit b6504a7ff46cef6bfd93240d21fb8df2a34aa457
Author: Jan Høydahl <[email protected]>
AuthorDate: Thu Nov 19 00:40:16 2026 +0100

    Remove the preStop hook from the Solr container (#891)
---
 .../solrcloud_controller_externaldns_test.go       | 14 ++++++------
 controllers/solrcloud_controller_ingress_test.go   | 14 ++++++------
 controllers/solrcloud_controller_test.go           |  6 ++---
 controllers/solrcloud_controller_zk_test.go        | 14 +++++-------
 controllers/util/solr_util.go                      | 26 +++-------------------
 docs/modules/solr-cloud/pages/solr-cloud-crd.adoc  |  4 ++--
 .../modules/upgrade-notes/pages/upgrade-notes.adoc |  8 +++++++
 helm/solr-operator/Chart.yaml                      |  5 +++++
 8 files changed, 40 insertions(+), 51 deletions(-)

diff --git a/controllers/solrcloud_controller_externaldns_test.go 
b/controllers/solrcloud_controller_externaldns_test.go
index 1ea2293b..87bd8a60 100644
--- a/controllers/solrcloud_controller_externaldns_test.go
+++ b/controllers/solrcloud_controller_externaldns_test.go
@@ -105,7 +105,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -184,7 +184,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "2000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -256,7 +256,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -327,7 +327,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -396,7 +396,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        hostnameAnnotation := solrCloud.Namespace + "." + 
testDomain
                        for _, domain := range testAdditionalDomains {
@@ -477,7 +477,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "2000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -543,7 +543,7 @@ var _ = FDescribe("SolrCloud controller - External DNS", 
func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "2000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
diff --git a/controllers/solrcloud_controller_ingress_test.go 
b/controllers/solrcloud_controller_ingress_test.go
index 07a62852..f287712e 100644
--- a/controllers/solrcloud_controller_ingress_test.go
+++ b/controllers/solrcloud_controller_ingress_test.go
@@ -121,7 +121,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -309,7 +309,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -387,7 +387,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -463,7 +463,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -541,7 +541,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -615,7 +615,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
@@ -692,7 +692,7 @@ var _ = FDescribe("SolrCloud controller - Ingress", func() {
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "3000"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the Solr Common Service")
                        commonService := expectService(ctx, solrCloud, 
solrCloud.CommonServiceName(), statefulSet.Spec.Selector.MatchLabels, false)
diff --git a/controllers/solrcloud_controller_test.go 
b/controllers/solrcloud_controller_test.go
index 6cadfea6..4177388c 100644
--- a/controllers/solrcloud_controller_test.go
+++ b/controllers/solrcloud_controller_test.go
@@ -21,7 +21,6 @@ import (
        "context"
        "crypto/md5"
        "fmt"
-       "strconv"
        "strings"
 
        solrv1beta1 "github.com/apache/solr-operator/api/v1beta1"
@@ -138,7 +137,7 @@ var _ = FDescribe("SolrCloud controller - General", func() {
                        testPodEnvVariables(expectedEnvVars, 
append(foundEnv[:len(foundEnv)-3], foundEnv[len(foundEnv)-1]))
 
                        // Other Pod Options Checks
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PostStart).To(BeNil(),
 "Post-start command should be nil.")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
                        
Expect(statefulSet.Spec.Template.Spec.Containers[0].EnvFrom).To(Equal(extraEnvFrom),
 "EnvFrom is not the same as the one provided in podOptions")
                        
Expect(statefulSet.Spec.Template.Spec.SecurityContext).To(Not(BeNil()), 
"PodSecurityContext is not the same as the one provided in podOptions")
                        
Expect(*statefulSet.Spec.Template.Spec.SecurityContext).To(Equal(testPodSecurityContext),
 "PodSecurityContext is not the same as the one provided in podOptions")
@@ -309,7 +308,6 @@ var _ = FDescribe("SolrCloud controller - General", func() {
                                "SOLR_PORT_ADVERTISE": "8983",
                                "GC_TUNE":             "gc Options",
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN)",
-                               "SOLR_STOP_WAIT":      
strconv.FormatInt(testTerminationGracePeriodSeconds-5, 10),
                        }
                        expectedStatefulSetLabels := 
util.MergeLabelsOrAnnotations(solrCloud.SharedLabelsWith(solrCloud.Labels), 
map[string]string{"technology": util.SolrCloudPVCTechnology})
                        expectedStatefulSetAnnotations := 
map[string]string{util.SolrZKConnectionStringAnnotation: "host:7271/test"}
@@ -421,7 +419,7 @@ var _ = FDescribe("SolrCloud controller - General", func() {
                        expectedStatefulSetAnnotations := 
map[string]string{util.SolrZKConnectionStringAnnotation: expectedZKHost}
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
                        
Expect(statefulSet.Annotations).To(Equal(expectedStatefulSetAnnotations), 
"Incorrect statefulSet annotations")
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PostStart).To(BeNil(),
 "There should be no postStart command, even if there is a chRoot for ZK")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
                        
Expect(statefulSet.Spec.Template.Spec.ServiceAccountName).To(BeEmpty(), "No 
custom serviceAccountName specified, so the field should be empty.")
 
                        // PodDisruptionBudget creation should be enabled by 
default
diff --git a/controllers/solrcloud_controller_zk_test.go 
b/controllers/solrcloud_controller_zk_test.go
index db17a4a8..7762bf85 100644
--- a/controllers/solrcloud_controller_zk_test.go
+++ b/controllers/solrcloud_controller_zk_test.go
@@ -19,7 +19,6 @@ package controllers
 
 import (
        "context"
-       "strconv"
 
        solrv1beta1 "github.com/apache/solr-operator/api/v1beta1"
        "github.com/apache/solr-operator/controllers/util"
@@ -117,7 +116,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                        }
                        foundEnv := 
statefulSet.Spec.Template.Spec.Containers[0].Env
                        testPodEnvVariables(expectedEnvVars, foundEnv)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "8983"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
                })
        })
 
@@ -183,7 +182,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                        }
                        foundEnv := 
statefulSet.Spec.Template.Spec.Containers[0].Env
                        testPodEnvVariables(expectedEnvVars, foundEnv)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "8983"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing that no ZookeeperCluster is created when 
using a connection String")
                        expectNoZookeeperCluster(ctx, solrCloud, 
solrCloud.ProvidedZookeeperName())
@@ -268,7 +267,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                        expectedStatefulSetAnnotations := 
map[string]string{util.SolrZKConnectionStringAnnotation: expectedZKHost}
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
                        
Expect(statefulSet.Annotations).To(Equal(util.MergeLabelsOrAnnotations(testSSAnnotations,
 expectedStatefulSetAnnotations)), "Wrong statefulSet annotations")
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PostStart).To(BeNil(),
 "There should be no postStart command, even if there is a chRoot for ZK")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
                        
Expect(statefulSet.Spec.Template.Spec.ServiceAccountName).To(BeEmpty(), "No 
custom serviceAccountName specified, so the field should be empty.")
                        
Expect(statefulSet.Spec.Template.Spec.InitContainers).To(HaveLen(1), "Solr 
StatefulSet requires 1 init container, for ZK.")
                        
Expect(statefulSet.Spec.Template.Spec.InitContainers[0].Command).To(Equal([]string{"sh",
 "-c", "solr zk ls ${ZK_CHROOT} -z ${ZK_SERVER} || solr zk mkroot ${ZK_CHROOT} 
-z ${ZK_SERVER}; "}), "Wrong command for the ZK init container")
@@ -377,7 +376,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                        expectedStatefulSetAnnotations := 
map[string]string{util.SolrZKConnectionStringAnnotation: expectedZKHost}
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
                        
Expect(statefulSet.Annotations).To(Equal(expectedStatefulSetAnnotations), 
"Wrong statefulSet annotations")
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PostStart).To(BeNil(),
 "No post-start command should be provided when no Chroot is used")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
                        
Expect(statefulSet.Spec.Template.Spec.ServiceAccountName).To(BeEmpty(), "No 
custom serviceAccountName specified, so the field should be empty.")
 
                        // Check the update strategy
@@ -467,7 +466,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                        }
                        foundEnv := 
statefulSet.Spec.Template.Spec.Containers[0].Env
                        testPodEnvVariables(expectedEnvVars, foundEnv)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "8983"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the created ZookeeperCluster")
                        expectZookeeperCluster(ctx, solrCloud, 
solrCloud.ProvidedZookeeperName())
@@ -543,7 +542,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                        }
                        foundEnv := 
statefulSet.Spec.Template.Spec.Containers[0].Env
                        testPodEnvVariables(expectedEnvVars, foundEnv)
-                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal([]string{"solr",
 "stop", "-p", "8983"}), "Incorrect pre-stop command")
+                       
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle).To(BeNil(), "No 
lifecycle hooks should be set by default")
 
                        By("testing the created ZookeeperCluster")
                        expectZookeeperCluster(ctx, solrCloud, 
solrCloud.ProvidedZookeeperName())
@@ -578,7 +577,6 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", 
func() {
                                "SOLR_PORT_ADVERTISE": "8983",
                                "SOLR_ZK_OPTS":        testSolrZKOpts,
                                "SOLR_OPTS":           
"-DhostPort=$(SOLR_NODE_PORT) -Davailability_zone=$(SOLR_AVAILABILITY_ZONE) 
-Dspread_domain=$(SOLR_SPREAD_DOMAIN) $(SOLR_ZK_OPTS) " + testSolrOpts,
-                               "SOLR_STOP_WAIT":      strconv.FormatInt(60-5, 
10),
                        }
                        testPodEnvVariables(expectedEnvVars, 
statefulSet.Spec.Template.Spec.Containers[0].Env)
 
diff --git a/controllers/util/solr_util.go b/controllers/util/solr_util.go
index b0cf8a88..498dee2c 100644
--- a/controllers/util/solr_util.go
+++ b/controllers/util/solr_util.go
@@ -322,12 +322,6 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, 
solrCloudStatus *solr.SolrCl
        solrHostName := solrCloud.AdvertisedNodeHost("$(POD_NAME)")
        solrAdressingPort := solrCloud.NodePort()
 
-       // Solr can take longer than SOLR_STOP_WAIT to run solr stop, give it a 
few extra seconds before forcefully killing the pod.
-       solrStopWait := terminationGracePeriod - 5
-       if solrStopWait < 0 {
-               solrStopWait = 0
-       }
-
        // Environment Variables
        var envFrom []corev1.EnvFromSource
        envVars := []corev1.EnvVar{
@@ -425,10 +419,6 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, 
solrCloudStatus *solr.SolrCl
                        Name:  "GC_TUNE",
                        Value: solrCloud.Spec.SolrGCTune,
                },
-               {
-                       Name:  "SOLR_STOP_WAIT",
-                       Value: strconv.FormatInt(solrStopWait, 10),
-               },
        }
 
        // Add all necessary information for connection to Zookeeper
@@ -443,13 +433,6 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, 
solrCloudStatus *solr.SolrCl
                envVars = append(envVars, backupEnvVars...)
        }
 
-       // Default preStop hook
-       preStop := &corev1.LifecycleHandler{
-               Exec: &corev1.ExecAction{
-                       Command: []string{"solr", "stop", "-p", 
strconv.Itoa(solrPodPort)},
-               },
-       }
-
        // Add Custom EnvironmentVariables and EnvFrom to the solr container
        if nil != customPodOptions {
                envVars = append(envVars, customPodOptions.EnvVariables...)
@@ -537,12 +520,9 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, 
solrCloudStatus *solr.SolrCl
                                PeriodSeconds:    10,
                                ProbeHandler:     defaultReadinessProbe,
                        },
-                       VolumeMounts: volumeMounts,
-                       Env:          envVars,
-                       EnvFrom:      envFrom,
-                       Lifecycle: &corev1.Lifecycle{
-                               PreStop: preStop,
-                       },
+                       VolumeMounts:    volumeMounts,
+                       Env:             envVars,
+                       EnvFrom:         envFrom,
                        SecurityContext: containerSecurityContext,
                },
        }
diff --git a/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc 
b/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc
index 263b09f5..040730f4 100644
--- a/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc
+++ b/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc
@@ -170,9 +170,9 @@ There are various runtime parameters that allow you to 
customize the running of
 
 === Time to wait for Solr to be killed gracefully
 
-The Solr Operator manages the Solr StatefulSet in a way that when a Solr pod 
needs to be stopped, or deleted, Kubernetes and Solr are on the same page for 
how long to wait for the process to die gracefully.
+When a Solr pod needs to be stopped, or deleted, Kubernetes sends `SIGTERM` to 
the Solr process, which shuts Solr down gracefully.
 
-The default time given is 60 seconds, before Solr or Kubernetes tries to 
forcefully stop the Solr process.
+The default time given is 60 seconds, before Kubernetes tries to forcefully 
stop the Solr process.
 You can override this default with the field:
 
 [source,yaml]
diff --git a/docs/modules/upgrade-notes/pages/upgrade-notes.adoc 
b/docs/modules/upgrade-notes/pages/upgrade-notes.adoc
index b631f940..0a7bf3e6 100644
--- a/docs/modules/upgrade-notes/pages/upgrade-notes.adoc
+++ b/docs/modules/upgrade-notes/pages/upgrade-notes.adoc
@@ -159,6 +159,14 @@ The label is only copied onto pods by Kubernetes `v1.35`+, 
and the property is e
 Solr pods also get the `spread_domain` system property, set to the name of 
their Kubernetes node, which Solr only uses when `spreadAcrossDomains` is 
enabled in the `AffinityPlacementFactory` configuration.
 These are part of the same pod spec change that restarts the Solr pods during 
this upgrade, so they do not cause an additional restart.
 
+* The `preStop` hook running `solr stop` has been removed, along with the 
`SOLR_STOP_WAIT` envVar that only served it, so pod deletions no longer emit a 
`FailedPreStopHook` warning event.
+Solr now shuts down on the `SIGTERM` that Kubernetes sends, which runs the 
same graceful shutdown.
+** This is part of the same pod spec change that restarts the Solr pods during 
this upgrade, so it does not cause an additional restart.
+The old pods emit the `FailedPreStopHook` event one last time as they are 
replaced.
+** A stopped Solr container now exits with code `143` instead of `0`, so its 
last state shows `Error` instead of `Completed`.
+** A custom Solr image whose entrypoint does not pass `SIGTERM` on to the Solr 
process is now killed at the end of `terminationGracePeriodSeconds`.
+Fix the entrypoint, or set your own `preStop` hook through 
`customSolrKubeOptions.podOptions.lifecycle`.
+
 === v0.8.0
 
 * *The minimum supported Solr version is now 8.11*
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index ad6a8b68..14bd4317 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -55,6 +55,11 @@ annotations:
   # Allowed syntax is described at: 
https://artifacthub.io/docs/topics/annotations/helm/#example
   # 'kind' accepts values: "added", "changed", "deprecated", "removed", 
"fixed" and "security"
   artifacthub.io/changes: |
+    - kind: removed
+      description: The preStop hook running 'solr stop' has been removed from 
the Solr container, along with the SOLR_STOP_WAIT envVar that only served it. 
Solr shuts down on SIGTERM, so pod deletions no longer emit a FailedPreStopHook 
warning event
+      links:
+        - name: Github Issue
+          url: https://github.com/apache/solr-operator/issues/871
     - kind: added
       description: The operator can now resize (expand) persistent data PVCs, 
which requires new RBAC permissions for persistentvolumeclaims (update/patch) 
and storageclasses (get/list/watch)
       links:

Reply via email to