Skip to content

Commit b2ced05

Browse files
authored
always push ready event #14 (#15)
1 parent 58d3947 commit b2ced05

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ OPERATOR_SDK_VERSION ?= v1.38.0
5252
# Image URL to use all building/pushing image targets
5353
DOCKER_HUB_NAME ?= $(shell docker info | sed '/Username:/!d;s/.* //')
5454
IMG_NAME ?= typesense-operator
55-
IMG_TAG ?= 0.2.3
55+
IMG_TAG ?= 0.2.4
5656
IMG ?= $(DOCKER_HUB_NAME)/$(IMG_NAME):$(IMG_TAG)
5757

5858
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.

charts/typesense-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ type: application
1313
# This is the chart version. This version number should be incremented each time you make changes
1414
# to the chart and its templates, including the app version.
1515
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16-
version: 0.2.3
16+
version: 0.2.4
1717
# This is the version number of the application being deployed. This version number should be
1818
# incremented each time you make changes to the application. Versions are not expected to
1919
# follow Semantic Versioning. They should reflect the version the application is using.
2020
# It is recommended to use it with quotes.
21-
appVersion: "0.2.3"
21+
appVersion: "0.2.4"

charts/typesense-operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ controllerManager:
1212
- ALL
1313
image:
1414
repository: akyriako78/typesense-operator
15-
tag: 0.2.3
15+
tag: 0.2.4
1616
resources:
1717
limits:
1818
cpu: 500m

internal/controller/typesensecluster_controller.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import (
2020
"context"
2121
"github.com/go-logr/logr"
2222
"github.com/pkg/errors"
23-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
"golang.org/x/text/cases"
24+
"golang.org/x/text/language"
2425
"k8s.io/apimachinery/pkg/runtime"
2526
"k8s.io/client-go/tools/record"
2627
ctrl "sigs.k8s.io/controller-runtime"
@@ -77,7 +78,7 @@ var (
7778
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
7879
// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch
7980
// +kubebuilder:rbac:groups=networking.k8s.io,resources=ingresses,verbs=get;list;watch;create;update;patch;delete
80-
//+kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
81+
// +kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
8182

8283
// Reconcile is part of the main kubernetes reconciliation loop which aims to
8384
// move the current state of the cluster closer to the desired state.
@@ -159,6 +160,10 @@ func (r *TypesenseClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
159160
terminationGracePeriodSeconds := *sts.Spec.Template.Spec.TerminationGracePeriodSeconds
160161
delayPerReplicaPeriodSeconds := int64(ts.Spec.Replicas)
161162

163+
toTitle := func(s string) string {
164+
return cases.Title(language.Und, cases.NoLower).String(s)
165+
}
166+
162167
if *updated {
163168
condition, size, err := r.ReconcileQuorum(ctx, ts, *sts)
164169
if err != nil {
@@ -174,7 +179,7 @@ func (r *TypesenseClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
174179
return ctrl.Result{}, cerr
175180
}
176181

177-
r.Recorder.Eventf(&ts, "Warning", string(condition), err.Error())
182+
r.Recorder.Eventf(&ts, "Warning", string(condition), toTitle(err.Error()))
178183

179184
if size != 0 {
180185
delayPerReplicaPeriodSeconds = int64(size)
@@ -192,22 +197,20 @@ func (r *TypesenseClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
192197
return ctrl.Result{}, cerr
193198
}
194199

195-
r.Recorder.Eventf(&ts, "Warning", string(condition), err.Error())
200+
r.Recorder.Eventf(&ts, "Warning", string(condition), toTitle(err.Error()))
196201

197202
if size != 0 {
198203
delayPerReplicaPeriodSeconds = int64(size)
199204
}
200205
} else {
201-
c := ts.Status.Conditions[0]
206+
//c := ts.Status.Conditions[0]
202207

203208
cerr := r.setConditionReady(ctx, &ts, string(condition))
204209
if cerr != nil {
205210
return ctrl.Result{}, cerr
206211
}
207212

208-
if c.Status != metav1.ConditionTrue {
209-
r.Recorder.Eventf(&ts, "Normal", string(condition), "quorum is ready")
210-
}
213+
r.Recorder.Eventf(&ts, "Normal", string(condition), toTitle("quorum is ready"))
211214

212215
delayPerReplicaPeriodSeconds = int64(1)
213216
}

0 commit comments

Comments
 (0)