This is an automated email from the ASF dual-hosted git repository.
houston 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 29982f0 Don't kill SolrCloud pods on StatefulSet creation (#432)
29982f0 is described below
commit 29982f09ca0051457dd14d6c7c718a98504f8db2
Author: Houston Putman <[email protected]>
AuthorDate: Tue May 24 13:09:10 2022 -0400
Don't kill SolrCloud pods on StatefulSet creation (#432)
This waits until the Operator is aware of a StatefulSet status
to kill the SolrCloud pods that are out of date. Otherwise it will think
all SolrCloud pods are out of date, because it doesn't have a
currentRevision from the StatefulSet status.
---
controllers/solrcloud_controller.go | 13 ++++++++-----
helm/solr-operator/Chart.yaml | 7 +++++++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/controllers/solrcloud_controller.go
b/controllers/solrcloud_controller.go
index aaad802..2270353 100644
--- a/controllers/solrcloud_controller.go
+++ b/controllers/solrcloud_controller.go
@@ -322,8 +322,8 @@ func (r *SolrCloudReconciler) Reconcile(ctx
context.Context, req ctrl.Request) (
err = r.Get(ctx, types.NamespacedName{Name: statefulSet.Name,
Namespace: statefulSet.Namespace}, foundStatefulSet)
// Set the annotation for a scheduled restart, if necessary.
- if nextRestartAnnotation, reconcileWaitDuration, err :=
util.ScheduleNextRestart(instance.Spec.UpdateStrategy.RestartSchedule,
foundStatefulSet.Spec.Template.Annotations); err != nil {
- logger.Error(err, "Cannot parse restartSchedule cron",
"cron", instance.Spec.UpdateStrategy.RestartSchedule)
+ if nextRestartAnnotation, reconcileWaitDuration, schedulingErr
:= util.ScheduleNextRestart(instance.Spec.UpdateStrategy.RestartSchedule,
foundStatefulSet.Spec.Template.Annotations); schedulingErr != nil {
+ logger.Error(schedulingErr, "Cannot parse
restartSchedule cron", "cron", instance.Spec.UpdateStrategy.RestartSchedule)
} else {
if nextRestartAnnotation != "" {
// Set the new restart time annotation
@@ -518,8 +518,6 @@ func (r *SolrCloudReconciler) reconcileCloudStatus(ctx
context.Context, solrClou
nodeNames := make([]string, len(foundPods.Items))
nodeStatusMap := map[string]solrv1beta1.SolrNodeStatus{}
- updateRevision := statefulSetStatus.UpdateRevision
-
newStatus.Replicas = statefulSetStatus.Replicas
newStatus.UpToDateNodes = int32(0)
newStatus.ReadyReplicas = int32(0)
@@ -570,7 +568,12 @@ func (r *SolrCloudReconciler) reconcileCloudStatus(ctx
context.Context, solrClou
}
// A pod is out of date if it's revision label is not equal to
the statefulSetStatus' updateRevision.
- nodeStatus.SpecUpToDate = p.Labels["controller-revision-hash"]
== updateRevision
+ // Assume the pod is up-to-date if we don't have an
updateRevision from the statefulSet status.
+ // This should only happen when the statefulSet has just been
created, so it's not a big deal.
+ // NOTE: This is usually because the statefulSet status wasn't
fetched, not because the fetched updateRevision
+ // is empty.
+ updateRevision := statefulSetStatus.UpdateRevision
+ nodeStatus.SpecUpToDate = updateRevision == "" ||
p.Labels["controller-revision-hash"] == updateRevision
if nodeStatus.SpecUpToDate {
newStatus.UpToDateNodes += 1
if nodeStatus.Ready {
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index 6c89772..64ff1d6 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -103,6 +103,13 @@ annotations:
url: https://github.com/apache/solr-operator/issues/438
- name: Github PR
url: https://github.com/apache/solr-operator/pull/439
+ - kind: fixed
+ description: SolrCloud pods are no longer deleted right after a
SolrCloud is created.
+ links:
+ - name: Github Issue
+ url: https://github.com/apache/solr-operator/issues/431
+ - name: Github PR
+ url: https://github.com/apache/solr-operator/pull/432
artifacthub.io/images: |
- name: solr-operator
image: apache/solr-operator:v0.6.0-prerelease